Skip to contents

This function predicts values based on Generalized k-Nearest Neighbours model objects.

Usage

forecast_by_gknn(
  object,
  newx,
  type = c("response", "class", "prob", "votes"),
  newoffset,
  ...,
  target = 2L
)

Arguments

object

an object of class Trained

newx

the new values at which prediction are to be made

type

character specifying the type of prediction. Three options are available

"response"

predicted values are on the same scale as the outcome, e.g. for binomial the returned values are classes, for gaussian the expected values

"class"

the class labels corresponding to the max probability

"prob"

the class distribution

"votes"

the raw counts for each class

newoffset

currently not used

...

further arguments to predict.gknn

target

(optional) integer, index of the target class. If provided, only the prediction for the selected class are returned (default to second level of factor response). Set to NULL to return all classes

Value

A vector containing the predictions.

See also

Author

Alessandro Barberis