predict.nearestCentroid: Nearest Centroid Classifier Prediction

Description Usage Arguments Value Details Author(s) Examples

View source: R/centroid.R

Description

A function that predicts the class of points based on the nearest centroid

Usage

1
2
## S3 method for class 'nearestCentroid'
predict(object, X, ...)

Arguments

object

An object of class nearestCentroid, with the following attributes:

  • centroids[K, d] the centroids of each class with K classes in d dimensions.

  • ylabs[K] the ylabels for each of the K unique classes, ordered.

  • priors[K] the priors for each of the K classes.

X

[n, d] the data to classify with n samples in d dimensions.

...

optional args.

Value

Yhat [n] the predicted class of each of the n data point in X.

Details

For more details see the help vignette: vignette("centroid", package = "lolR")

Author(s)

Eric Bridgeford

Examples

1
2
3
4
5
library(lolR)
data <- lol.sims.rtrunk(n=200, d=30)  # 200 examples of 30 dimensions
X <- data$X; Y <- data$Y
model <- lol.classify.nearestCentroid(X, Y)
Yh <- predict(model, X)

Example output

Registered S3 methods overwritten by 'robust':
  method              from      
  plot.covfm          fit.models
  print.covfm         fit.models
  summary.covfm       fit.models
  print.summary.covfm fit.models
rlm is already registered in the fit.models registry
covfm is already registered in the fit.models registry

lolR documentation built on July 8, 2020, 7:35 p.m.