View source: R/070_Hyperparameters.R
| setup_KNN | R Documentation |
Setup hyperparameters for k-Nearest Neighbors training.
setup_KNN(k = 7L, kernel = "optimal", distance = 2, scale = TRUE, ifw = FALSE)
k |
(Tunable) Integer [1, Inf): Number of neighbors. Must be less than the number of training cases. |
kernel |
(Tunable) Character {"rectangular", "triangular", "epanechnikov", "biweight", "triweight", "cos", "inv", "gaussian", "rank", "optimal"}: Kernel used to weight neighbors by distance. |
distance |
(Tunable) Numeric (0, Inf): Parameter of the Minkowski distance. |
scale |
Logical: If TRUE, scale features to unit variance before computing distances. |
ifw |
(Tunable) Logical: If TRUE, use Inverse Frequency Weighting in classification. |
Both outcome types are fit with kknn::train.kknn, which selects between
regression and classification from the outcome. Factors are one-hot encoded
by rtemis first, as an algorithm-internal preprocessor that is re-applied at
predict time: the backend's own factor handling resolves a contrast function
off the search path, which is not reachable when kknn is loaded but not
attached, as a suggested package is.
kknn provides no case weights, so ifw cannot be honored: enabling it
makes training abort.
KNNHyperparameters object.
EDG
knn_hyperparams <- setup_KNN(k = 11L, kernel = "rectangular")
knn_hyperparams
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.