Algorithm: Compares Multiclass SVM, K nearest neighbor and Multiclass...

Description Usage Arguments Value Examples

View source: R/Algorithm.R

Description

Compares Multiclass SVM, K nearest neighbor and Multiclass Logistic regression on the labelled data points using five fold cross validation

Usage

1
Algorithm(Xtilde, Y, K = NULL)

Arguments

Xtilde

n * p centered and scaled data points

Y

A numeric n vector of labels of Xtilde

K

Number of classes, ( If K is NULL, it calculates K as maximum entry in Y)

Value

A list of three elements a list of three elements:

error_svm

returns five fold cross-validation error when Multiclass svm is used

error_knn

returns five fold cross-validation error when K-nearest neighbor is used with K = round(sqrt(N)) where N is the number of training data points

error_logistic

returns five fold cross-validation error when Multiclass logistic regression is used with default numIter = 50, eta = 0.1, lambda = 1

Examples

1
2
3
4
5
6
7
X <- rbind(matrix(rnorm(10,0,1),5,2),matrix(rnorm(10,1,2),5,2), matrix(rnorm(10,4,3),5,2))
fold_ids <- sample(1:15)
X <- X[fold_ids, ]
Xtilde <- standardizeX(X)$tilde
Y <- c(1,1,1,1,1,2,2,2,2,2,3,3,3,3,3)
Y <- Y[fold_ids]
out <- Algorithm(Xtilde,Y,3)

gargjhanvi/SSLLabelGuide documentation built on Dec. 20, 2021, 9:48 a.m.