Exemple #1
0
    public virtual bool isAnomaly(Timeseries ts, correlatedFeatures cf, int timeStep)
    {
        List <float> Column1   = ts.GetColumn(cf.feature1);
        List <float> Column2   = ts.GetColumn(cf.feature2);
        Point        currPoint = new Point(Column1[timeStep], Column2[timeStep]);
        float        currDev   = Anomaly_Detection_Util.dev(currPoint, cf.lin_reg);

        return(currDev > cf.threshold * 1.1);
    }
Exemple #2
0
    public bool isAnomalous(correlatedFeatures cf, Point point)
    {
        float correlation = adu.dev(point, cf.lin_reg);

        if (correlation > cf.threshold)
        {
            return(true);
        }
        return(false);
    }
        new public void cirCorr(correlatedFeatures cf, Point[] points, int size)
        {
            Circle minCircle = new Circle(new Point(0, 0), 0);
            Circle circle    = minCircle.findMinCircle(points, size);

            cf.centerX   = circle.center.x;
            cf.centerY   = circle.center.y;
            cf.rad       = circle.radius;
            cf.threshold = (float)(cf.rad * 1.1);
            cf.isCircle  = true;
            this.cf.Add(cf);
        }
Exemple #4
0
 public override bool isAnomaly(Timeseries ts, correlatedFeatures cf, int timeStep)
 {
     if (cf.corrlation > circThreshold)
     {
         var   Column1   = ts.GetColumn(cf.feature1);
         var   Column2   = ts.GetColumn(cf.feature2);
         Point currPoint = new Point(Column1[timeStep], Column2[timeStep]);
         //Point point = cf.center
         return(Circle_Util.distanceBetweenPoints(currPoint, cf.center) > cf.threshold * 1.1);
     }
     return(false);
 }
Exemple #5
0
 public virtual void addCorrelation(Timeseries ts, string feat1, string feat2, float pearson)
 {
     if (pearson > linThreshold)
     {
         correlatedFeatures correlation = new correlatedFeatures();
         correlation.feature1   = feat1;
         correlation.feature2   = feat2;
         correlation.corrlation = pearson;
         var Column1 = ts.GetColumn(feat1);
         var Column2 = ts.GetColumn(feat2);
         correlation.lin_reg   = Anomaly_Detection_Util.LinReg(Column1, Column2);
         correlation.threshold = getMaxDev(Timeseries.CombineColumns(Column1, Column2), correlation.lin_reg);
         cf.Add(correlation);
     }
 }
        new public bool isAnomalous(correlatedFeatures cf, Point point)
        {
            if (!cf.isCircle)
            {
                return(isAnomalous(cf, point));
            }

            else
            {
                float cor = (float)Math.Sqrt(Math.Pow(point.x - cf.centerX, 2) + Math.Pow(point.y - cf.centerY, 2));
                if (cor > cf.threshold)
                {
                    return(true);
                }
            }
            return(false);
        }
Exemple #7
0
 public override void addCorrelation(Timeseries ts, string feat1, string feat2, float pearson)
 {
     if (pearson > circThreshold)
     {
         correlatedFeatures correlation = new correlatedFeatures();
         correlation.feature1   = feat1;
         correlation.feature2   = feat2;
         correlation.corrlation = pearson;
         var    Column1   = ts.GetColumn(feat1);
         var    Column2   = ts.GetColumn(feat2);
         var    points    = Timeseries.CombineColumns(Column1, Column2);
         Circle welzlCirc = Circle_Util.welzl(points, new List <Point>());
         correlation.center    = welzlCirc.center;
         correlation.threshold = welzlCirc.radius;
         cf.Add(correlation);
     }
 }
Exemple #8
0
    public void learnNormal(Timeseries ts)
    {
        anomaly_detection_util             adu   = new anomaly_detection_util();
        Dictionary <string, List <float> > tsMap = ts.table;
        List <string> tsFeaturesVector           = ts.features;
        int           featuresVectorSize         = tsFeaturesVector.Count();
        int           valueVectorSize            = tsMap[tsFeaturesVector[0]].Count();

        for (int i = 0; i < featuresVectorSize; ++i)
        {
            string             fiName     = tsFeaturesVector[i];
            float[]            fiData     = tsMap[fiName].ToArray();
            float              maxPearson = 0;
            correlatedFeatures currentCF  = new correlatedFeatures();
            currentCF.feature1 = fiName;
            for (int j = i + 1; j < featuresVectorSize; ++j)
            {
                string  fjName         = tsFeaturesVector[j];
                float[] fjData         = tsMap[fjName].ToArray();
                float   currentPearson = Math.Abs(adu.pearson(fiData, fjData, valueVectorSize));
                if (currentPearson > maxPearson)
                {
                    maxPearson         = currentPearson;
                    currentCF.feature2 = fjName;
                }
            }
            if (maxPearson > this.threshold)
            {
                currentCF.corrlation = maxPearson;
                Point[] points = new Point[valueVectorSize];
                for (int j = 0; j < valueVectorSize; ++j)
                {
                    points[j] = new Point(tsMap[currentCF.feature1][j], tsMap[currentCF.feature2][j]);
                }
                currentCF.lin_reg   = adu.linear_reg(points, valueVectorSize);
                currentCF.threshold = 0;
                for (int j = 0; j < valueVectorSize; ++j)
                {
                    currentCF.threshold = Math.Max(currentCF.threshold, Math.Abs(adu.dev(points[j], currentCF.lin_reg)));
                }
                currentCF.threshold *= (float)1.1;
                cf.Add(currentCF);
            }
        }
    }
Exemple #9
0
 public float cirCorr(correlatedFeatures cf, Point[] points, int size)
 {
     return(0);
 }