//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); * }*/ }
//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); } }
// create linear regression from Point[]. private static Line CreateCorrelativeForm(Point[] array) { return(AnomalyDetectionUtil.LinearReg(array)); }