예제 #1
0
 private void Analyze_button_Click(object sender, EventArgs e)
 {
     if (TimePeriod_comboBox.SelectedIndex > -1)
     {
         if (uint.TryParse(FileNumber_textBox.Text, out uint number))
         {
             if (DataFromFile.ReadFromFile(TimePeriod_comboBox.SelectedItem.ToString(), number.ToString(),
                                           out List <string> readDataList))
             {
                 Plot_Form form = new Plot_Form(readDataList, this);
                 form.Show();
                 Hide();
             }
             else
             {
                 FileNumber_textBox.Clear();
                 MessageBox.Show("There is no such document");
             }
         }
         else
         {
             FileNumber_textBox.Clear();
             MessageBox.Show("This value should be integer");
         }
     }
     else
     {
         MessageBox.Show("Select document time period from combobox");
     }
 }
        private void PlotDrawing_timer_Tick(object sender, EventArgs e)
        {
            if (rebuiltPlot)
            {
                pane.CurveList.Clear();

                pane.YAxis.Title.Text = PlotBasedOn_comboBox.SelectedItem.ToString();

                var variablePair = DataFromFile.ParseSelectedColumn(PlotBasedOn_comboBox.SelectedItem.ToString(), InputDataList);

                if (NormalizedData_CheckBox.Checked)
                {
                    Algorithm.InputDataNormalization(ref variablePair);
                    pane.YAxis.Scale.Min = -0.1;
                    pane.YAxis.Scale.Max = 1.1;
                }
                else
                {
                    pane.YAxis.Scale.MinAuto = true;
                    pane.YAxis.Scale.MaxAuto = true;
                }

                Dictionary <double, double> resultOfClassification = new Dictionary <double, double>();

                if (BayesClassifier_checkBox.Checked)
                {
                    resultOfClassification = Algorithm.BayesClassifier(InputDataList);
                }

                if (!OnlyDots_CheckBox.Checked)
                {
                    PointPairList func = new PointPairList(Algorithm.PolynomialRegresion(variablePair, 3));

                    LineItem myCurve = pane.AddCurve("Polynomial Regression", func, Color.Red, SymbolType.None);
                }

                PointPairList dotsRed   = new PointPairList();
                PointPairList dotsGreen = new PointPairList();

                foreach (var pair in variablePair)
                {
                    if (resultOfClassification.TryGetValue(pair.Key, out double value) && Math.Round(value * 10) == 1)
                    {
                        dotsRed.Add(pair.Key, pair.Value);
                    }
                    else
                    {
                        dotsGreen.Add(pair.Key, pair.Value);
                    }
                }

                LineItem myDotsRed   = pane.AddCurve(null, dotsRed, Color.Red, SymbolType.Diamond);
                LineItem myDotsGreen = pane.AddCurve(null, dotsGreen, Color.Green, SymbolType.Diamond);

                myDotsRed.Symbol.Fill.Type   = FillType.Solid;
                myDotsRed.Symbol.Size        = 3;
                myDotsRed.Line.IsVisible     = false;
                myDotsGreen.Symbol.Fill.Type = FillType.Solid;
                myDotsGreen.Symbol.Size      = 3;
                myDotsGreen.Line.IsVisible   = false;

                pane.XAxis.Scale.Min = -20;
                pane.XAxis.Scale.Max = 750;

                pane.AxisChange();

                Plot_zedGraph.Refresh();

                rebuiltPlot = false;
            }
        }