Skip to content

Commit 591a4e1

Browse files
add best params to clsfcn2
1 parent 3f5e20b commit 591a4e1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

source/classification2.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,8 +1220,7 @@ accuracies_grid
12201220

12211221
We can decide which number of neighbors is best by plotting the accuracy versus $K$,
12221222
as shown in {numref}`fig:06-find-k`.
1223-
Here we are using the shortcut `point=True`
1224-
to layer a point and line chart.
1223+
Here we are using the shortcut `point=True` to layer a point and line chart.
12251224

12261225
```{code-cell} ipython3
12271226
:tags: [remove-output]
@@ -1250,6 +1249,13 @@ glue("best_acc", "{:.1f}".format(accuracies_grid["mean_test_score"].max()*100))
12501249
Plot of estimated accuracy versus the number of neighbors.
12511250
:::
12521251

1252+
We can also obtain the number of neighbours with the highest accuracy programmatically by accessing
1253+
the `best_params_` attribute of the fit `GridSearchCV` object. Note that it is still useful to visualize
1254+
the results as we did above since this provides additional information on how the model performance varies.
1255+
```{code-cell} ipython3
1256+
cancer_tune_grid.best_params_
1257+
```
1258+
12531259
+++
12541260

12551261
Setting the number of

0 commit comments

Comments
 (0)