예제 #1
0
        public void open_xml()
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog
            {
                InitialDirectory = @"C:\",
                Title            = "Browse Text Files",
                CheckFileExists  = true,
                CheckPathExists  = true,
                DefaultExt       = "xml",
                Filter           = "xml files (*.xml)|*.xml",
                FilterIndex      = 2,
                RestoreDirectory = true,
                ReadOnlyChecked  = true,
                ShowReadOnly     = true
            };

            // check if file path is correct
            if (openFileDialog1.ShowDialog() == true)
            {
                file_path = openFileDialog1.FileName; // initial file path field
                //StreamReader sr = new StreamReader(file_path);
                readXML((string)file_path);
                create_dict();
                find_most_corralated();
                TimeSeries            ts1 = new TimeSeries((string)file_path_csv, chunks);
                SimpleAnomalyDetector s   = new SimpleAnomalyDetector();
                TimeSeries            ts  = new TimeSeries((string)file_path2, chunks);
                s.learnNormal(ts);
                List <AnomalyReport> a = s.detect(ts1);
            }
        }
예제 #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);
            CorrelatedFeatures c = s.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();
                }
                // size vector
                int size = ts_normal.get_dict()[features.IndexOf(chosen_feature)].Count;
                // create circle ****************************************************************
                List <DataPoint> learn_points = circle_to_points(c.Center.x, c.Center.y, c.Threshold);
                Circle_Points = learn_points;
                NotifyPropertyChanged("Circle_Points");
                //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");
                // the point of the detect
                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");
            }

            // anomaly.get_points(ts_normal.get_dict()[features.IndexOf(chosen_feature)], ts_normal.get_dict()[ts_normal.get]
        }