SVM支持向量机这部分代码主要参考[1]李航老师的书而完成. 

//下面演示SVM使用过程
//1. 下面产生训练数据, 训练数据x在0到1之间, 而对应的y则是, x小于0.5时y=-1, 否则y = 1
x = 0:1000;
x = x';
x = x / 1000;
y = {ReplaceByCondition<矩阵运算\ReplaceByCondition>}(x, <, 0.5, -1);
y = {ReplaceByCondition<矩阵运算\ReplaceByCondition>}(y, >, 0, 1);

//2. 假如我们已经有上面的样本数据x, y
svm = {SVMCreate<矩阵运算\SVMCreate>}();
{SVMSetType<矩阵运算\SVMSetType>}(svm, "RQuad");
{SVMSetData<矩阵运算\SVMSetData>}(svm, x, y);
{SVMSetPenalty<矩阵运算\SVMSetPenalty>}(svm, 1e4);
{SVMSolve<矩阵运算\SVMSolve>}(svm);

x1 = 0.451;
y1 = {SVMPredict<矩阵运算\SVMPredict>}(svm, x1);//预测结果,

参考:
[1] 李航. 统计学习方法[M]. 清华大学出版社, 2012.