in my course i learned how to use cross validation to increase the accuracy of my model, everything looks beautiful in training. But when I go to practice in training I find that I can't use the models trained with cross-validation, follow my code:
X = array[:,0:8]
Y = array[:,8]
num_folds = 10
seed = 7
kfold = KFold(num_folds, True, random_state = seed)
modelo = LogisticRegression()
resultado = cross_val_score(modelo, X, Y, cv = kfold)
print("Acurácia: %.3f" % (resultado.mean() * 100))
in this cross-validation logic how can i use the model trained in my test data?
I'm trying something like modelo.predict(X_test)
but not success
can anyone help me?
You need to fit the model to the data before you can use the .predict
function. I believe you're using scikit learn, so:
clf = LogisticRegression()
clf = clf.fit(X, y)
clf.predict(X[:2, :])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.