private static void PredictIssue() { ITransformer loadedModel = _mLContext.Model.Load(_modelPath, out var modelInputSchema); Sentiment_Analysis singlesentiment = new Sentiment_Analysis() { Phrase = "" }; _predEngine = _mLContext.Model.CreatePredictionEngine<Sentiment_Analysis, Sentiments>(loadedModel); var prediction = _predEngine.Predict(singlesentiment); Console.WriteLine($"{prediction.Sentiment}"); }
public static IEstimator<ITransformer> BuildAndTrainModel(IDataView trainingDataView, IEstimator<ITransformer> pipeline) { var trainingPipline = pipeline.Append(_mLContext.MulticlassClassification.Trainers.SdcaMaximumEntropy("Label", "Features")) .Append(_mLContext.Transforms.Conversion.MapKeyToValue("PredictedLabel")); _trainedmodel = trainingPipline.Fit(trainingDataView); _predEngine = _mLContext.Model.CreatePredictionEngine<Sentiment_Analysis, Sentiments>(_trainedmodel); Sentiment_Analysis se = new Sentiment_Analysis() { Phrase = //"This terms candidates are very normal" "This website sucks" }; var prediction = _predEngine.Predict(se); Console.WriteLine($"single line prediction { prediction.Sentiment}"); return trainingPipline; }