Machine Learning by Andrew Ng --- Anomaly Detection and Recommender systems

本文深入探讨了异常检测的原理与步骤,包括利用高斯分布学习特征的均值和方差,通过ε选择与F1分数评估,以及最终公式应用于异常检测。同时,阐述了推荐系统的数学建模过程,特别提到了协同过滤算法的成本函数、梯度计算、正则化成本函数和正则化梯度等关键概念。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

In anomaly detection problems,every features corresponding to one formula of Gaussian distribution.

To start anomaly detection,the steps you should do are the fellows:
  • Using all the examples of each feature to learn the correspond mu and sigma.
  • Then selecting the epsilon with F1 scores.
  • Something more important already show in the lecture notes.
Then Multiplicative every Gaussian distribution’s formula ,Using the final formula to detect the anomalous.But sometimes it does not fit well.So maybe you should change your way to get the final formula of your anomaly detection algorithm.the follow picture shows the formula:

These are the differences between Original model and Multiplicative Gaussian:

Let’s now talk about Recommender Systems:

I think that to deal with Recommender Systems problems,It is important to build a powerful mathmatical model.
for this exercise ,the follow picture shows the model(with unknow features),Which has two matrix represented movies’ and users’ features:

In order to deal with this kind of problem,we may recommended to use an algorithm named Collaborative filtering learning algorithm,the steps:

  • Collaborative filtering cost function
  • Collaborative filtering gradient
  • Regularized cost function
  • Regularized gradient
The picture below will help you( To follow the steps show on the exercise’s pdf is better):


Also show you how i finish this ,but do not copy it!:

id = find(R==1);%获取R==1的下标
J = (1/2) * sum(sum( (((X*Theta')-Y).*R ).^2)) + ((lambda/2) * sum(sum(Theta.^2)) )+ ((lambda/2) * sum(sum(X.^2)) );

for index1 = 1:num_users
%弄明白整个算法的过程,向量化就简单了。
    idx1 = find(R(:,index1)==1);%获得第index1个用户评价了的电影列向量下标(参考ppt的电影与用户的关系的表格)
    XT = X(idx1,:);%获取第index1个用户评价过的每个电影的features
    YT = Y(idx1,index1);%获得第index1个用户评价过的每个电影的得分
    Theta_grad(index1,:) = ((Theta(index1,:) * XT') - YT' ) * XT + lambda*Theta(index1,:);%向量化求解
end

for index2 = 1:num_movies
    idx2 = find(R(index2,:)==1);%获得一个用户列表下标(所有评价过第index2部电影的用户)
    ThetaT = Theta(idx2,:);%获得评价过第index2部电影的用户featrues
    YT = Y(index2,idx2);%获得第index2部电影被所有评价过该电影的用户给的得分
    X_grad(index2,:) = ( X(index2,:) * ThetaT' - YT ) * ThetaT + lambda*X(index2,:); %向量化求解
end
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值