Beispiel #1
0
        private void button12_Click(object sender, EventArgs e)
        {
            progressBar1.Maximum = dataDoubleTest.Count;

            dataGridView4.Rows[2].Cells[1].Value = dataGridView2.Rows.Count / 100 * Convert.ToDouble(dataGridView4.Rows[1].Cells[1].Value);

            InfaDlyaObnaryjeniyaAnomaliiARFF infa = new InfaDlyaObnaryjeniyaAnomaliiARFF();

            infa.dataTrain   = dataDoubleTrain;
            infa.dataTest    = dataDoubleTest;
            infa.porogOcenki = 90;


            Task.Factory.StartNew(() => { obnaryjenieAnomaliiARFF(infa); }); //Создание и запуск нового потока
        }
Beispiel #2
0
        public void obnaryjenieAnomaliiARFF(object a)
        {
            InfaDlyaObnaryjeniyaAnomaliiARFF infa      = (InfaDlyaObnaryjeniyaAnomaliiARFF)a;
            List <List <Double> >            dataTrain = infa.dataTrain; //обучающие данные
            List <List <Double> >            dataTest  = infa.dataTest;  //обучающие данные

            DateTime dateTime;                                           //время

            /*
             *          Calling isolationForestAlgorithm with input data, number of trees which is roughly taken to be
             *          20% of number of data points and sub sampling size which is taken as 10% of number of data points.
             * (входные (обучающие) данные, количество деревьев, размер подвыборки для ДР)
             */
            isolationForestAlgorithm isolationForestAlgorithm = new isolationForestAlgorithm();

            label1.Invoke((Action)(() => { label1.Text = "Обучение леса..."; }));

            dateTime = DateTime.Now;

            //Можно поиграть с параметрами
            List <Tree> forest = isolationForestAlgorithm.buildForest(dataTrain, 100, Convert.ToInt32(dataTrain.Count * 0.66));  //(data, data.size() / 5, data.size() / 10); //оригинал

            textBoxLog.Invoke((Action)(() =>
            {
                textBoxLog.Text += "Количество элементов на обучение" + dataTrain.Count;
                textBoxLog.Text += "Время обучения" + (DateTime.Now - dateTime);
            })); //Вывод времени обучения

            /*
             *          Calculating anomalyScore for each data point in input data. This is calculated for each data point
             *          by calculating the average of the path length for each point.
             */
            anomalyScore anomalyScore = new anomalyScore();

            dataGridView6.Invoke((Action)(() =>
            {
                dataGridView6.Columns.Add("columns6_Score", "Оценка аномалии");
                //dataGridView6.Columns.Add("columns6_flagAnomalii", "Флаг аномалии");
            })); //Добавление строки в таблицу

            int countDataTest = dataTest.Count;

            ocenkaAnomalii = new double[countDataTest];

            dateTime = DateTime.Now;

            for (int i = 0; i < countDataTest; i++)
            {
                ocenkaAnomalii[i] = anomalyScore.Calculating(forest, dataTest[i], countDataTest); //Оценка аномалии

                dataGridView6.Invoke((Action)(() =>
                {
                    dataGridView6.Rows[i].Cells[dataGridView6.Columns.Count - 1].Value = ocenkaAnomalii[i];
                })); //Добавление строки в таблицу

                label1.Invoke((Action)(() => { label1.Text = "Обработано данных:" + i + "/" + countDataTest; }));
                progressBar1.Invoke((Action)(() => { progressBar1.Value = i; }));
            }

            textBoxLog.Invoke((Action)(() =>
            {
                textBoxLog.Text += "Количесвто элементов на тестирование" + countDataTest;
                textBoxLog.Text += "Время тестирования" + (DateTime.Now - dateTime);
            })); //Вывод времени тестирования
        }