예제 #1
0
        public static IEstimator <ITransformer> BuildAndTrainModel(IDataView trainingDataView, IEstimator <ITransformer> pipeline)
        {
            Console.WriteLine("hello0");
            var trainingPipeline = pipeline.Append(_mlContext.MulticlassClassification.Trainers.SdcaMaximumEntropy("Label", "Features"))
                                   .Append(_mlContext.Transforms.Conversion.MapKeyToValue("PredictedLabel"));

            Console.WriteLine("hello1");
            _trainedModel = trainingPipeline.Fit(trainingDataView);

            Console.WriteLine("hello2");
            _predEngine = _mlContext.Model.CreatePredictionEngine <GitHubIssue, IssuePrediction>(_trainedModel);

            Console.WriteLine("hello3");
            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.."
            };

            Console.WriteLine("hello04");
            var prediction = _predEngine.Predict(issue);

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

            Console.WriteLine("hello6");
            return(trainingPipeline);
        }
예제 #2
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"
            };

            _predEngine = _mlContext.Model.CreatePredictionEngine <GitHubIssue, IssuePrediction>(loadedModel);
            var prediction = _predEngine.Predict(singleIssue);

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