我被困在这里。我正在使用sklearn.LinearSVR
,但是即使我的所有尺寸都匹配,也会出现形状未对齐错误。
如果需要,我将发布数据集,但是我不确定如何将其上传到堆栈溢出
以下是我的代码:
from sklearn.svm import LinearSVR
Y_train = enc_Y[: index].flatten() <-- .shape = (1873,)
X_train = enc_X[: index].values <-- .shape = (1873,501)
Y_test = enc_Y[index:].flatten() <-- .shape = (209,)
X_test = enc_X[index:].values <-- .shape = (209,501)
model = LinearSVC(C=1, loss='hinge', max_iter=1000, verbose=0)
model.fit(X_train, Y_train)
---- this all works fine ----
然后这是我得到错误的地方:
Predictions = model.predict(X_test)
>> ValueError: shapes (209,501) and (922842,) not aligned: 501 (dim 1) != 922842 (dim 0)
感谢您的帮助