示例#1
0
        private static LabelSuggestion Predict <T>(
            T issueOrPr,
            PredictionEngine <T, GitHubIssuePrediction> predEngine,
            ILogger logger)
            where T : IssueModel
        {
            if (predEngine == null)
            {
                throw new InvalidOperationException("expected prediction engine loaded.");
            }

            GitHubIssuePrediction prediction = predEngine.Predict(issueOrPr);

            VBuffer <ReadOnlyMemory <char> > slotNames = default;

            predEngine.OutputSchema[nameof(GitHubIssuePrediction.Score)].GetSlotNames(ref slotNames);

            float[] probabilities    = prediction.Score;
            var     labelPredictions = MikLabelerPredictor.GetBestThreePredictions(probabilities, slotNames);

            float maxProbability = probabilities.Max();

            logger.LogInformation($"# {maxProbability} {prediction.Area} for #{issueOrPr.Number} {issueOrPr.Title}");
            return(new LabelSuggestion
            {
                LabelScores = labelPredictions,
            });
        }
示例#2
0
文件: Predictor.cs 项目: wli3/arcade
        public static async Task <string> PredictAsync(GitHubIssue issue, ILogger logger, double threshold)
        {
            PredictionModel <GitHubIssue, GitHubIssuePrediction> model = await PredictionModel.ReadAsync <GitHubIssue, GitHubIssuePrediction>(ModelPath);

            GitHubIssuePrediction prediction = model.Predict(issue);

            float[] probabilities  = prediction.Probabilities;
            float   maxProbability = probabilities.Max();

            logger.LogInformation($"# {maxProbability.ToString()} {prediction.Area} for #{issue.ID} {issue.Title}");
            return(maxProbability > threshold ? prediction.Area : null);
        }
示例#3
0
        public static async Task <string> PredictAsync(GitHubIssue issue, ILogger logger)
        {
            PredictionModel <GitHubIssue, GitHubIssuePrediction> model = await PredictionModel.ReadAsync <GitHubIssue, GitHubIssuePrediction>(ModelPath);

            GitHubIssuePrediction prediction = model.Predict(issue);

            float[] probabilities  = prediction.Probabilities;
            float   maxProbability = probabilities.Max();

            logger.LogInformation($"Label {prediction.Area} for {issue.ID} is predicted with confidence {maxProbability.ToString()}");

            return(maxProbability > 0.8 ? prediction.Area : null);
        }
示例#4
0
        public static string Predict(GitHubIssue issue, ILogger logger, double threshold)
        {
            if (predEngine == null)
            {
                MLContext    mlContext = new MLContext();
                ITransformer mlModel   = mlContext.Model.Load(ModelPath, out DataViewSchema inputSchema);
                predEngine = mlContext.Model.CreatePredictionEngine <GitHubIssue, GitHubIssuePrediction>(mlModel);
            }

            GitHubIssuePrediction prediction = predEngine.Predict(issue);

            float[] probabilities  = prediction.Score;
            float   maxProbability = probabilities.Max();

            logger.LogInformation($"# {maxProbability.ToString()} {prediction.Area} for #{issue.Number} {issue.Title}");
            return(maxProbability > threshold ? prediction.Area : null);
        }
示例#5
0
        public static string Predict <T>(T issueOrPr, ref PredictionEngine <T, GitHubIssuePrediction> predEngine, ILogger logger, double threshold)
            where T : IssueModel
        {
            if (predEngine == null)
            {
                MLContext    mlContext = new MLContext();
                ITransformer mlModel   = mlContext.Model.Load(PrModelPath, out DataViewSchema inputSchema);
                predEngine = mlContext.Model.CreatePredictionEngine <T, GitHubIssuePrediction>(mlModel);
            }

            GitHubIssuePrediction prediction = predEngine.Predict(issueOrPr);

            float[] probabilities  = prediction.Score;
            float   maxProbability = probabilities.Max();
            string  typeToPredict  = issueOrPr is IssueModel ? "issue" : "PR";

            logger.LogInformation($"# {maxProbability} {prediction.Area} for {typeToPredict} #{issueOrPr.Number} {issueOrPr.Title}");
            return(maxProbability > threshold ? prediction.Area : null);
        }