我已经使用下面的训练数据集成功构建了逻辑回归模型。X = train.drop('y', axis=1)y = train['y']X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.5)scaler = StandardScaler() scaler.fit(X_train)X_train = scaler.transform(X_train)X_test = scaler.transform(X_test)logreg1 = LogisticRegression()logreg1.fit(X_train, y_train)score = logreg1.score(X_test, y_test)cvs = cross_val_score(logreg1, X_test, y_test, cv=5).mean()我的问题是我想引入测试数据集来预测未知的 y 值。在测试数据中没有 y 列。如何使用单独的测试数据集预测 y 值?
1 回答
智慧大石
TA贡献1946条经验 获得超3个赞
使用预测():
y_pred = logreg1.predict(X_test)
score = logreg1.score(X_test, y_pred)
print(y_pred) // see the predictions
添加回答
举报
0/150
提交
取消