Skip to content

Instantly share code, notes, and snippets.

@Joelfranklin96
Created December 13, 2019 19:17
Show Gist options
  • Save Joelfranklin96/d78a6113da9393d6fb668b3199fccf18 to your computer and use it in GitHub Desktop.
Save Joelfranklin96/d78a6113da9393d6fb668b3199fccf18 to your computer and use it in GitHub Desktop.
Cross_validation_score
# Defining the models
models = [KNeighborsClassifier(n_neighbors = 3),
MLPClassifier(alpha = 1),
DecisionTreeClassifier(max_depth = 5),
RandomForestClassifier(max_depth=5,n_estimators=10,max_features=1),
AdaBoostClassifier(),
GaussianNB(),
SVC(kernel = 'linear'),
SVC(kernel = 'rbf'),
SVC(kernel = 'sigmoid')]
# KFold cross validation technique is used
validation_type = model_selection.KFold(n_splits = 10)
# Calculation of cross validation scores
cv_result = []
for i in range(len(models)):
cv_result.append(model_selection.cross_val_score(models[i],X_train,y_train,cv = validation_type,scoring = 'accuracy').mean())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment