Learn R Programming

scR (version 0.4.0)

scb: Calculate sample complexity bounds for a classifier given target accuracy

Description

Calculate sample complexity bounds for a classifier given target accuracy

Usage

scb(vcd = NULL, epsilon = NULL, delta = NULL, eta = NULL, theor = TRUE, ...)

Value

A real number giving the sample complexity bound for the specified parameters.

Arguments

vcd

The Vapnik-Chervonenkis dimension (VCD) of the chosen classifier. If theor is FALSE, this can be left unspecified and simvcd() will be called to estimate the VCD

epsilon

A real number between 0 and 1 giving the targeted maximum out-of-sample (OOS) error rate

delta

A real number between 0 and 1 giving the targeted maximum probability of observing an OOS error rate higher than epsilon

eta

A real number between 0 and 1 giving the probability of misclassification error in the training data.

theor

A Boolean indicating whether the theoretical VCD is to be used. If FALSE, it will instead be estimated using simvcd()

...

Arguments to be passed to simvcd()

See Also

simvcd(), to calculate VCD for a chosen model

Examples

Run this code
mylogit <- function(formula, data){
m <- structure(
  glm(formula=formula,data=data,family=binomial(link="logit")),
  class=c("svrclass","glm")  #IMPORTANT - must use the class svrclass to work correctly
)
return(m)
}
mypred <- function(m,newdata){
out <- predict.glm(m,newdata,type="response")
out <- factor(ifelse(out>0.5,1,0),levels=c("0","1"))
#Important - must specify levels to account for possibility of all
#observations being classified into the same class in smaller samples
return(out)
}
library(parallel)
scb(epsilon=0.05,delta=0.05,eta=0.05,theor=FALSE,
model=mylogit,dim=7,m=10,k=10,maxn=50,predictfn = mypred,
    coreoffset = (detectCores() -2))
vcd <- 7
scb(vcd,epsilon=0.05,delta=0.05,eta=0.05)

Run the code above in your browser using DataLab