【发布时间】:2021-03-16 02:02:25
【问题描述】:
建立模型后,我现在想用新数据检查结果。 我用过以下
count_vectorizer = CountVectorizer()
X_train= np.asarray(X_train)
y_train= np.asarray(y_train)
X_test = np.asarray(X_test)
score_log = clf.fit(X_train, y_train).predict(['Hello World'])
使用逻辑回归模型。
不幸的是我得到了
ValueError: Expected 2D array, got 1D array instead:
array=['Hello World'].
Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.
当我尝试使用时
top=['Hello World'].reshape(-1,1)
和['Hello World'].to_numpy().reshape(-1,1)
我遇到了这个新错误:
AttributeError: 'list' object has no attribute 'reshape'
您能解释一下如何检查模型中的新句子吗?
【问题讨论】:
标签: python numpy scikit-learn logistic-regression