protected override async Task OnMessageActivityAsync(ITurnContext <IMessageActivity> turnContext, CancellationToken cancellationToken) { // Add input data var input = new ModelInput() { SentimentText = turnContext.Activity.Text }; // Load model and predict output of sample data ModelOutput result = ConsumeModel.Predict(input); var replyText = result.Prediction ? "Toxic" : "Non-Toxic"; await turnContext.SendActivityAsync(MessageFactory.Text(replyText, replyText), cancellationToken); }
static void Main(string[] args) { Console.WriteLine("Sentiment Prediction"); Console.WriteLine("Insert your text to evaluate..."); // Add input data var input = new ModelInput(); input.SentimentText = Console.ReadLine(); // Load model and predict output of sample data ModelOutput result = ConsumeModel.Predict(input); Console.WriteLine("The result was a " + (!result.Prediction ? "Good" : "Bad") + " Sentiment"); Console.ReadLine(); }
static void Main(string[] args) { // Add input data var input = new ModelInput() { Col0 = "This restaurant was wonderful." }; // Load model and predict output of sample data ModelOutput result = ConsumeModel.Predict(input); // If Prediction is 1, sentiment is "Positive"; otherwise, sentiment is "Negative" string sentiment = result.Prediction == "1" ? "Positive" : "Negative"; Console.WriteLine($"Text: {input.Col0}\nSentiment: {sentiment}"); }
static void Main(string[] args) { // Create single instance of sample data from first line of dataset for model input ModelInput sampleData = CreateSingleDataSample(DATA_FILEPATH); // Make a single prediction on the sample data and print results ModelOutput predictionResult = ConsumeModel.Predict(sampleData); Console.WriteLine("Using model to make single prediction -- Comparing actual IsPositive with predicted IsPositive from sample data...\n\n"); Console.WriteLine($"word: {sampleData.Word}"); Console.WriteLine($"isNegative: {sampleData.IsNegative}"); Console.WriteLine($"\n\nActual IsPositive: {sampleData.IsPositive} \nPredicted IsPositive: {predictionResult.Prediction}\n\n"); Console.WriteLine("=============== End of process, hit any key to finish ==============="); Console.ReadKey(); }
static void Main(string[] args) { Debug.WriteLine(" Object is not valid for this category."); // Add input data var input = new ModelInput(); input.ImageSource = @"C:\Users\racha\Downloads\Machine Learning\images\Auto\Auto1.jpg"; // Load model and predict output of sample data ModelOutput result = ConsumeModel.Predict(input); Debug.WriteLine(result.Prediction); Console.WriteLine(result.Prediction); }
static void Main(string[] args) { string text; do { var input = new ModelInput(); text = Console.ReadLine(); input.SentimentText = text; // Load model and predict output of sample data ModelOutput result = ConsumeModel.Predict(input); Console.WriteLine($"Text: {input.SentimentText}\nIs Toxic: {result.Prediction}"); }while (text != "q"); }
static void Main(string[] args) { // Create single instance of sample data from first line of dataset for model input ModelInput sampleData = CreateSingleDataSample(DATA_FILEPATH); // Make a single prediction on the sample data and print results ModelOutput predictionResult = ConsumeModel.Predict(sampleData); Console.WriteLine("Using model to make single prediction -- Comparing actual Open with predicted Open from sample data...\n\n"); Console.WriteLine($"timestamp: {sampleData.Timestamp}"); Console.WriteLine($"polarity: {sampleData.Polarity}"); Console.WriteLine($"\n\nActual Open: {sampleData.Open} \nPredicted Open: {predictionResult.Score}\n\n"); Console.WriteLine("=============== End of process, hit any key to finish ==============="); Console.ReadKey(); }
public async Task <IActionResult> Create(string postId, string parentId, string content) { var mi = new ModelInput(); mi.SentimentText = content; var a = ConsumeModel.Predict(mi); bool isRude = a.Prediction == "1"; var posterId = this.userManager.GetUserId(this.User); await this.commentsService.CreateComment(posterId, parentId, postId, content, isRude); return(this.RedirectToAction("ById", "JobPosts", new { id = postId })); }
public override void FillSentiment() { int totalSentiment = 0; ModelOutput result; var input = new ModelInput(); foreach (string line in _article.Text) { input.Comment = line; result = ConsumeModel.Predict(input); totalSentiment += result.Prediction ? 1 : 0; } _article.Sentiment = totalSentiment / _article.Text.Count; }
static void Main(string[] args) { // Add input data var input = new ModelInput(); Console.Write("Enter Distance: "); input.Trip_distance = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter Time: "); input.Trip_time_in_secs = Convert.ToInt32(Console.ReadLine()); // Load model and predict output of sample data ModelOutput result = ConsumeModel.Predict(input); Console.WriteLine("The estimated fare is: " + result.Score); }
static void Main(string[] args) { // Add input data var input = new ModelInput(); input.Comment = "This is heaven"; // Load model and predict output of sample data string path = @"../SampleClassification/SampleClassification.Model/MLModel.zip"; ConsumeModel.MLNetModelPath = Path.GetFullPath(path); ModelOutput result = ConsumeModel.Predict(input); Console.WriteLine($"Text: {input.Comment}\nIs Toxic: {result.Prediction}"); }
public void Comment(string commnet) { // Add input data var input = new ModelInput() { Col0 = commnet }; // Load model and predict output of sample data ModelOutput result = ConsumeModel.Predict(input); // If Prediction is 1, sentiment is "Positive"; otherwise, sentiment is "Negative" string sentiment = result.Prediction == "1" ? "Positive" : "Negative"; Console.WriteLine($"Thank you For Your {sentiment} Comment"); }
static void Main(string[] args) { // Create single instance of sample data from first line of dataset for model input ModelInput sampleData = CreateSingleDataSample(DATA_FILEPATH); // Make a single prediction on the sample data and print results ModelOutput predictionResult = ConsumeModel.Predict(sampleData); Console.WriteLine("Using model to make single prediction -- Comparing actual Product_category with predicted Product_category from sample data...\n\n"); Console.WriteLine($"birth_year: {sampleData.Birth_year}"); Console.WriteLine($"user_gender: {sampleData.User_gender}"); Console.WriteLine($"\n\nActual Product_category: {sampleData.Product_category} \nPredicted Product_category value {predictionResult.Prediction} \nPredicted Product_category scores: [{String.Join(",", predictionResult.Score)}]\n\n"); Console.WriteLine("=============== End of process, hit any key to finish ==============="); Console.ReadKey(); }
static void Main(string[] args) { //This line is for creating model //ModelBuilder.CreateModel(); ModelInput input = new ModelInput() { Date = DateTime.Now, WeightedPrice = 18245.52f }; var result = ConsumeModel.Predict(input, horizon: 3); Console.WriteLine($"Predicted Bitcoin actual price for is {result.ForecastedPrice[0]:#$}"); Console.WriteLine($"Predicted Bitcoin lowerbound price for is {result.LowerBoundPrice[0]:#$}"); Console.WriteLine($"Predicted Bitcoin upperbound price for is {result.UpperBoundPrice[0]:#$}"); }
static void Main(string[] args) { // Create single instance of sample data from first line of dataset for model input ModelInput sampleData = CreateSingleDataSample(DATA_FILEPATH); // Make a single prediction on the sample data and print results ModelOutput predictionResult = ConsumeModel.Predict(sampleData); Console.WriteLine("Using model to make single prediction -- Comparing actual DirectionChanged_ with predicted DirectionChanged_ from sample data...\n\n"); Console.WriteLine($"previousHit: {sampleData.PreviousHit}"); Console.WriteLine($"newHit: {sampleData.NewHit}"); Console.WriteLine($"\n\nActual DirectionChanged_: {sampleData.DirectionChanged_} \nPredicted DirectionChanged_: {predictionResult.Prediction}\n\n"); Console.WriteLine("=============== End of process, hit any key to finish ==============="); Console.ReadKey(); }
public async Task <IActionResult> AjaxComment(int ProjectId, string theComment) { //Find User Id var _userId = _userManager.GetUserId(User); var ProjectValidation = await _context.Projectdb.FindAsync(ProjectId); var UserValidation = await _context.appUserdb.FindAsync(_userId); //if user or project dosent exist at the database if (UserValidation == null || ProjectValidation == null) { return(NotFound()); } Comment comment = new Comment { project = await _context.Projectdb.FindAsync(ProjectId), owner = await _context.appUserdb.FindAsync(_userId), OwnerId = _userId, theComment = theComment, dateSubmit = DateTime.Now }; var input = new ModelInput(); input.Comment = theComment; ModelOutput result = ConsumeModel.Predict(input); if (result.Prediction) { comment.RudeComment = true; } else { comment.RudeComment = false; } //If The Comments State Is Not Vaild. if (!ModelState.IsValid) { return(View(comment)); } Project project = comment.project; project.comments.Add(comment); _context.Add(comment); //_context.Add(project); await _context.SaveChangesAsync(); return(Json("OK!")); }
static void Main(string[] args) { // Add input data var input = new ModelInput(); while (true) { Console.Write("Enter line # in data file (ENTER to quit): "); int lineNumber; var success = int.TryParse(Console.ReadLine(), out lineNumber); if (!success) { break; } var dataPath = @"C:\GitHub\Misc-csharp\MLPricePrediction\taxi-fare-train.txt"; string line = ""; using (var f = new StreamReader(dataPath)) { for (int i = 0; i < lineNumber; ++i) { line = f.ReadLine(); } } var items = line.Split(','); input.Vendor_id = items[0]; input.Rate_code = int.Parse(items[1]); input.Passenger_count = int.Parse(items[2]); input.Trip_time_in_secs = int.Parse(items[3]); input.Trip_distance = float.Parse(items[4]); input.Payment_type = items[5]; /*input.Vendor_id = "CMT"; // CMT, VTS * input.Rate_code = 1; * input.Passenger_count = 1; * input.Trip_time_in_secs = 386; * input.Trip_distance = 1.3f; * input.Payment_type = "CRD"; // CSH, CRD*/ // Load model and predict output of sample data ModelOutput result = ConsumeModel.Predict(input); Console.WriteLine($"Vendor:{input.Vendor_id} RateCode:{input.Rate_code} Passengers:{input.Passenger_count} TripTime:{input.Trip_time_in_secs} Distance:{input.Trip_distance} PaymentType:{input.Payment_type}"); Console.WriteLine($"Fare: {result.Score:N2}\n"); } }
static void Main(string[] args) { // Create single instance of sample data from first line of dataset for model input ModelInput sampleData = CreateSingleDataSample(DATA_FILEPATH); // Make a single prediction on the sample data and print results var predictionResult = ConsumeModel.Predict(sampleData); Console.WriteLine("Using model to make single prediction -- Comparing actual PARSEME_MWE with predicted PARSEME_MWE from sample data...\n\n"); Console.WriteLine($"FORMm3: {sampleData.FORMm3}"); Console.WriteLine($"LEMMAm3: {sampleData.LEMMAm3}"); Console.WriteLine($"UPOSm3: {sampleData.UPOSm3}"); Console.WriteLine($"HEADm3: {sampleData.HEADm3}"); Console.WriteLine($"DEPRELm3: {sampleData.DEPRELm3}"); Console.WriteLine($"FORMm2: {sampleData.FORMm2}"); Console.WriteLine($"LEMMAm2: {sampleData.LEMMAm2}"); Console.WriteLine($"UPOSm2: {sampleData.UPOSm2}"); Console.WriteLine($"HEADm2: {sampleData.HEADm2}"); Console.WriteLine($"DEPRELm2: {sampleData.DEPRELm2}"); Console.WriteLine($"FORMm1: {sampleData.FORMm1}"); Console.WriteLine($"LEMMAm1: {sampleData.LEMMAm1}"); Console.WriteLine($"UPOSm1: {sampleData.UPOSm1}"); Console.WriteLine($"HEADm1: {sampleData.HEADm1}"); Console.WriteLine($"DEPRELm1: {sampleData.DEPRELm1}"); Console.WriteLine($"FORM0: {sampleData.FORM0}"); Console.WriteLine($"LEMMA0: {sampleData.LEMMA0}"); Console.WriteLine($"UPOS0: {sampleData.UPOS0}"); Console.WriteLine($"HEAD0: {sampleData.HEAD0}"); Console.WriteLine($"DEPREL0: {sampleData.DEPREL0}"); Console.WriteLine($"FORMp1: {sampleData.FORMp1}"); Console.WriteLine($"LEMMAp1: {sampleData.LEMMAp1}"); Console.WriteLine($"UPOSp1: {sampleData.UPOSp1}"); Console.WriteLine($"HEADp1: {sampleData.HEADp1}"); Console.WriteLine($"DEPRELp1: {sampleData.DEPRELp1}"); Console.WriteLine($"FORMp2: {sampleData.FORMp2}"); Console.WriteLine($"LEMMAp2: {sampleData.LEMMAp2}"); Console.WriteLine($"UPOSp2: {sampleData.UPOSp2}"); Console.WriteLine($"HEADp2: {sampleData.HEADp2}"); Console.WriteLine($"DEPRELp2: {sampleData.DEPRELp2}"); Console.WriteLine($"FORMp3: {sampleData.FORMp3}"); Console.WriteLine($"LEMMAp3: {sampleData.LEMMAp3}"); Console.WriteLine($"UPOSp3: {sampleData.UPOSp3}"); Console.WriteLine($"HEADp3: {sampleData.HEADp3}"); Console.WriteLine($"DEPRELp3: {sampleData.DEPRELp3}"); Console.WriteLine($"\n\nActual PARSEME_MWE: {sampleData.PARSEME_MWE} \nPredicted PARSEME_MWE value {predictionResult.Prediction} \nPredicted PARSEME_MWE scores: [{String.Join(",", predictionResult.Score)}]\n\n"); Console.WriteLine("=============== End of process, hit any key to finish ==============="); Console.ReadKey(); }
public async Task <SendCommentDTO> Handle(Command request, CancellationToken cancellationToken) { var sender = await dataContext.Users.FirstOrDefaultAsync(x => x.Id == currentUser.UserId); if (sender is null) { throw new HttpContextException(HttpStatusCode.NotFound, new { User = "******" }); } var advertise = await dataContext.Advertise.Where(x => x.UniqueId == request.AdvertiseId) .FirstOrDefaultAsync(); ModelInput sampleData = new ModelInput() { Comment = request.Comment, }; // Make a single prediction on the sample data and print results var predictionResult = ConsumeModel.Predict(sampleData); var userComment = new UserComments { Advertise = advertise, Commenter = sender, CommentedAt = DateTime.UtcNow, Comment = request.Comment, PositiveAccuracy = predictionResult.Score[0], NegativeAccuracy = predictionResult.Score[1] }; await dataContext.UserComments.AddAsync(userComment); var success = await dataContext.SaveChangesAsync() > 0; if (success) { return(new SendCommentDTO { Comment = userComment.Comment, CommentedAt = userComment.CommentedAt, DisplayName = $"{userComment.Commenter.FirstName} {userComment.Commenter.LastName}" }); } else { throw new Exception("ERROR WHILE SENDING Comment"); } }
static void Main(string[] args) { // Modelimizi eğittik. Artık ona örnek yorumlar yollayıp bunun zararlı olup olmadığını tahmin etmesini isteyebiliriz. var input = new ModelInput(); input.SentimentText = "It was a very disgusting article, man."; // Tahminlemeyi yaptırıyoruz ModelOutput result = ConsumeModel.Predict(input); Console.WriteLine($"Girilen Yorum: '{input.SentimentText}'\nZehirli mi?: {result.Prediction}"); input.SentimentText = "Great narration. I took great advantage. Thank you."; result = ConsumeModel.Predict(input); Console.WriteLine($"Girilen Yorum: '{input.SentimentText}'\nZehirli mi?: {result.Prediction}"); }
static void Main(string[] args) { // Create single instance of sample data from first line of dataset for model input ModelInput sampleData = CreateSingleDataSample(DATA_FILEPATH); // Make a single prediction on the sample data and print results ModelOutput predictionResult = ConsumeModel.Predict(sampleData); Console.WriteLine("Using model to make single prediction -- Comparing actual Area with predicted Area from sample data...\n\n"); Console.WriteLine($"ID: {sampleData.ID}"); Console.WriteLine($"Title: {sampleData.Title}"); Console.WriteLine($"Description: {sampleData.Description}"); Console.WriteLine($"\n\nActual Area: {sampleData.Area} \nPredicted Area value {predictionResult.Prediction} \nPredicted Area scores: [{String.Join(",", predictionResult.Score)}]\n\n"); Console.WriteLine("=============== End of process, hit any key to finish ==============="); Console.ReadKey(); }
static void Main(string[] args) { // Add input data var input = new ModelInput(); input.Passenger_count = 1f; input.Payment_type = "CRD"; input.Trip_distance = 5.3f; input.Trip_time_in_secs = 850; input.Vendor_id = "CMT"; // Load model and predict output of sample data ModelOutput result = ConsumeModel.Predict(input); Console.WriteLine($"The predicted fare is: {result.Score}"); }
protected override async Task OnMessageActivityAsync(ITurnContext <IMessageActivity> turnContext, CancellationToken cancellationToken) { // Create single instance of sample data from first line of dataset for model input ModelInput sampleData = new ModelInput() { Sentiment_Text = turnContext.Activity.Text, }; // Make a single prediction on the sample data and print results var predictionResult = ConsumeModel.Predict(sampleData); var replyText = $"Echo: {turnContext.Activity.Text}"; await turnContext.SendActivityAsync(MessageFactory.Text(replyText, replyText), cancellationToken); await turnContext.SendActivityAsync($"You are {predictionResult.Prediction}", null, null, cancellationToken); }
static void Main(string[] args) { Console.WriteLine("Leave a Comment,Please :"); string Coment; Coment = Console.ReadLine();//Get a comment from the user. var input = new ModelInput(); input.SentimentText = Coment;//Give the comment left as input // Load model and predict output from the comment left ModelOutput result = ConsumeModel.Predict(input); Console.WriteLine($"Text: {input.SentimentText}\nIs Toxic: {result.Prediction}\n"); }
static void Main(string[] args) { List <ModelInput> sampleData = CreateSingleDataSample(DATA_FILEPATH); foreach (var data in sampleData) { var predictionResult = ConsumeModel.Predict(data); Console.WriteLine("================================================================================================"); Console.WriteLine($"Title: {data.Title}"); //Console.WriteLine($"Author: {data.Author}"); //Console.WriteLine($"Description: {data.Description}"); //Console.WriteLine($"NumberOfViews: {data.NumberOfViews}"); Console.WriteLine($"Actual Like: {data.Like} \nPredicted Like: {predictionResult.Prediction}"); } }
static void Main(string[] args) { // Add input data var input = new ModelInput { Passenger_count = 2, Trip_distance = 4, Trip_time_in_secs = 1150, Payment_type = "CRD" }; // Load model and predict output of sample data ModelOutput result = ConsumeModel.Predict(input); Console.WriteLine($"Predicted fare: ${result.Score}"); }
static void Main(string[] args) { Console.WriteLine("AI Prediction of age of vin numbers"); Console.WriteLine("Training data: 10,000 rows spanish data"); // Add input data var input = new ModelInput(); Console.WriteLine("Please enter a VIN:"); input.VIN = Console.ReadLine(); // Load model and predict output of sample data ModelOutput result = ConsumeModel.Predict(input); Console.WriteLine("The year is predicted to be: " + result.Prediction); Console.ReadLine(); }
static void Main(string[] args) { // Create single instance of sample data from first line of dataset for model input ModelInput sampleData = new ModelInput() { Col1 = 13868.85F, Col2 = 11063.38F, Col3 = 5452.781F, Col4 = 3019.123F, Col5 = 2338.009F, Col6 = 894.0856F, Col7 = 479.2575F, Col8 = 358.4319F, Col9 = 283.7598F, Col10 = 253.8049F, Col11 = 256.5529F, Col12 = 257.3511F, Col13 = 268.1667F, Col14 = 288.2473F, Col15 = 289.4342F, Col16 = 0F, }; // Make a single prediction on the sample data and print results var predictionResult = ConsumeModel.Predict(sampleData); Console.WriteLine("Using model to make single prediction -- Comparing actual Col0 with predicted Col0 from sample data...\n\n"); Console.WriteLine($"Col1: {sampleData.Col1}"); Console.WriteLine($"Col2: {sampleData.Col2}"); Console.WriteLine($"Col3: {sampleData.Col3}"); Console.WriteLine($"Col4: {sampleData.Col4}"); Console.WriteLine($"Col5: {sampleData.Col5}"); Console.WriteLine($"Col6: {sampleData.Col6}"); Console.WriteLine($"Col7: {sampleData.Col7}"); Console.WriteLine($"Col8: {sampleData.Col8}"); Console.WriteLine($"Col9: {sampleData.Col9}"); Console.WriteLine($"Col10: {sampleData.Col10}"); Console.WriteLine($"Col11: {sampleData.Col11}"); Console.WriteLine($"Col12: {sampleData.Col12}"); Console.WriteLine($"Col13: {sampleData.Col13}"); Console.WriteLine($"Col14: {sampleData.Col14}"); Console.WriteLine($"Col15: {sampleData.Col15}"); Console.WriteLine($"Col16: {sampleData.Col16}"); Console.WriteLine($"\n\nPredicted Col0 value {predictionResult.Prediction} \nPredicted Col0 scores: [{String.Join(",", predictionResult.Score)}]\n\n"); Console.WriteLine("=============== End of process, hit any key to finish ==============="); Console.ReadKey(); }
static void Main(string[] args) { // Create single instance of sample data from first line of dataset for model input ModelInput sampleData = new ModelInput() { Listed_in = @"International TV Shows, TV Dramas, TV Sci-Fi & Fantasy", }; // Make a single prediction on the sample data and print results var predictionResult = ConsumeModel.Predict(sampleData); Console.WriteLine("Using model to make single prediction -- Comparing actual Type with predicted Type from sample data...\n\n"); Console.WriteLine($"Listed_in: {sampleData.Listed_in}"); Console.WriteLine($"\n\nPredicted Type value {predictionResult.Prediction} \nPredicted Type scores: [{String.Join(",", predictionResult.Score)}]\n\n"); Console.WriteLine("=============== End of process, hit any key to finish ==============="); Console.ReadKey(); }
static void Main(string[] args) { // Create single instance of sample data from first line of dataset for model input ModelInput sampleData = new ModelInput() { Col0 = @"Wow... Loved this place.", }; // Make a single prediction on the sample data and print results var predictionResult = ConsumeModel.Predict(sampleData); Console.WriteLine("Using model to make single prediction -- Comparing actual Col1 with predicted Col1 from sample data...\n\n"); Console.WriteLine($"Col0: {sampleData.Col0}"); Console.WriteLine($"\n\nPredicted Col1 value {predictionResult.Prediction} \nPredicted Col1 scores: [{String.Join(",", predictionResult.Score)}]\n\n"); Console.WriteLine("=============== End of process, hit any key to finish ==============="); Console.ReadKey(); }