From 1cc27c08b1cae00143a70e69883ecf42cdbb67c6 Mon Sep 17 00:00:00 2001 From: "Ricardo Pereira da Costa (pereir33)" Date: Tue, 28 Jun 2022 20:13:16 +0100 Subject: [PATCH] Add files via upload --- car_insurance.ipynb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/car_insurance.ipynb b/car_insurance.ipynb index c5e1c17..159e846 100644 --- a/car_insurance.ipynb +++ b/car_insurance.ipynb @@ -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": {