Created
December 13, 2019 19:17
-
-
Save Joelfranklin96/d78a6113da9393d6fb668b3199fccf18 to your computer and use it in GitHub Desktop.
Cross_validation_score
This file contains hidden or 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
# 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