Hello,
I am trying to use Python (or if you could recommend a better tool) to determine if a review is "negative" or "positive". I have tried the Naive Bayes classifier tool but it needs at least 2 fields to train the model. If there is a way to truly get the model to learn text classification (NLP), that would be very helpful! I've attached a training set labeling if a review is negative or positive, and a test set that would see if the model could determine if it was "negative" or "positive".
Training set:
Test set (desired outcome is the review type being predicted):
Solved! Go to Solution.
Hi @vujennyfer
I made the workflow for you.
Python code is as follows.
from sklearn.naive_bayes import MultinomialNB
from sklearn.feature_extraction.text import CountVectorizer
#Read from AlteryxData
df = Alteryx.read("#1")
dfp = Alteryx.read("#2")
#Make Model
clf = MultinomialNB()
vec = CountVectorizer(min_df=1)
X = vec.fit_transform(df['review'])
clf.fit(X, df['review_type'])
#Predict
X_p = vec.transform(dfp['review'])
predicted = clf.predict(X_p)
# Output the list of files as dataframe
dfp['review_type_predicted'] = predicted
Alteryx.write(dfp,1)
Result:
Hi @vujennyfer ,
Have you tried exploring the Sentiment Analysis tool under the Alteryx Intelligence Suite kit? Here’s a nice guide on how to use the tool in a code-free manner: https://community.alteryx.com/t5/Data-Science/Try-Sentiment-Analysis-with-Designer-You-Must/ba-p/589...
The tool uses the open-source VADER package. Hope this helps!
Best,
Michael
Thank you SO MUCH @AkimasaKajitani! This worked!! 🙂
Hi @mutama, I've tried to download it but unfortunately it comes at an additional cost.
@vujennyferGlad your issue was sorted out! I'm just here to let you know about a new tool called Jupyter Flow. It will allow you to create cool notebooks like the one @AkimasaKajitani helped you fix, but you'll also be able to share the workflow and run it on Alteryx Server. Enjoy solving!
It looks like the OP is asking about a supervised model, but Alteryx rep responded with an unsupervised model solution using Intelligence Suite. Does Intel Suite offer the ability to do supervised learning (ie, classification models with text inputs using TF-IDF)?