Intent PredictSingleItem(ClassificationData statement, bool debug = false) { PredictionEngine <ClassificationData, ClassificationPrediction> predictionFunction = _mlContext.Model.CreatePredictionEngine <ClassificationData, ClassificationPrediction>(_model); var resultprediction = predictionFunction.Predict(statement); Intent intent = new Intent(); intent.Name = _datasetName; intent.Score = resultprediction.Probability; if (debug) { Console.WriteLine("-------- Prediction of " + _datasetName + " model --------"); Console.WriteLine("Query: " + resultprediction.Content + " | Prediction (" + _datasetName + "): " + Convert.ToBoolean(resultprediction.Prediction) + " | Probability: " + resultprediction.Probability); Console.WriteLine("----------------------------------------------------"); Console.WriteLine(); } return(intent); }
public Intent Classify(string query, bool debug = false) { ClassificationData statement = new ClassificationData { Content = query }; return(PredictSingleItem(statement, debug)); }