machine-learning - SVM 训练的稍微倾斜的图

标签 machine-learning octave svm

我正在 coursera 上学习 ML 类(class),我的 SVMtraining 代码是正确的,但图表与 pdf 中提供的解决方案不匹配。我不明白我的代码中为什么或有什么问题。

以下是我的解决方案。我还附上了图表,第一个是提供的解决方案,另一个是我的。 enter image description here enter image description here

 function [C, sigma] = dataset3Params(X, y, Xval, yval)

 C = 1;
 sigma = 0.3;

 vals= [0.01 0.03 0.1 0.3 1 3 10 30];
 err=1000000000;

 for i=1:8
 for j= 1:8

 ex_C=vals(i);
 ex_sigma=vals(j);

 model=svmTrain(X, y, ex_C, @(x1,x2) gaussianKernel(x1,x2,ex_sigma));

 predictions = svmPredict(model, Xval);
 sam_err= mean(double(predictions ~= yval));

 if sam_err <= err
 C=ex_C;
 sigma=ex_sigma;
 err=sam_err;

 end 

 end

 end

最佳答案

轮廓应为contour(X1, X2, vals, [0.5 0.5], 'b');

关于machine-learning - SVM 训练的稍微倾斜的图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39930995/

相关文章:

numpy - Spark 随机森林 - 无法将 float 转换为 int 错误

Octave 将字符串从文件加载到矩阵

python - 在 python 中使用 SVM 进行回归置信度

matlab - 如何在 Octave 中绘制隐式曲面?

r - 使用 e1071 (SVM) 进行文本分类

r - plot 不会显示 svm 对象,也不会返回错误

machine-learning - SVM - 数据的属性是否可以指示最佳参数(例如 C、gamma)

machine-learning - 在具有不平衡数据的管道中进行交叉验证的正确方法

python - 有没有办法重命名 Keras 模型的指标和损失?

matlab - Matlab/Octave 中矢量/矩阵成员的无环函数调用