# How to predict the rating of a text review and improve it?

1. Why is it better to treat the rating prediction of a text review as a regression problem rather than a classification one? Is it because the ratings (1,2,3,4,5) are ordinal variables?

2. What kind of Naive Bayes algorithm is the most suitable for this problem? Is Multinomial Naive Bayes the best one? It is a classifier, so I am unsure if it can deal with the ordinal nature of the rating variable or not.

3. The conditional independence assumption does not hold for text data. Terms are conditionally dependent on each other. Which observations in the dataset will be primarily affected by this assumption? Those observations whose word/feature counts are the least (the most sparse ones)?

4. If we want to keep a single feature/word in our model, which one should we choose? Should we keep the feature with the maximum sum of its word counts?

5. Generally, is it accurate to say that neural networks are better than KNN models for predicting the ratings because the text datasets are usually sparse? Does the performance of these two regressors mainly differs for observations whose word/feature counts are the least (the most sparse ones)?

• I could be wrong, but you should ask a single question per question, not 5. Oct 23, 2022 at 18:04

Why is it better to treat the rating prediction of a text review as a regression problem rather than a classification one? Is it because the ratings (1,2,3,4,5) are ordinal variables?

Well, the main reason other than what you've referred to is that for rating, we can have scores like 4.7 that cannot be described with classification easily.

What kind of Naive Bayes algorithm is the most suitable for this problem? Is Multinomial Naive Bayes the best one? It is a classifier, so I am unsure if it can deal with the ordinal nature of the rating variable or not.

If I've understood you, you mean how to specify the order of the Markov chain. You have to note that Naive Bayes considers all words are independent. This is a very simple approach but can have good results in some situations. You can have a Markov chain of order 2 which means each of two consecutive words is dependent. You can have a Markov chain of higher orders, but you have to consider that the probability table will be sparse for higher orders, and you will not have a perfect result. Attention-based models can be used, and they have shown promising outcomes.

The conditional independence assumption does not hold for text data. Terms are conditionally dependent on each other. Which observations in the dataset will be primarily affected by this assumption? Those observations whose word/feature counts are the least (the most sparse ones)?

To be frank, I really do not know which will be affected. If you employ naive Bayes, this problem holds for all words. By the way, rare words are always important in tasks like information retrieval.

If we want to keep a single feature/word in our model, which one should we choose? Should we keep the feature with the maximum sum of its word counts?

I don't fully understand this, but it is dangerous in the sense that the word the usually has the most frequency, but it does not convey any special meaning.

Generally, is it accurate to say that neural networks are better than KNN models for predicting the ratings because the text datasets are usually sparse? Does the performance of these two regressors mainly differs for observations whose word/feature counts are the least (the most sparse ones)?

I can't say that. By the way, we have approaches like transfer learning for deep learning. KNN can have good results, but you have to obtain good features. On the other hand, the test phase can be time-consuming based on the frequency of your dataset. You have to note that word count is not the only statistics that can be obtained from a text. There are so many papers that consider for instance mutual info. By the way, you can use transformers with transfer learning that has shown astonishing performance.

• Thanks. The higher the TF-IDF score, the more important or relevant the term. I know how to compute TF_IDF in python. Is it true to calculate the sum of all columns/features individually and then select the maximum of those sums as the first best feature? Oct 24, 2022 at 6:00
• @ebrahimi about summing, I don't think it's a good idea due to the fact that you are not allowed to sum the age and height which are different features. At least, this is my opinion. About relevance, I do agree, but about the importance, I'm not sure we can use it for classification. For classification, the interaction between words is profoundly important. Oct 24, 2022 at 6:46