$$ \newcommand{\R}{\mathbb{R}} \newcommand{\E}{\mathbb{E}} \newcommand{\x}{\mathbf{x}} \newcommand{\y}{\mathbf{y}} \newcommand{\wv}{\mathbf{w}} \newcommand{\av}{\mathbf{\alpha}} \newcommand{\bv}{\mathbf{b}} \newcommand{\N}{\mathbb{N}} \newcommand{\id}{\mathbf{I}} \newcommand{\ind}{\mathbf{1}} \newcommand{\0}{\mathbf{0}} \newcommand{\unit}{\mathbf{e}} \newcommand{\one}{\mathbf{1}} \newcommand{\zero}{\mathbf{0}} \newcommand\rfrac[2]{^{#1}\!/_{#2}} \newcommand{\norm}[1]{\left\lVert#1\right\rVert} $$ # 随机异常值选择 ## 描述 异常值是一个或多个在数量上偏离大多数数据集的观测值,可能是进一步研究的主题。由Jeroen Janssens[[1]](# Janssens)开发的随机离群点选择(SOS)是一种将一组向量作为输入的无监督随机异常值选择算法。该算法采用基于相似性的离群点选择,并对每个数据点输出一个离群点概率。直观地说,当其他数据点与某个数据点没有足够的关联性时,该数据点就被认为是一个异常值。 异常值检测在许多领域都有应用,例如,日志分析,欺诈检测,噪声消除,新颖性检测,质量控制,传感器监控等。如果传感器出现故障,大概率会输出偏离的值。 有关更多信息,请参阅[Jeroens Janssens博士论文](https://github.com/jeroenjanssens/phd-thesis)关于异常值选择和单类分类的介绍算法。 ## 参数 随机异常值选择算法的实现可以通过以下参数控制: | 参数 | 描述 | | --- | --- | | **Perplexity** | Perplexity可以解释为k-最近邻算法中的k。 与SOS作为邻居的区别不是二元属性,而是概率属性,因此它是实数。 必须介于1和n-1之间,其中n是点数。 通过使用观察数量的平方根可以获得良好的起点. (默认值: **30**) | | **ErrorTolerance** | 可接受的误差容限,以在近似亲和力时减少计算时间。 它会牺牲精度以换取减少的计算时间. (默认值: **1e-20**) | | **MaxIterations** | 用于近似算法亲和度的最大迭代次数。(默认值: **10**) | ## 例子 ``` val data = env.fromCollection(List( LabeledVector(0.0, DenseVector(1.0, 1.0)), LabeledVector(1.0, DenseVector(2.0, 1.0)), LabeledVector(2.0, DenseVector(1.0, 2.0)), LabeledVector(3.0, DenseVector(2.0, 2.0)), LabeledVector(4.0, DenseVector(5.0, 8.0)) // The outlier! )) val sos = new StochasticOutlierSelection().setPerplexity(3) val outputVector = sos .transform(data) .collect() val expectedOutputVector = Map( 0 -> 0.2790094479202896, 1 -> 0.25775014551682535, 2 -> 0.22136130977995766, 3 -> 0.12707053787018444, 4 -> 0.9922779902453757 // The outlier! ) outputVector.foreach(output => expectedOutputVector(output._1) should be(output._2)) ``` **参考** [1]J.H.M. Janssens, F. Huszar, E.O. Postma, and H.J. van den Herik. _Stochastic Outlier Selection_. Technical Report TiCC TR 2012-001, Tilburg University, Tilburg, the Netherlands, 2012.