コード例 #1
0
        public void find_exceptions_points(string csv_learn, string csv_detect, List <string> features, string chosen_feature)
        {
            Anomaly_detector      anomaly = new Anomaly_detector();
            SimpleAnomalyDetector s       = new SimpleAnomalyDetector();

            this.sd   = s;
            ts_normal = new TimeSeries((string)csv_learn, features);
            sd.learnNormal(ts_normal);
            ts_detect       = new TimeSeries((string)csv_detect, features);
            anomaly_reports = sd.detect(ts_detect);
            for (int i = 0; i < anomaly_reports.Count; i++)
            {
                Line_Reg_Points.Add(new DataPoint(anomaly_reports[i].timeStep, 0));
            }
            NotifyPropertyChanged("Line_Reg_Points");
        }
コード例 #2
0
        public void updateChoose(string csv_learn, string csv_detect, List <string> features, string chosen_feature)
        {
            /*Anomaly_detector anomaly = new Anomaly_detector();
             * SimpleAnomalyDetector s = new SimpleAnomalyDetector();
             * this.sd = s;
             * ts_normal = new TimeSeries((string)csv_learn, features);
             * s.learnNormal(ts_normal);
             * TimeSeries ts_detect = new TimeSeries((string)csv_detect, features);
             * anomaly_reports = s.detect(ts_detect);*/
            Anomaly_detector      anomaly = new Anomaly_detector();
            SimpleAnomalyDetector s       = new SimpleAnomalyDetector();

            this.sd   = s;
            ts_normal = new TimeSeries((string)csv_learn, features);
            sd.learnNormal(ts_normal);
            ts_detect       = new TimeSeries((string)csv_detect, features);
            anomaly_reports = sd.detect(ts_detect);
            for (int i = 0; i < anomaly_reports.Count; i++)
            {
                Line_Reg_Points.Add(new DataPoint(anomaly_reports[i].timeStep, 0));
            }
            NotifyPropertyChanged("Line_Reg_Points");
            CorrelatedFeatures c = sd.get_correlated(chosen_feature);

            if (c != null)
            {
                string second_cor;
                if (c.get_feature1() == chosen_feature)
                {
                    second_cor = c.get_feature2();
                }
                else
                {
                    second_cor = c.get_feature1();
                }

                int size = ts_normal.get_dict()[features.IndexOf(chosen_feature)].Count;
                //sap-
                List <DataPoint> learn_points = line_to_points(c.get_line_reg(), size, ts_detect.get_dict()[features.IndexOf(chosen_feature)], ts_detect.get_dict()[features.IndexOf(second_cor)]);
                Line_Reg_Points = learn_points;
                NotifyPropertyChanged("Line_Reg_Points");
                //same
                List <DataPoint> detected_points = new List <DataPoint>();
                for (int i = 0; i < anomaly_reports.Count; i++)
                {
                    if (anomaly_reports[i].get_feature1() == chosen_feature)
                    {
                        float x = ts_detect.get_dict()[features.IndexOf(chosen_feature)][(int)anomaly_reports[i].timeStep];
                        float y = ts_detect.get_dict()[features.IndexOf(second_cor)][(int)anomaly_reports[i].timeStep];
                        detected_points.Add(new DataPoint(x, y));
                    }
                    else
                    {
                        float x = ts_detect.get_dict()[features.IndexOf(second_cor)][(int)anomaly_reports[i].timeStep];
                        float y = ts_detect.get_dict()[features.IndexOf(chosen_feature)][(int)anomaly_reports[i].timeStep];
                        detected_points.Add(new DataPoint(x, y));
                    }
                }
                Anomaly_Points = detected_points;
                NotifyPropertyChanged("Anomaly_Points");
            }
            else
            {
                Anomaly_Points  = new List <DataPoint>();
                Line_Reg_Points = new List <DataPoint>();
            }
        }