Created
February 16, 2020 03:25
-
-
Save vidit0210/cb47dd7482a642874f3f1caf88e3fd19 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.model_selection import StratifiedKFold | |
from sklearn.base import clone | |
skfolds = StratifiedKFold(n_splits =3,random_state=42) | |
for train_index,test_index in skfolds.split(X_train,y_train_5): | |
clone_clf = clone(sgd_clf) | |
X_train_folds = X_train[train_index] | |
y_train_folds = y_train_5[train_index] | |
X_test_fold = X_train[test_index] | |
y_test_fold = y_train_5[test_index] | |
clone_clf.fit(X_train_folds,y_train_folds) | |
y_pred = clone_clf.predict(X_test_fold) | |
n_correct = sum(y_pred == y_test_fold) | |
print(n_correct/len(y_pred)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment