Support Vector Machine Action Set
Active-Set Method
This example trains a model by using the same German Credit Benchmark data that are used in Example 38.1. In this case, instead of using the default interior point method, the action applies the active-set method and the nonlinear RBF kernel.
The following statements use the svmTrain action to run the active-set algorithm on the mycas.dmagecr data table. The method parameter specifies the training technique as active set. The kernel parameter specifies the kernel as radial basis function (RBF). The savestate parameter specifies a table named svmModel to save the model.
proc cas;
action svm.svmtrain /
table="dmagecr"
method="ACTIVESET"
kernel="RBF"
kernelParm=1
nominals={"checking" "history" "purpose" "savings" "employed"
"marital" "coapp" "property" "other" "job" "housing"
"telephon" "foreign" "good_bad"}
inputs={"duration" "amount" "installp" "resident" "existcr"
"depends" "age" "checking" "history" "purpose" "savings"
"employed" "marital" "coapp" "property" "other" "job"
"housing" "telephon" "foreign"}
target="good_bad"
savestate={name="svmModel", replace=true};
run;
quit;
The "Training Results" table in Output 38.3.1 shows that the inner product of the weights is 461.159728; the bias is 0.47396852; and the number of support vectors is 960, where 289 of those vectors are on the margin. The table also shows that the maximum decision function value (Maximum F) is 1.30042618 and the minimum decision function value (Minimum F) is –1.
Output 38.3.1: Active-Set Method Training Results
| Training Results | |
|---|---|
| Inner Product of Weights | 461.159728 |
| Bias | 0.47396852 |
| Total Slack (Constraint Violations) | 126.851782 |
| Norm of Longest Vector | 1 |
| Number of Support Vectors | 960 |
| Number of Support Vectors on Margin | 289 |
| Maximum F | 1.30042618 |
| Minimum F | -1 |
| Number of Effects | 20 |
| Columns in Data Matrix | 61 |
The "Misclassification Matrix" table in Output 38.3.2 shows that among the total of 1,000 observations, 700 observations are classified as good and 300 observations are classified as bad. The number of correctly predicted good observations is 700, and the number of correctly predicted bad observations is 294. Thus the accuracy is 99.4%, as indicated in the "Fit Statistics" table in Output 38.1.3.
Output 38.3.2: Active-Set Method Misclassification Matrix
| Misclassification Matrix | |||
|---|---|---|---|
| Observed | Training Prediction | ||
| bad | good | Total | |
| bad | 294 | 6 | 300 |
| good | 0 | 700 | 700 |
| Total | 294 | 706 | 1000 |
Output 38.3.3: Active-Set Method Accuracy
| Fit Statistics | |
|---|---|
| Statistic | Training |
| Accuracy | 0.9940 |
| Error | 0.0060 |
| Sensitivity | 0.9800 |
| Specificity | 1.0000 |
Active-Set Method
This example trains a model by using the same German Credit Benchmark data that are used in Example 38.1. In this case, instead of using the default interior point method, the action applies the active-set method and the nonlinear RBF kernel.
The following statements use the svmTrain action to run the active-set algorithm on the mycas.dmagecr data table. The method parameter specifies the training technique as active set. The kernel parameter specifies the kernel as radial basis function (RBF). The savestate parameter specifies a table named svmModel to save the model.
s:loadactionset{actionset="svm"}
out = s:svmtrain{
table = "dmagecr",
method = "activeset",
kernel = "RBF",
kernelParm = 1.0,
nominals = {"checking","history","purpose","savings","employed","marital",
"coapp","property","other","job","housing","telephon",
"foreign","good_bad" },
inputs = {"duration","amount","installp","resident","existcr","depends",
"age","checking","history","purpose","savings","employed",
"marital","coapp","property","other","job","housing","telephon",
"foreign"},
target = "good_bad",
savestate={name="svmModel"}
}
The following commands display the tables that are produced by this action call:
print(out.ModelInfo)
print(out.TrainingResult)
print(out.Misclassification)
print(out.FitStatistics)
For details about the results of this analysis, see the CASL version of this example.
Active-Set Method
This example trains a model by using the same German Credit Benchmark data that are used in Example 38.1. In this case, instead of using the default interior point method, the action applies the active-set method and the nonlinear RBF kernel.
The following statements use the svmTrain action to run the active-set algorithm on the mycas.dmagecr data table. The method parameter specifies the training technique as active set. The kernel parameter specifies the kernel as radial basis function (RBF). The savestate parameter specifies a table named svmModel to save the model.
s.loadactionset("svm")
out=s.svmTrain(
table = {"name":"dmagecr"},
method = "activeset",
kernel = "rbf",
kernelParm = 1,
nominals = {"checking","history","purpose","savings","employed",
"marital","coapp","property","other","job","housing",
"telephon","foreign","good_bad"},
inputs = {"duration","amount","installp","resident","existcr",
"depends","age", "checking","history","purpose","savings",
"employed", "marital","coapp","property","other","job",
"housing","telephon","foreign"},
target = "good_bad",
savestate = {"name":"svmModel"}
)
The following commands display the tables that are produced by this action call:
print(out.ModelInfo)
print(out.TrainingResult)
print(out.Misclassification)
print(out.FitStatistics)
For details about the results of this analysis, see the CASL version of this example.
Active-Set Method
This example trains a model by using the same German Credit Benchmark data that are used in Example 38.1. In this case, instead of using the default interior point method, the action applies the active-set method and the nonlinear RBF kernel.
The following statements use the svmTrain action to run the active-set algorithm on the mycas.dmagecr data table. The method parameter specifies the training technique as active set. The kernel parameter specifies the kernel as radial basis function (RBF). The savestate parameter specifies a table named svmModel to save the model.
cas.read.csv(s,
"dmagecr.csv",
header = TRUE,
casOut = list(name = "dmagecr", replace = TRUE))
loadActionSet(s, 'svm')
result<-cas.svm.svmTrain(s,
table = "dmagecr",
method = "activeset",
kernel = "RBF",
kernelParm1 = 1,
nominals = list("checking", "history", "purpose", "savings", "employed",
"marital", "coapp", "property", "other", "job", "housing",
"telephon", "foreign", "good_bad"),
inputs = list("duration", "amount", "installp", "resident",
"existcr", "depends", "age", "checking",
"history", "purpose", "savings", "employed",
"marital", "coapp", "property", "other",
"job", "housing", "telephon", "foreign"),
target = "good_bad",
savestate={name="svmModel"})
The following command displays the tables that are produced by this action call:
print(result)
For details about the results of this analysis, see the CASL version of this example.