Machine Learning 第八波编程作业(完)——Anomaly Detection and Recommender Systems

仅列出核心代码:

1.estimateGuassian.m

mu = mean(X)’;
X2 = (X – ones(m, 1)*mu’).^2;
sigma2 = mean(X2);

2.selectThreshold.m

cvPredictions = (pval < epsilon);
tp = sum((cvPredictions == 1) & (yval == 1));
fp = sum((cvPredictions == 1) & (yval == 0));
fn = sum((cvPredictions == 0) & (yval == 1));
prec = tp/(tp + fp);
rec = tp/(tp + fn);
F1 = 2*prec*rec/(prec + rec);

3.cofiCostFunc.m

X1 = (X*Theta’- Y).*R;
reg1 = (sum(sum(X.^2)) + sum(sum(Theta.^2)))*lambda/2;
J = sum(sum((X1).^2))/2 + reg1;

X_grad = X1*Theta + lambda*X;
Theta_grad = X1’*X + lambda*Theta;

课程地址:https://www.coursera.org/course/ml

 

Advertisements
    • k
    • 2013年7月1日

    终于追完了,累惨 orz ……
    看我的编程作业页面,就想起一种人民群众喜闻乐见的娱乐形式——80分

    • 哈哈,恭喜恭喜~
      道路越是难走,收获也就越大吧。

  1. 感谢LZ发布的每期编程题答案~

    虽然我没有照抄,但是卡住的时候还是会来头看一下的。
    说起来,有几次我提交作业被说有错,于是就跑来这里对答案,可又实在看不出我哪里有错,于是过5分钟原样重新提交,就nice work了,搞得我一脸的黑线 |||= =

    • 提交的时候有两种错误,一种是通讯中断引起的,这时再提交就可能没问题了。
      一种是程序本身的错误,这种情况下我还没有遇到过重新提交会正确的……

  1. No trackbacks yet.

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s