SPEC.fit: Fit the supervised classifier under partition exchangeability

Description Usage Arguments Value Examples

View source: R/Classifier.R

Description

Trains the model according to training data x, where x is assumed to follow the Poisson-Dirichlet distribution, and discrete labels y.

Usage

1
SPEC.fit(x, y)

Arguments

x

data vector, or matrix with rows as data points and columns as features.

y

training data label vector of length equal to the amount of rows in x.

Value

Returns an object used as training data objects for the classification algorithms tMarLab and tSimLab.

If x is multidimensional, each list described below is returned for each dimension.

Returns a list of classwise lists, each with components:

frequencies: the frequencies of values in the class.

psi: the Maximum Likelihood estimate for ψ for the class.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## Create training data x and its class labels y from Poisson-Dirichlet distributions
## with different psis:
set.seed(111)
x1<-rPD(5000,10)
x2<-rPD(5000,100)
x<-c(x1,x2)
y1<-rep("1", 5000)
y2<-rep("2", 5000)
y<-c(y1,y2)
fit<-SPEC.fit(x,y)

## With multidimensional x:
set.seed(111)
x1<-cbind(rPD(5000,10),rPD(5000,50))
x2<-cbind(rPD(5000,100),rPD(5000,500))
x<-rbind(x1,x2)
y1<-rep("1", 5000)
y2<-rep("2", 5000)
y<-c(y1,y2)
fit<-SPEC.fit(x,y)

ville-kinnula/SPEC documentation built on Dec. 23, 2021, 3:11 p.m.