You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: r/2021-07-21-ml-knn.rmd
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ We will train a [k-Nearest Neighbors (kNN)](https://parsnip.tidymodels.org/refer
14
14
15
15
### Display training and test splits
16
16
17
-
We get the synthetic data that form the shape of a moon. We then split it into a training and testing set. data that form the shape of a moon. We then split it into a training and testing set. Finally, we display the ground truth labels using [a scatter plot](https://plotly.com/r/line-and-scatter/).
17
+
Using Tidymodels, we first generate synthetic data that form the shape of a moon. We then split it into a training and testing set. Finally, we display the ground truth labels using [a scatter plot](https://plotly.com/r/line-and-scatter/).
18
18
19
19
In the graph, we display all the negative labels as squares, and positive labels as circles. We differentiate the training and test set by adding a dot to the center of test data.
Now, we train the kNN model on the same training data displayed in the previous graph. Then, we predict the confidence score of the model for each of the data points in the test set. We will use shapes to denote the true labels, and the color will indicate the confidence of the model for assign that score.
51
51
52
-
Notice that `scatter` only requires one function call to plot both negative and positive labels, and can additionally set a continuous color scale based on the `yscore` output by our kNN model.
52
+
Notice that `plot_ly` only requires one function call to plot both negative and positive labels, and can additionally set a continuous color scale based on the `yscore` output by our kNN model.
53
53
54
54
```{r}
55
55
library(plotly)
@@ -206,7 +206,7 @@ fig
206
206
207
207
## Multi-class prediction confidence with [`Heatmap`](https://plotly.com/r/heatmaps/)
208
208
209
-
It is also possible to visualize the prediction confidence of the model using [heatmaps](https://plotly.com/r/heatmaps/). In this example, you can see how to compute how confident the model is about its prediction at every point in the 2D grid. Here, we define the confidence as the difference between the highest score and the score of the other classes summed, at a certain point.
209
+
It is also possible to visualize the prediction confidence of the model using [heatmaps](https://plotly.com/r/heatmaps/). In this example, you can see how to compute how confident the model is about its prediction at every point in the 2D grid. Here, we define the confidence as the difference between the highest score and the sum of the score of the other classes, at a certain point.
0 commit comments