public List <AnomalyReport> detect(Timeseries ts) { List <AnomalyReport> vector = new List <AnomalyReport>(); int i = 0; foreach (correlatedFeatures var in cf) { for (int j = 0; j < ts.table.First().Value.Count(); ++j) { // Loop through the map. int iter = -1; // Loop through the cf vector. iter++; float floatA = ts.table[var.feature1][j]; float floatB = ts.table[var.feature2][j]; dynamic p = new Point(floatA, floatB); // A point represent the two current features. //float correlation = dev(*p, i->lin_reg); // Case the correlation is bigger then the threshold determined by the current correlation deviation. if (isAnomalous(var, p)) { string description = var.feature1 + "-" + var.feature2; long timeStep = j + 1; // For time step to start with 1 instead of 0. AnomalyReport ar = new AnomalyReport(description, timeStep); // Build a anomaly report with those features. vector.Add(ar); } } i++; } return(vector); }
public List <AnomalyReport> detect(Timeseries ts) { List <AnomalyReport> anomalies = new List <AnomalyReport>(); int numOfRows = ts.NumOfRows; int cfLen = cf.Count; for (int cfIndex = 0; cfIndex < cfLen; cfIndex++) { for (int timeStep = 0; timeStep < numOfRows; timeStep++) { if (isAnomaly(ts, cf[cfIndex], timeStep)) { //cout << "Anomaly found at " << timeStep + 1 << ": " << currDev << " crossed " << cf[cfIndex].threshold << std::endl; AnomalyReport report = new AnomalyReport(cf[cfIndex].feature1 + "-" + cf[cfIndex].feature2, timeStep + 1); anomalies.Add(report); } } } return(anomalies); }