Coursera机器学习week7 编程作业

Posted starry

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Coursera机器学习week7 编程作业相关的知识,希望对你有一定的参考价值。

gaussianKernel.m

sim = exp(-sum((x1-x2).^2)/(sigma.^2*2));

 dataset3Params.m

steps = [0.01,0.03,0.1,0.3,1,3,10,30];
minError = Inf;
minC = Inf;
minSigma = Inf;


for i = 1:length(steps)
	for j = 1:length(steps)
		currC = steps(i);
		currSigma = steps(j);
		model = svmTrain(X, y, currC, @(x1, x2) gaussianKernel(x1, x2, currSigma)); 
		predictions = svmPredict(model, Xval);
		error = mean(double(predictions ~= yval));
		if(error < minError)
			minError = error;
			minC = currC;
			minSigma = currSigma;
		end
	end
end

C = minC;
sigma = minSigma;

processEmail.m

for i = 1:length(vocabList)
        if(strcmp(vocabList(i), str))
            word_indices = [word_indices; i]
            break;
        end
    end

emailFeatures.m

for i = 1:length(word_indices)
    x(word_indices(i)) = 1
end

  

以上是关于Coursera机器学习week7 编程作业的主要内容,如果未能解决你的问题,请参考以下文章

Coursera机器学习week7 单元测试

吴恩达-coursera-机器学习-week7

Coursera机器学习week7 笔记

机器学习- 吴恩达Andrew Ng Week7 知识总结Support Vector Machines

机器学习- 吴恩达Andrew Ng Coursera学习总结合集,编程作业技巧合集

机器学习- 吴恩达Andrew Ng Coursera学习总结合集,编程作业技巧合集