public Task <TwitAnalyzerResult> Analyze(Twit twit) { var probability = GetPrediction(Entry.FromString(twit.Text)); return(Task.FromResult( new TwitAnalyzerResult { Algorithm = "bayes", TwitAnalysisResult = new TwitAnalysisResult { CategorizationResult = TwitAnalysisResult.Categorize(probability), PositiveProbability = probability, Text = twit.Text, TimestampUtc = DateTime.UtcNow } })); }
public Task <TwitAnalyzerResult> Analyze(Twit twit) { var predictionFunction = _mlContext.Model.CreatePredictionEngine <SentimentData, SentimentPrediction>(_model); var sampleStatement = new SentimentData { Text = twit.Text }; var prediction = predictionFunction.Predict(sampleStatement); return(Task.FromResult( new TwitAnalyzerResult { Algorithm = _estimationAlgorithm, TwitAnalysisResult = new TwitAnalysisResult { CategorizationResult = TwitAnalysisResult.Categorize(prediction.Probability), PositiveProbability = prediction.Probability, Text = twit.Text, TimestampUtc = DateTime.UtcNow } })); }