Skip to content

Instantly share code, notes, and snippets.

Created Dec 18, 2020
What would you like to do?
from sklearn.cross_validation import KFold
def run_kfold(clf):
kf = KFold(891, n_folds=10)
outcomes = []
fold = 0
for train_index, test_index in kf:
fold += 1
X_train, X_test = X_all.values[train_index], X_all.values[test_index]
y_train, y_test = y_all.values[train_index], y_all.values[test_index], y_train)
predictions = clf.predict(X_test)
accuracy = accuracy_score(y_test, predictions)
print("Fold {0} accuracy: {1}".format(fold, accuracy))
mean_outcome = np.mean(outcomes)
print("Mean Accuracy: {0}".format(mean_outcome))

This comment has been minimized.

Copy link

@rosha78 rosha78 commented May 3, 2021

Hi Do you have the code that has been put up for this project perfect?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment