Пример #1
0
        private static void PredictIssue()
        {
            ITransformer loadedModel = _mlContext.Model.Load(_modelPath, out var modelInputSchema);

            GitHubIssue singleIssue = new GitHubIssue()
            {
                Title       = "Entity Framework crashes",
                Description = "When connecting to the database, EF is crashing"
            };

            _predictionEngine = _mlContext.Model.CreatePredictionEngine <GitHubIssue, IssuePrediction>(loadedModel);

            var prediction = _predictionEngine.Predict(singleIssue);

            Console.WriteLine($"=============== Single Prediction - Result: {prediction.Area} ===============");
        }
Пример #2
0
        private static IEstimator <ITransformer> BuildAndTrainModel(IDataView trainingDataView,
                                                                    IEstimator <ITransformer> pipeline)
        {
            var trainingPipeline = pipeline
                                   .Append(_mlContext.MulticlassClassification.Trainers.SdcaMaximumEntropy("Label", "Features"))
                                   .Append(_mlContext.Transforms.Conversion.MapKeyToValue("PredictedLabel"));

            _trainedModel = trainingPipeline.Fit(trainingDataView);

            _predictionEngine = _mlContext.Model.CreatePredictionEngine <GitHubIssue, IssuePrediction>(_trainedModel);

            GitHubIssue issue = new GitHubIssue()
            {
                Title       = "WebSockets communication is slow in my machine",
                Description = "The WebSockets communication used under the covers by SignalR looks like is going slow in my development machine.."
            };

            var prediction = _predictionEngine.Predict(issue);

            Console.WriteLine($"Single Prediction just-trained-model - Result: {prediction.Area}");

            return(trainingPipeline);
        }