Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
314 views
in Technique[技术] by (71.8m points)

python - How can we use Pre-trained model to predict only one new_test_data on any model

Problem Statement :
Data consists of 10000 rows and 3 columns as "tweet","tweet_tokens","sentiment"
This data is from nltk.corpus import twitter_samples

Sample data how it looks like :
sample_dataframe

shape : (10000, 3)

Used model : MultibinomialNB to train and predict the dataset with CountVectorizer(ngram=(1,1)) and got the following scores :
Precision : 0.771 / Recall : 0.698 / Accuracy : 0.745

Features what it looks like in dataframe :
shape

Saving the model with pickle and predicting it for ONE tweet returns ERROR

Code for saving trained model and reusing it

ERROR for prediction for one tweet

Problem : Can we use this trained model to predict just one tweet and output as "Positive" or "Negative" ?? Tried using this model but ends up always as dimension mismatch or shape not aligned

Question : Do we always have to make new_test_data shape as of trained_data_set ??


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...