Learn R Programming

CCI (version 0.3.6)

wrapper_knn: k-Nearest Neighbors (KNN) wrapper for CCI (kknn-based)

Description

k-Nearest Neighbors (KNN) wrapper for CCI (kknn-based)

Usage

wrapper_knn(
  formula,
  data,
  train_indices,
  test_indices,
  metric,
  metricfunc = NULL,
  k = 15,
  eps = 1e-15,
  positive = NULL,
  kernel = "optimal",
  distance = 2,
  ...
)

Value

Numeric performance metric

Arguments

formula

Model formula

data

Data frame

train_indices

Indices for training rows

test_indices

Indices for test rows

metric

Performance metric: "RMSE" (regression), "Kappa" (classification), or "LogLoss" (classification)

metricfunc

Optional custom metric function: function(actual, predictions, ...)

k

Integer, number of neighbors (default 15)

eps

Small value to avoid log(0) in LogLoss calculations. Default is 1e-15.

positive

Character. The positive class label for binary classification (used in LogLoss). Default is NULL.

kernel

Character. Weighting kernel for kknn. Default "optimal".

distance

Numeric. Minkowski distance parameter. 2 = Euclidean. Default 2.

...

Additional arguments passed to kknn::kknn (e.g., ykernel, na.action)