在pycharm中运行的。。。
# Quick Start
1、第一个
```
from svmutil import *
# Read data in LIBSVM format
y, x = svm_read_problem('../heart_scale')
m = svm_train(y[:200], x[:200], '-c 4')
p_label, p_acc, p_val = svm_predict(y[200:], x[200:], m)
```
2、第二个
```
# Construct problem in python format
# Dense data
# y, x = [1,-1], [[1,0,1], [-1,0,-1]]
# Sparse data
y, x = [1,-1], [{1:1, 3:1}, {1:-1,3:-1}]
prob = svm_problem(y, x)
param = svm_parameter('-t 0 -c 4 -b 1')
m = svm_train(prob, param)
p_label, p_acc, p_val = svm_predict(y, x, m)
```
3、第三个
```
# 4
# Precomputed kernel data (-t 4)
# # Dense data
# # y, x = [1,-1], [[1, 2, -2], [2, -2, 2]]
# # Sparse data
# y, x = [1,-1], [{0:1, 1:2, 2:-2}, {0:2, 1:-2, 2:2}]
# # isKernel=True must be se for precomputed kernel
prob = svm_problem(y, x, isKernel=True)
param = svm_parameter('-t 4 -c 4 -b 1')
m = svm_train(prob, param)
p_label, p_acc, p_val = svm_predict(y, x, m)
# For the format of precomputed kernel, please read LIBSVM README.
```
4、第四个
```
# Other utility functions
svm_save_model('heart_scale.model', m)
m = svm_load_model('heart_scale.model')
p_label, p_acc, p_val = svm_predict(y, x, m, '-b 1')
ACC, MSE, SCC = evaluations(y, p_label)
```
5、第五个
```
# Getting online help
help(svm_train)
```
6、第六个
```
from svm import *
prob = svm_problem([1,-1], [{1:1, 3:1}, {1:-1,3:-1}])
param = svm_parameter('-c 4')
m = libsvm.svm_train(prob, param) # m is a ctype pointer to an svm_model
# Convert a Python-format instance to svm_nodearray, a ctypes structure
x0, max_idx = gen_svm_nodearray({1:1, 3:1})
label = libsvm.svm_predict(m, x0)
print(label)
```