from textblob import TextBlob
from sklearn.model_selection import cross_val_score
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.naive_bayes import MultinomialNB
from sklearn.pipeline import make_pipeline
from sklearn.datasets import fetch_20newsgroups
categories = ['alt.atheism', 'comp.graphics', 'sci.med', 'soc.religion.christian']
data = fetch_20newsgroups(categories=categories)
X = data.data
y = data.target
model = make_pipeline(CountVectorizer(), MultinomialNB())
scores = cross_val_score(model, X, y, cv=5, scoring='accuracy')
print("Cross-validation scores: ", scores)
print("Average score: ", scores.mean())
这样,你就可以使用TextBlob进行交叉验证了。