擅长:python、mysql、java
<p>我也遇到了同样的问题,并通过根据训练数据的形状调整单个字符串数据的大小来解决</p>
<p>完整代码:</p>
<pre><code>joblib.dump(clf, "model.pkl")
classifer = joblib.load("model.pkl")
textFeature = "Dengue soaring in ......"
vocabulary=pre_process(textFeature)
vocabulary_df =pd.Series(vocabulary)
#### Feature extraction using Tfidf Vectorizer
from sklearn.feature_extraction.text import TfidfVectorizer
vectorizer = TfidfVectorizer(stop_words='english')
test_ = vectorizer.fit_transform(vocabulary_df.values)
test_.resize(1, features_train.shape[1])
classifer.predict(test_)
</code></pre>