Exemple #1
0
        private void btnRun_Click(object sender, EventArgs e)
        {
            double param1Value, param2Value, param3Value;

            double[,] classprototypes;
            int k;

            SET_WAIT_CURSOR();

            param1Value = (double)this.numParam1.Value;
            param2Value = (double)this.numParam2.Value;
            param3Value = (double)this.numParam3.Value;

            if (DataSrc.HistoricalData.Constituents.Count > 0)
            {
                //If the population data is successfully retrieved
                if (BuildPopulationMatrix())
                {
                    //Run selected Algorithm
                    switch (AlgSelectList[algorithmSelectListBox.SelectedIndex])
                    {
                    case DefaultAlgorithm.K_MEANS:
                        if (param1Value > 0)
                        {
                            //Define the initial class prototypes as random points within feature space defined by the population
                            // this function limits the points to within a box defined by the min and max in each dimension plus _%
                            classprototypes = Helpers.XRandPointsInSpace((int)param1Value, PopulationToClassify);
                            k = Algorithms.k_means(PopulationToClassify, classprototypes, (int)param1Value, 5000, out PopulationClassLabels);
                        }
                        BindChartData(PopulationToClassify, PopulationClassLabels);
                        InsertClassColumn(PopulationClassLabels);
                        break;

                    case DefaultAlgorithm.FUZZY_C_MEANS:
                        if (param1Value > 0)
                        {
                            //Define the initial class prototypes as random points within feature space defined by the population
                            // this function limits the points to within a box defined by the min and max in each dimension plus _%
                            classprototypes = Helpers.XRandPointsInSpace((int)param1Value, PopulationToClassify);
                            k = Algorithms.fuzzy_c_means(PopulationToClassify, classprototypes, (int)param1Value, 2, 5000, out PopulationClassLabels);
                        }
                        BindChartData(PopulationToClassify, PopulationClassLabels);
                        InsertClassColumn(PopulationClassLabels);
                        break;

                    default:
                        break;
                    }
                }
            }

            CLEAR_WAIT_CURSOR();
        }