http://www.cnblogs.com/piags/archive/2012/11/06/2757683.html
插入算法
参照 http://www.ctex.org/documents/packages/verbatim/index.htm 中的algorithms章节,下面举例说明需要注意的几点
代码范例
\begin{algorithm}
\caption{PB-KNN Algorithm}
\label{alg_PB-KNN}
\algblock[Name]{Begin}{End}
\begin{algorithmic}[1]
\scriptsize
\Require DataSet $D$, parameters $k$,$n$
\Ensure outliers set $OutSet$
\Begin
\State Classify and pre-pruning, get $D=\{D_1,D_2,\cdots,D_n\}$
\State Sort subsets and clusters,get $C=\{C_1,C_2,C_3,C_4\}$
\ForAll {cluster $C_i\in C$}
\ForAll {data $p\in C_i$}
\State Inti $Neig(p)$
\ForAll {data $q\in C_i$ \textbf{and} $q\neq p$}
\If {$Avg_D(q)+\mathrm{distance}(p,q)\leq OutValue$}
\State data $p$ is not an outlier, \textbf{break}
\EndIf
\If {$Avg_D(p)\leq OutValue$ \textbf{and} $|Neig(p)|=q$}
\State data $p$ is not an outlier, \textbf{break}
\EndIf
\If {$\text{distance}(p,q) \leq
\text{Maxdistance}(p,Neig(p))$}
\State Update $Neig(p)$ by $q$
\EndIf
\If {$Avg_D(p)> OutValue$}
\State Update $OutSet$ by $p$
\EndIf
\If {$|OutSet|=n$}
\State Update $OutValue$ by $\text{Min}(OutSet)$
\EndIf
\EndFor
\EndFor
\EndFor
\State \textbf{return} $OutSet$
\End
\end{algorithmic}
\end{algorithm}
\caption{PB-KNN Algorithm}
\label{alg_PB-KNN}
\algblock[Name]{Begin}{End}
\begin{algorithmic}[1]
\scriptsize
\Require DataSet $D$, parameters $k$,$n$
\Ensure outliers set $OutSet$
\Begin
\State Classify and pre-pruning, get $D=\{D_1,D_2,\cdots,D_n\}$
\State Sort subsets and clusters,get $C=\{C_1,C_2,C_3,C_4\}$
\ForAll {cluster $C_i\in C$}
\ForAll {data $p\in C_i$}
\State Inti $Neig(p)$
\ForAll {data $q\in C_i$ \textbf{and} $q\neq p$}
\If {$Avg_D(q)+\mathrm{distance}(p,q)\leq OutValue$}
\State data $p$ is not an outlier, \textbf{break}
\EndIf
\If {$Avg_D(p)\leq OutValue$ \textbf{and} $|Neig(p)|=q$}
\State data $p$ is not an outlier, \textbf{break}
\EndIf
\If {$\text{distance}(p,q) \leq
\text{Maxdistance}(p,Neig(p))$}
\State Update $Neig(p)$ by $q$
\EndIf
\If {$Avg_D(p)> OutValue$}
\State Update $OutSet$ by $p$
\EndIf
\If {$|OutSet|=n$}
\State Update $OutValue$ by $\text{Min}(OutSet)$
\EndIf
\EndFor
\EndFor
\EndFor
\State \textbf{return} $OutSet$
\End
\end{algorithmic}
\end{algorithm}
本文介绍了一种名为PB-KNN的异常检测算法,该算法通过预处理和聚类技术来提高检测效率,并使用K近邻策略确定数据点是否为异常值。文中详细描述了算法流程,包括初始化邻居集、更新异常值集合等步骤。
2641

被折叠的 条评论
为什么被折叠?



