예제 #1
0
        public List <AnomalyReport> detect(IDictionary <string, List <float> > table)
        {
            List <AnomalyReport> anomalyReport = new List <AnomalyReport>();

            foreach (CorrelatedFeatures correlatedFeature in cf)
            {
                for (int i = 0; i < table[correlatedFeature.Feature1].Count; i++)
                {
                    Point p = new Point(table[correlatedFeature.Feature1].ElementAt(i), table[correlatedFeature.Feature1].ElementAt(i));
                    if (!MinCircle.IsPointInside(correlatedFeature.CircleThreshold, p))
                    {
                        anomalyReport.Add(new AnomalyReport(correlatedFeature.Feature1 + "-" + correlatedFeature.Feature2, i));
                    }
                }
            }
            return(anomalyReport);
        }
예제 #2
0
        public void LearnNormal(IDictionary <string, List <float> > table)
        {
            int columnSize = table.ElementAt(0).Value.Count; //table.Keys.ElementAt(0)
            int rowSize    = table.Count;

            for (int i = 0; i < table.Count; i++)
            {
                CorrelatedFeatures cfs = new CorrelatedFeatures();
                cfs.Corr     = -1;
                cfs.Feature1 = table.ElementAt(i).Key;
                for (int j = i + 1; j < table.Count; j++)
                {
                    float correlation = AnomalyUtils.Pearson(table.ElementAt(i).Value, table.ElementAt(j).Value);
                    if (correlation > correlationThreshold)
                    {
                        if (correlation > cfs.Corr)
                        {
                            cfs.Feature2 = table.ElementAt(j).Key;
                            cfs.Corr     = correlation;
                            cfs.Lin_Reg  = AnomalyUtils.LinearReg(table.ElementAt(i).Value,
                                                                  table.ElementAt(j).Value);
                            cfs.Threshold = HighestDev(table.ElementAt(i).Value,
                                                       table.ElementAt(j).Value, cfs.Lin_Reg);

                            List <Point> pointsList = new List <Point>();
                            for (int k = 1; k < columnSize; k++)
                            {
                                pointsList.Add(new Point(table[cfs.Feature1].ElementAt(k), table[cfs.Feature2].ElementAt(k)));
                            }

                            cfs.CircleThreshold         = MinCircle.FindMinCircle(pointsList);
                            cfs.CircleThreshold.radius *= 1.1;
                        }
                    }
                }
                if (cfs.Corr > -1)
                {
                    cf.Add(cfs);
                }
            }
        }