Coursera Machine Learning Week 7 - Support Vector Machines

来源:互联网 发布:文明太空mac版 编辑:程序博客网 时间:2024/06/05 08:11

Quiz

1.

Suppose you have trained an SVM classifier with a Gaussian kernel, and it learned the following decision boundary on the training set:

You suspect that the SVM is underfitting your dataset. Should you try increasing or decreasing C? Increasing or decreasing σ2?

  • It would be reasonable to try decreasing C. It would also be reasonable to try decreasing σ2.
  • It would be reasonable to try decreasing C. It would also be reasonable to try increasing σ2.
  • It would be reasonable to try increasing C. It would also be reasonable to try increasing σ2.
  • (CHECKED) It would be reasonable to try increasing C. It would also be reasonable to try decreasing σ2.

2.

The formula for the Gaussian kernel is given by similarity(x,l(1))=exp(−||x−l(1)||22σ2) .

The figure below shows a plot of f1=similarity(x,l(1)) when σ2=1.

Which of the following is a plot of f1 when σ2=0.25?

选瘦的那个

3.

The SVM solves

minθ C∑mi=1y(i)cost1(θTx(i))+(1−y(i))cost0(θTx(i))+∑nj=1θ2j
where the functions cost0(z) and cost1(z) look like this:

The first term in the objective is:

C∑mi=1y(i)cost1(θTx(i))+(1−y(i))cost0(θTx(i)).
This first term will be zero if two of the following four conditions hold true. Which are the two conditions that would guarantee that this term equals zero?

  • (CHECKED) For every example with y(i)=0, we have that θTx(i)≤−1.
  • (CHECKED) For every example with y(i)=1, we have that θTx(i)≥1.
  • For every example with y(i)=0, we have that θTx(i)≤0.
  • For every example with y(i)=1, we have that θTx(i)≥0.

4.

Suppose you have a dataset with n = 10 features and m = 5000 examples.

After training your logistic regression classifier with gradient descent, you find that it has underfit the training set and does not achieve the desired performance on the training or cross validation sets.

Which of the following might be promising steps to take? Check all that apply.

  • (CHECKED) Try using a neural network with a large number of hidden units.
  • (CHECKED) Create / add new polynomial features.
  • Use a different optimization method since using gradient descent to train logistic regression might result in a local minimum.
  • Reduce the number of examples in the training set.

5.

Which of the following statements are true? Check all that apply.

  • If you are training multi-class SVMs with the one-vs-all method, it is not possible to use a kernel.

  • (CHECKED) Suppose you have 2D input examples (ie, x(i)∈ℝ2). The decision boundary of the SVM (with the linear kernel) is a straight line.

  • (CHECKED) The maximum value of the Gaussian kernel (i.e., sim(x,l(1))) is 1.

  • If the data are linearly separable, an SVM using a linear kernel will return the same parameters θ regardless of the chosen value of C (i.e., the resulting value of θ does not depend on C).

ex6

gaussianKernel.m

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

dataset3Param.m

if(0)min = inf;v = [0.01 0.03 0.1 0.3 1 3 10 30];fprintf('find min prediction error\n');for c = v  for s = v    model = svmTrain(X, y, c, @(x1, x2) gaussianKernel(x1, x2, s));    e = mean(double(svmPredict(model, Xval) ~= yval));    fprintf('c, s, e: %f, %f, %f\n', c, s, e);    if( e <= min )      fprintf('## min c, s, e: %f %f %f\n', c, s, e);      C = c;      sigma = s;      min = e;    end  endendfprintf('final C, sigma, min_error: %f %f %f\n', C, sigma, min);% final C, sigma, min_error: 1.000000 0.100000 0.030000endif

emailFeature.m

for i = word_indices    x(i) = 1;end% x = arrayfun(@(i) ~isempty(word_indices(word_indices==i)), 1:n);

processEmail.m

    for i = 1:length(vocabList)      if (strcmp(str, vocabList{i}))        word_indices = [word_indices ; i];      end    end    % word_indices = [word_indices strmatch(str, vocabList, 'exact')];

-eof-

0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 华为平板电脑开机密码忘记了怎么办 微信被太多人投诉被限制登录怎么办 微信账号被永久封号里面的钱怎么办 乱世王者领礼包时账号异常怎么办 qq填写资料见证号格式错误怎么办 如果把微信注销 王者的号怎么办 93元的吃鸡号忘了激活吗怎么办 王者荣耀实名注册不是自己的怎么办 苹果手机打开qq太慢了怎么办 剪辑视频打开了软件关闭不了怎么办 玩永恒纪元手游网络老掉线怎么办 绝地求生买的钥匙激活码忘了怎么办 魅族手机移动网络打不开网页怎么办 小米5s升级后下载不了软件怎么办 电脑可以登qq却开不了网页怎么办 手机微信图片没下载原图怎么办 qq号密码忘了密保忘了怎么办 扣扣更改密保手机失败怎么办 至尊宝安全模式密保手机更换怎么办 微信号手机号换了密码忘记了怎么办 被加盟网店托管骗了怎么办 善林金融倒闭投资者的钱怎么办? 微信支付密码忘了怎么办没绑卡 美团外卖没有骑手接单怎么办 发微信的"发送"没有了怎么办 华硕电脑下面的任务栏卡住了怎么办 微信登别人电脑上忘记退了怎么办 买手机买全新结果买到翻新机怎么办 苹果手机激活锁忘了id账号怎么办 淘宝很多产品都需要3c怎么办 小米mix装在兜里还能解锁怎么办 痰咳不出来憋的嘴唇紫了怎么办 京东闪电退款后不给退货怎么办 我的中国银行卡在异地被冻结怎么办 qq密保号码换了验证不了怎么办 qq登陆需要密保手机验证怎么办 微信漂流瓶被投诉收不到回复怎么办 电视的屏幕出现三条黑线怎么办 付了定金的房子不想要了怎么办 顾客刚买了东西就退怎么办 飞机票买了但是没有报团怎么办