public void SetupSentimentPipeline() { _sentimentExample = new SentimentData() { SentimentText = "Not a big fan of this." }; string _sentimentDataPath = Program.GetInvariantCultureDataPath("wikipedia-detox-250-line-data.tsv"); var env = new MLContext(seed: 1, conc: 1); var reader = new TextLoader(env, columns: new[] { new TextLoader.Column("Label", DataKind.BL, 0), new TextLoader.Column("SentimentText", DataKind.Text, 1) }, hasHeader: true ); IDataView data = reader.Read(_sentimentDataPath); var pipeline = new TextFeaturizingEstimator(env, "SentimentText", "Features") .Append(new SdcaBinaryTrainer(env, "Label", "Features", advancedSettings: (s) => { s.NumThreads = 1; s.ConvergenceTolerance = 1e-2f; })); var model = pipeline.Fit(data); _sentimentModel = model.CreatePredictionEngine <SentimentData, SentimentPrediction>(env); }
public void SetupSentimentPipeline() { _sentimentExample = new SentimentData() { SentimentText = "Not a big fan of this." }; string _sentimentDataPath = BaseTestClass.GetDataPath("wikipedia-detox-250-line-data.tsv"); var env = new MLContext(seed: 1, conc: 1); var reader = new TextLoader(env, columns: new[] { new TextLoader.Column("Label", DataKind.BL, 0), new TextLoader.Column("SentimentText", DataKind.Text, 1) }, hasHeader: true ); IDataView data = reader.Read(_sentimentDataPath); var pipeline = new TextFeaturizingEstimator(env, "Features", "SentimentText") .Append(env.BinaryClassification.Trainers.StochasticDualCoordinateAscent( new SdcaBinaryTrainer.Options { NumThreads = 1, ConvergenceTolerance = 1e-2f, })); var model = pipeline.Fit(data); _sentimentModel = model.CreatePredictionEngine <SentimentData, SentimentPrediction>(env); }
public void SetupSentimentPipeline() { _sentimentExample = new SentimentData() { SentimentText = "Not a big fan of this." }; string _sentimentDataPath = Program.GetInvariantCultureDataPath("wikipedia-detox-250-line-data.tsv"); using (var env = new ConsoleEnvironment(seed: 1, conc: 1, verbose: false, sensitivity: MessageSensitivity.None, outWriter: EmptyWriter.Instance)) { var reader = new TextLoader(env, new TextLoader.Arguments() { Separator = "\t", HasHeader = true, Column = new[] { new TextLoader.Column("Label", DataKind.BL, 0), new TextLoader.Column("SentimentText", DataKind.Text, 1) } }); IDataView data = reader.Read(_sentimentDataPath); var pipeline = new TextFeaturizingEstimator(env, "SentimentText", "Features") .Append(new SdcaBinaryTrainer(env, "Label", "Features", advancedSettings: (s) => { s.NumThreads = 1; s.ConvergenceTolerance = 1e-2f; })); var model = pipeline.Fit(data); _sentimentModel = model.MakePredictionFunction <SentimentData, SentimentPrediction>(env); } }