System: Ubuntu with gcc installed
Libsvm Installation
1 | cd libsvm-3.2/matlab |
Just for Test
Load data
1 | cd ../ |
Result:
Error using load
Number of columns on line 3 of ASCII file heart_scale must be the same as previous lines.
Load data again and train model
1 | [heart_scale_label, heart_scale_inst] = libsvmread('heart_scale'); |
Result:
*
optimization finished, #iter = 162
nu = 0.431029
obj = -100.877288, rho = 0.424462
nSV = 132, nBSV = 107
Total nSV = 132
model =
struct with fields:
Parameters: [5×1 double]
nr_class: 2
totalSV: 132
rho: 0.4245
Label: [2×1 double]
sv_indices: [132×1 double]
ProbA: []
ProbB: []
nSV: [2×1 double]
sv_coef: [132×1 double]
SVs: [132×13 double]
Predict the data and show accuracy
1 | [predict_label, accuracy, decision_values] = svmpredict(heart_scale_label, heart_scale_inst, model); |
Result:
Accuracy = 86.6667% (234/270) (classification)