The algorithm can score data with continuous or logical features.
The algorithm can predict either a continuous or categorical target, or both
(but no more than one of each), as well as return the closest neighbors
ranked by distance or similarity. If no continuous or categorical target is
provided, return_ranked_neighbors must be non-zero, and ranked neighbors will
be returned.
There is no predict
method for knn
. The scored test set is returned
as part of the neighbr
object. The data to be scored must be passed in
with the training data to knn()
.
Supported distance measures (used with continuous features): euclidean, squared_euclidean.
Supported similarity measures (used with logical features): simple_matching, jaccard, tanimoto.
Currently, only one type of categorical_scoring_method and
continuous_scoring_method are supported (majority vote and average, respectively).
Logical features must consist of 0,1 or TRUE,FALSE values.
Categorical non-logical features must be transformed before being used.
The categorical target does not have to be of factor class, but is assumed to be not continuous.
The distance and similarity measures in this package are based on those
defined in the
PMML
specification.
Several of the elements in the returned list are only used when converting
the knn model to PMML (for example, function_name
).
For more details and examples, see the vignette by running the following:
vignette("neighbr-help")