本文是学习Andrew Ng的机器学习系列教程的学习笔记。教学视频地址:
https://study.163.com/course/introduction.htm?courseId=1004570029#/courseDetail?tab=1
异常侦测:
61. Anomaly detection – Problem motivation
New data is anomaly with old data. Anomaly data Possibility
Set a number , if new test point is bigger than it, the point is anomaly
针对一些特性建立针对某一期待预测状态的可能性模型
62. Anomaly detection – Gaussian distribution or normal distribution
曲线与x轴面积为1
Sigma越小,图形越高越尖;Mu是中心点位置;
参数估计问题:给出数据,估算高斯分布参数Mu 和sigma
参数估计有公式:
Maximum likelihood estimation极大似然估计
1/m或者1/(m-1)在数学上有区别,但实践中差别很小,只要有较大数据量m
63. Anomaly detection – Algorithm
二维数据图形化展示:
P(x)相当于三维图形中的高度:
64. Anomaly detection – developing and evaluating an anomaly detection system
用训练数据拟合模型,用交叉验证数据优化特征数量及sigma,最后用测试数据测试最终的模型:
65. Anomaly detection – anomaly detection vs. supervised learning
正样本数量太少负样本数量大,就很难从学习算法中获得模型,所以采用错误检测,从负样本中学习;
正样本数量大,比如垃圾邮件,我们有很多垃圾邮件,可以用监督学习;
66. Anomaly detection – choosing what features to use
数据用hist画直方图,不符合高斯分布的进行对数转化;log transport
或者其他方法转换,调整红圈内参数,使得数据更高斯分布:
octave 中正则化特征数据:
错误分析:当模型不能预测异常数据,就分析异常数据具备的特性,引入新特征,让算法从数据中提取新特征进行训练;
从没有标记出来的异常样本上找新特征;
选择特征:
CPU负载和网络负载比率,应该能反应正常与否,正常应该是正比;
67. Anomaly detection – Multivariate Gaussian distribution
图形分析,有些异常数据不能很好的标记出来:
可以采用多元高斯分布进行改进:
协方差矩阵正对角数值影响特征变化快慢;反对角数值影响x1=x2方向上的变化快慢;Mu是峰值位置;
68. Anomaly detection – Anomaly detection using the multivariate Gaussian distribution
According to the data set to calculate the mu and sigma:
多元高斯分布与原始的高斯分布:
原始高斯分布,是针对轴对称的,是多元高斯的特殊情况;
- 如果手动创建特征来引入单独特征之间的关系,可以用原始模型;
- 数据量大用原始
- 即使训练数据relatively small training set集很小,也能很好工作
- 多元高斯可以自动的引入单独特征之间关系;
- 耗费计算资源
- 训练数量要大于特征数量,最好大于10倍以上; sigma是可逆的;才使用多元;
当sigma不可逆,就尝试m大于10倍n,或者看看有没有等价、冗余的特征:x1=x2, x3=x4+x5…;