Click here to Skip to main content
15,903,203 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So I created this sentimental analysis program
--- Tutorial: Analyze website comments - binary classification - ML.NET | Microsoft Docs[^] ---


It works more or less pretty good , but it needs a lot more training so I wanted to implement a verification tactic in the "UseModelWithBatchItems" subroutine where I would literally just ask the user if the prediction was correct if yes it would copy the text into its training data and state it as 1(positive) and if it got it wrong it would do the same thing but state it as 0(negative) requesting an answer from he user is easy and i ca just do a if and else statement to check if the user inputted yes or no and outputting the text with the correct binary representative is easy but I'm not sure how to transfer the line of text over to the training data

What I have tried:

I am too scared to try , i have tried Filereader in c# before but have had bad experiences with it. so need help sorry if i sound dum. i was actually surprise i managed to get it working.
Posted
Updated 1-Aug-19 12:57pm
Comments
HamzaMcBob 1-Aug-19 17:52pm    
also on a side note when i literally insert the text and the binary representative i want in the training data and insert the exact same text into what i am testing sometimes it will work and sometimes it will and other times it will not work , for example i put in a sentence before(into the training data) with the result i wanted and it gave the the correct answer when running it but it could not do the same thing when i did it with another sentence



The woman is dead. 0 <---in training data , in test --->SentimentText = "The woman is dead. ,Negative
as expected
but when trying to do it with another sentnence it does not work.
ps i used that specific senentence because of the program i am trying to create.
Patrice T 1-Aug-19 18:02pm    
Use Improve question to update your question.
So that everyone can pay attention to this information.
Patrice T 1-Aug-19 18:03pm    
Try to show your actual code.
Afzaal Ahmad Zeeshan 1-Aug-19 18:57pm    
He is following the guide that Microsoft has provided on the link he referred to.

1 solution

Quote:
but it needs a lot more training
That is machine learning 101 for you right there.
Quote:
I would literally just ask the user if the prediction was correct
This does work, and will work just fine. In most production environment this is not ideal scenario as it can lead to so many serious problems. One of the such things is, think of what will happen is the user can input some data and train your model into thinking something that should be wrong. Like, what if the user will enter, "this is a good day", and he labels it as "positive (1)"? Same for other scenarios... Now, in machine learning, if your model has enough data about a particular scenario it would lead to incorrect predictions and would lead to having your data corrupted. Thus, no input goes to the training sets without sanitization.
Quote:
how to transfer the line of text over to the training data
You will use the same training data set that you were using earlier. That file, which Microsoft provided was a zip file, I am not sure what type of file was in it, but you need to modify that file.

Here are the steps:

  1. Take input from the user—how much longer you need to take, like statements, labels, etc.
  2. Add this input to the end of the file—most probably use File.AppendAllText(string, string) function.
  3. Once file has the data, restart the training.
Machine learning, and the entire programming domain is about 3 words, try, and try again.
 
Share this answer
 
Comments
HamzaMcBob 2-Aug-19 13:21pm    
The File.AppendAllText functionality is not working , the name of the file it is to be saved in is called "yelp_labelled txt" (the training data) and when I try and do


string appendText = prediction.SentimentText + prediction.Prediction;
File.AppendAllText(yelp_labelled.txt, appendText);
it comes up with the error yelp_labelled does not exist in the current context
I shoudnt have to state it at the beginning of the subroutine should I??

Iv also tried streamwriter and that also gave the same error
Afzaal Ahmad Zeeshan 2-Aug-19 14:16pm    
Indeed, because you need to pass a string which is the path of the file. That has to be something like, "C:\Somewhere\Folder\yeld_labelled.txt". But you are passing a name, which C# will consider as a variable.

StreamWriters, etc. are not necessary in this case.

See more on the error, here.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900