-1

I have a project to measure the sentiment level of a customer as 0 (happy), 1 (neutral), 2(unhappy) from the text data supplied by customer comments. I have trained a classifier model on tensorflow and it predicts the sentiment level of a new document. There is no problem until that point. I can get prediction probabilities of classifier indicates a new document belongs to which level. After prediction of a new document belongs to which class I get some probalities like below:

Level - Propability

0 (happy) ---> 0.17

1 (neutral) ---> 0.41

2 (unhappy) ---> 0.42

This result indicates that predicted document belongs to class 2. However, I need precise sentiment scores not just labels. If I divide interval [0-1] into 3 parts each corresponds to a label like [0-0.33],[0.33-0.66],[0.66-1]. For above case I need a score between 0.66 and 1 and also is shold be closer to 0.66 something like 0.68.

As other examples showed below:

EX-I:

Level - Propability

0:[0-0.33] --> 0

1:[0.33-0.66] --> 1

2:[0.66-1] --> 0

For EX-I score should be 0.5

. .

EX-II:

Level - Propability

0:[0-0.33] --> 0.51

1:[0.33-0.66] --> 0.49

2:[0.66-1] --> 0

For EX-II score should be less than 0.33 but so close to it.

What is the exact terminology for this case in math or is there an equation to calculate the current fuzzy score from probabilities.

Thanks for your help.

1 Answers1

0

Instead of doing classification, you should turn to regression.

During your training step, you may convert class happy to 0, class neutral to 0.5 and unhappy to 1. Then, your tensorflow model will predict values between 0 and 1 that correspond to what you want to do.

Joseph Budin
  • 1,299
  • 1
  • 11
  • 28
  • I am not sure I can change the class label as a decimal number 0.5. Manipulating class labels as 0,1,2 or 0,0,5,1 does it matter ? I use the model.predict_proba() function of tensorflow and it just gives the predicted propabilities for each class. – Ahmet Bardız Jan 07 '18 at 07:48
  • It's the simplest way I can see, but you'll have to change a tiny bit your model because it will need to be a regression model. – Joseph Budin Jan 07 '18 at 10:13