# heuristicC: Fast Heuristics For The Estimation Of the C Constant Of A... In LiblineaR: Linear Predictive Models Based on the LIBLINEAR C/C++ Library

 heuristicC R Documentation

## Fast Heuristics For The Estimation Of the C Constant Of A Support Vector Machine.

### Description

`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.

### Usage

```heuristicC(data)
```

### Arguments

 `data` a nxp data matrix. Each row stands for an example (sample, point) and each column stands for a dimension (feature, variable)

### Value

A value for the C constant is returned, computed as follows:
1/(1/n Sum_i=1:n sqrt(G[i,i])) where data %*% t(data)

### Note

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.

### Author(s)

Thibault Helleputte thibault.helleputte@dnalytics.com

### References

`LiblineaR`

### Examples

```data(iris)

x=iris[,1:4]
y=factor(iris[,5])
train=sample(1:dim(iris),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,labels=yTrain,type=t,cost=co,bias=TRUE,verbose=FALSE)

```

LiblineaR documentation built on Dec. 3, 2022, 9:09 a.m.