Skip to content
Permalink
Browse files
Add files via upload
  • Loading branch information
pereir33 committed Jun 28, 2022
1 parent b53fc6f commit 1cc27c08b1cae00143a70e69883ecf42cdbb67c6
Showing 1 changed file with 11 additions and 1 deletion.
@@ -1490,7 +1490,7 @@
"%%capture\n",
"from sklearn.model_selection import GridSearchCV\n",
"\n",
"#grid search for decision tree regression\n",
"#grid search for Kneighbours classification\n",
"tuningKNC=GridSearchCV(modelKNC,param_grid=ParamsKNC,scoring='neg_mean_squared_error',cv=3,verbose=3)\n",
"tuningKNC.fit(X_train,y_train)\n"
]
@@ -1536,6 +1536,7 @@
}
],
"source": [
"#Decision tree classifier using the best parameters found\n",
"modelDT = DecisionTreeClassifier(criterion=\"entropy\",max_depth=11,max_features=None,min_samples_leaf=9,min_weight_fraction_leaf=0.1,splitter=\"random\")\n",
"modelDT = modelDT.fit(X_train, y_train)\n",
"modelDT.predict(X_test)\n",
@@ -1559,12 +1560,21 @@
}
],
"source": [
"#KNeighbours Classifier using the best parameters found\n",
"modelKNC = KNeighborsClassifier(algorithm=\"auto\",metric=\"manhattan\",n_neighbors=10,p=1,weights=\"uniform\")\n",
"modelKNC = modelKNC.fit(X_train,y_train)\n",
"modelKNC.predict(X_test)\n",
"print (\"The accuricy for the train set is :\" + str(modelKNC.score(X_train,y_train)))\n",
"print (\"The accuricy for the test set is :\" + str(modelKNC.score(X_test,y_test)))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In both tuned models the score obtained in the training set were infiriors to the ones obtained using default parameteres,\n",
"but, the score obtained by the tuned models in the test set were better than using the default parameters"
]
}
],
"metadata": {

0 comments on commit 1cc27c0

Please sign in to comment.