Accelerating the pace of engineering and science

# resubEdge

Class: ClassificationSVM

Classification edge for support vector machine classifiers by resubstitution

## Description

example

e = resubEdge(SVMModel) returns the resubstitution classification edge (e) for the support vector machine (SVM) classifier SVMModel using the training data stored in SVMModel.X and corresponding class labels stored in SVMModel.Y.

## Input Arguments

expand all

### SVMModel — Full, trained SVM classifierClassificationSVM classifier

Full, trained SVM classifier, specified as a ClassificationSVM model trained using fitcsvm.

## Output Arguments

expand all

### e — Classification edgescalar

Classification edge, returned as a scalar. e represents the weighted mean of the classification margins.

## Definitions

### Edge

The edge is the weighted mean of the classification margins.

The weights are the prior class probabilities. If you supply weights, then the software normalizes them to sum to the prior probabilities in the respective classes. The software uses the renormalized weights to compute the weighted mean.

One way to choose among multiple classifiers, e.g., to perform feature selection, is to choose the classifier that yields the highest edge.

### Classification Margins

The classification margins are, for each observation, the difference between the score for the true class and maximal score for the false classes. Provided that they are on the same scale, margins serve as a classification confidence measure, i.e., among multiple classifiers, those that yield larger margins are better [2].

### Score

The SVM score for classifying observation x is the signed distance from x to the decision boundary ranging from -∞ to +∞. A positive score for a class indicates that x is predicted to be in that class, a negative score indicates otherwise.

The score is also the numerical, predicted response for x, $f\left(x\right)$, computed by the trained SVM classification function

$f\left(x\right)=\sum _{j=1}^{n}{\alpha }_{j}{y}_{j}G\left({x}_{j},x\right)+b,$

where $\left({\alpha }_{1},...,{\alpha }_{n},b\right)$ are the estimated SVM parameters, $G\left({x}_{j},x\right)$ is the dot product in the predictor space between x and the support vectors, and the sum includes the training set observations.

## Examples

expand all

### Estimate the Resubstitution Edge of SVM Classifiers

```load ionosphere
```

Train an SVM classifier. It is good practice to standardize the predictors and define the class order.

```SVMModel = fitcsvm(X,Y,'Standardize',true,'ClassNames',{'b','g'});
```

SVMModel is a trained ClassificationSVM classifier. 'b' is the negative class and 'g' is the positive class.

Estimate the resubstitution edge.

```e = resubEdge(SVMModel)
```
```e =

5.0996

```

The mean of the training sample margins is 5.0999.

### Select SVM Classifier Features by Comparing In-Sample Edges

The classifier edge measures the average of the classifier margins. One way to perform feature selection is to compare training sample edges from multiple models. Based solely on this criterion, the classifier with the highest edge is the best classifier.

Load the ionosphere data set. Define two data sets:

• fullX contains all predictors (except the removed column of 0s).

• partX contains the last 20 predictors.

```load ionosphere
fullX = X;
partX = X(:,end-20:end);
```

Train SVM classifiers for each predictor set.

```FullSVMModel = fitcsvm(fullX,Y);
PartSVMModel = fitcsvm(partX,Y);
```

Estimate the training sample edge for each classifier.

```fullEdge = resubEdge(FullSVMModel)
partEdge = resubEdge(PartSVMModel)
```
```fullEdge =

3.3652

partEdge =

2.0471

```

The edge for the classifier trained on the complete data set is greater, suggesting that the classifier trained using all of the predictors has a better in-sample fit.

## Algorithms

For binary classification, the software defines the margin for observation j, mj, as

${m}_{j}=2{y}_{j}f\left({x}_{j}\right),$

where yj ∊ {-1,1}, and f(xj) is the predicted score of observation j for the positive class. However, the literature commonly uses mj = yjf(xj) to define the margin.

## References

[1] Christianini, N., and J. C. Shawe-Taylor. An Introduction to Support Vector Machines and Other Kernel-Based Learning Methods. Cambridge, UK: Cambridge University Press, 2000.

[2] Hu, Q., X. Che, L. Zhang, and D. Yu. "Feature Evaluation and Selection Based on Neighborhood Soft Margin." Neurocomputing. Vol. 73, 2010, pp. 2114–2124.