Ejemplo n.º 1
0
        //create the CorrelatedFeatures List.
        public void CreateCf(TimeSeries ts)
        {
            float biggestPearson;
            CorrelatedFeatures currentStruct = new CorrelatedFeatures();
            int i;

            for (i = 0; i < ts.GetColumnSize(); i++)
            {
                currentStruct.Feature1 = ts.GetFeatures()[i];
                currentStruct.Feature2 = "";
                biggestPearson         = Threshold; //minimum for correlation
                for (int j = 0; j < ts.GetColumnSize(); j++)
                {
                    if (j == i)
                    {
                        continue;
                    }
                    float absPearson = AnomalyDetectionUtil.Pearson(ts.GetColumn(currentStruct.Feature1).ToArray(),
                                                                    ts.GetColumn(ts.GetFeatures()[j]).ToArray());
                    absPearson = absPearson > 0 ? absPearson : -absPearson;
                    if (absPearson >= biggestPearson)
                    {
                        biggestPearson            = absPearson;
                        currentStruct.Feature2    = ts.GetFeatures()[j];
                        currentStruct.Correlation = biggestPearson;
                    }
                }

                if (currentStruct.Feature2 != "")
                {
                    currentStruct.AllPoints = new List <Point>();
                    Cf.Add(currentStruct);
                }
            }

            /* //for the last item
             * i = ts.GetColumnSize() - 1;
             * currentStruct.Feature1 = ts.GetFeatures()[i];
             * currentStruct.Feature2 = "";
             * biggestPearson = Threshold; //minimum for correlation
             * for (int j = 0; j < i; j++)
             * {
             *   float absPearson = AnomalyDetectionUtil.Pearson(ts.GetColumn(currentStruct.Feature1).ToArray(),
             *       ts.GetColumn(ts.GetFeatures()[j]).ToArray());
             *   absPearson = absPearson > 0 ? absPearson : -absPearson;
             *   if (absPearson >= biggestPearson)
             *   {
             *       biggestPearson = absPearson;
             *       currentStruct.Feature2 = ts.GetFeatures()[j];
             *       currentStruct.Correlation = biggestPearson;
             *   }
             * }
             *
             * if (currentStruct.Feature2 != "")
             * {
             *   currentStruct.AllPoints = new List<Point>();
             *   Cf.Add(currentStruct);
             * }*/
        }
Ejemplo n.º 2
0
        //calculating the Line for each element in the List.
        private void CreateForm(TimeSeries ts)
        {
            for (var i = 0; i < _cf.Count; i++)
            {
                var array = new Point[ts.GetRowSize()];
                for (var j = 0; j < ts.GetRowSize(); j++)
                {
                    array[j] = new Point(ts.GetColumn(_cf[i].Feature1)[j], ts.GetColumn(_cf[i].Feature2)[j]);
                    _cf[i].AllPoints.Add(array[j]);
                }

                var line = CreateCorrelativeForm(array);

                _cf[i] = new CorrelatedFeatures(_cf[i].Feature1, _cf[i].Feature2, _cf[i].Correlation, line);
                //float th = FindThreshold(array, Cf[i]);
                //Cf[i] = new CorrelatedFeatures(Cf[i].Feature1, Cf[i].Feature2, Cf[i].Correlation, th, line);
            }
        }
Ejemplo n.º 3
0
        //calculating the Line for each element in the List.
        public void CreateForm(TimeSeries ts)
        {
            for (var i = 0; i < Cf.Count; i++)
            {
                Point[] array = new Point[ts.GetRowSize()];
                for (int j = 0; j < ts.GetRowSize(); j++)
                {
                    array[j] = new Point(ts.GetColumn(Cf[i].Feature1)[j], ts.GetColumn(Cf[i].Feature2)[j]);
                    Cf[i].AllPoints.Add(array[j]);
                }

                Line line = CreateCorrelativeForm(array);

                Cf[i] = new CorrelatedFeatures(Cf[i].Feature1, Cf[i].Feature2, Cf[i].Correlation, 0, line);
                //float th = FindThreshold(array, Cf[i]);
                //Cf[i] = new CorrelatedFeatures(Cf[i].Feature1, Cf[i].Feature2, Cf[i].Correlation, th, line);
            }
        }
Ejemplo n.º 4
0
        //create the CorrelatedFeatures List.
        private void CreateCf(TimeSeries ts)
        {
            var currentStruct = new CorrelatedFeatures();
            int i;

            for (i = 0; i < ts.GetColumnSize(); i++)
            {
                currentStruct.Feature1 = ts.GetFeatures()[i];
                currentStruct.Feature2 = "";
                var biggestPearson = _threshold;
                for (var j = 0; j < ts.GetColumnSize(); j++)
                {
                    if (j == i)
                    {
                        continue;
                    }
                    var absPearson = AnomalyDetectionUtil.Pearson(ts.GetColumn(currentStruct.Feature1).ToArray(),
                                                                  ts.GetColumn(ts.GetFeatures()[j]).ToArray());
                    absPearson = absPearson > 0 ? absPearson : -absPearson;
                    if (!(absPearson >= biggestPearson))
                    {
                        continue;
                    }
                    biggestPearson            = absPearson;
                    currentStruct.Feature2    = ts.GetFeatures()[j];
                    currentStruct.Correlation = biggestPearson;
                }

                if (currentStruct.Feature2 == "")
                {
                    continue;
                }
                currentStruct.AllPoints = new List <Point>();
                _cf.Add(currentStruct);
            }
        }