| heuristicC | R Documentation |
heuristicC implements a heuristics proposed by Thorsten Joachims in
order to make fast estimates of a convenient value for the C constant used by
support vector machines. This implementation only works for linear support
vector machines.
heuristicC(data)
data |
a nxp data matrix. Each row stands for an example (sample, point)
and each column stands for a dimension (feature, variable). A vector will
be transformed to a n x 1 matrix. Sparse matrices of class matrix.csr,
matrix.csc and matrix.coo from package SparseM are accepted, as are
dgCMatrix, dgRMatrix and dgTMatrix from package Matrix – the same classes
accepted by |
A value for the C constant is returned, computed as follows:
\frac{1}{\frac{1}{n}\sum_{i=1}^{n}\sqrt{G[i,i]}}
where
G=\code{data}\%*\%t(\code{data})
Classification models usually perform better if each dimension of the data is first centered and scaled. If data are scaled, it is better to compute the heuristics on the scaled data as well.
Thibault Helleputte thibault.helleputte@dnalytics.com
T. Joachims
SVM light (2002)
http://svmlight.joachims.org
LiblineaR
data(iris)
x=iris[,1:4]
y=factor(iris[,5])
train=sample(1:dim(iris)[1],100)
xTrain=x[train,]
xTest=x[-train,]
yTrain=y[train]
yTest=y[-train]
# Center and scale data
s=scale(xTrain,center=TRUE,scale=TRUE)
# Sparse Logistic Regression
t=6
co=heuristicC(s)
m=LiblineaR(data=s,target=yTrain,type=t,cost=co,bias=TRUE,verbose=FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.