Description Usage Arguments Details Value See Also Examples
Selects prototypes for each class in a greedy manner as described in 'Bien and Tibshirani (2011) Prototype Selection for Interpretable Classification. Annals of Applied Statistics. 5(4). 24032424.'
protoclass
1  protoclass(x, y, z, dxz, eps, lambda = 1/n)

x 
n by p matrix of training features (optional,
see 
y 
nvector of labels of the training data. 
z 
set of potential prototypes (optional, see

dxz 
instead of 
eps 
size of covering balls. 
lambda 
cost of adding a prototype. 
It's more efficient to compute dxz just once on your own rather than have protoclass repeatedly compute the pairwise distances on each call.
An object of class "protoclass," which has the following elements:
alpha: Matrix of dimensions nrow(z)bynclass. alpha[j,k] indicates whether jth potential prototype has been chosen as a prototype for class k.
classes: Names of classes
proto.order: The sequence of prototypes that were selected.
ncovered: nprotobynclass matrix with ncovered[j,k] giving the number of class k training points covered by the jth prototype's ball.
coverlist: nbynclass matrix with row i giving number of each type of prototype covering point i.
uncovered: Indicates whether a training point is not covered by a prototype of its own class.
wrongcover: Number of prototypes from other classes covering each training point.
nproto: nclassvector giving the number of prototypes in each class.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26  # generate some data:
set.seed(1)
n < 200
p < 2
x < matrix(rnorm(n * p), n, p)
y < rep(c("A","B"), each=n/2)
x[y=="A", ] < x[y=="A", ] + 3
itr < sample(n, n/2)
xtr < x[itr, ] # train
ytr < y[itr]
xte < x[itr, ] # test
yte < y[itr]
# take prototype candidates identical to training points:
z < xtr
dxz < dist2(xtr, z)
# run protoclass:
prot < protoclass(dxz=dxz, y=ytr, eps=2, lambda=1/n)
## Not run:
plot(prot,xtr,y=1+(ytr=="A"))
## End(Not run)
# get predictions on test data:
pred1 < predict(prot, xte, z=xtr)
# get predictions on test data using pairwise distances:
pred2 < predictwithd.protoclass(prot, dist2(xte, z))

Loading required package: class
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.