Exemplo n.º 1
0
        private async void TrainButtonClick(object sender, EventArgs e)
        {
            if (Controller.File == null)
            {
                BrakPlikuMessageBox();
                return;
            }

            switch (KlasyfikatorComboBox.SelectedIndex)
            {
            //2plik = 0.056 4plik = 0.066 [300k points]
            case 0:
                DisableChangeButtons();
                await Task.Run(() =>
                {
                    KNNClassifier = new KnnAccordClassifier(3);
                    if (!KNNClassifier.CanClassify)
                    {
                        var pointsToTrain     = Utills.GenerateClassArray(Controller.File.LasPointDataRecords, 0.066);
                        var inputOutputArrays = KnnAccordClassifier.MakeInputOutputs(pointsToTrain, Controller.File);
                        KNNClassifier.Teach(inputOutputArrays.Item1, inputOutputArrays.Item2);
                    }
                });

                EnableChangeButtons();
                break;

            case 1:
                DisableChangeButtons();
                await Task.Run(() =>
                {
                    ENNetwork = new EncogNeuralNetwork(Controller.File);
                });

                EnableChangeButtons();
                break;

            case 2:
                DisableChangeButtons();
                await Task.Run(() =>
                {
                    KNNClassifierQuick = new KnnAccordClassifierQuick(3);
                    if (!KNNClassifierQuick.CanClassify)
                    {
                        var inputOutputArrays =
                            KnnAccordClassifierQuick.MakeInputOutputs(Utills.GroupPointsList(
                                                                          Controller.File, OpenGlController.divisionCountX, OpenGlController.divisionCountY));
                        KNNClassifierQuick.TeachGroups(inputOutputArrays.Item1, inputOutputArrays.Item2);
                    }
                });

                EnableChangeButtons();
                break;

            case 3:
                DisableChangeButtons();
                await Task.Run(() =>
                {
                    ENNetworkQ = new EncogNeuralNetworkQuick(Controller.File, OpenGlController.divisionCountX, OpenGlController.divisionCountY);
                });

                EnableChangeButtons();
                break;

            case 4:
                DisableChangeButtons();
                await Task.Run(() =>
                {
                    KNNClassifierSlow = new KnnAccordClassifierSlow(3);
                    if (!KNNClassifierSlow.CanClassify)
                    {
                        var pointsToTrain     = Utills.GenerateClassArray(Controller.File.LasPointDataRecords, 0.10);
                        var inputOutputArrays = KnnAccordClassifierSlow.MakeInputOutputs(pointsToTrain, Controller.File);
                        KNNClassifierSlow.Teach(inputOutputArrays.Item1, inputOutputArrays.Item2);
                    }
                });

                EnableChangeButtons();
                break;

            case 5:
                DisableChangeButtons();
                await Task.Run(() =>
                {
                    ENNetworkS = new EncogNeuralNetworkSlow(Controller.File);
                });

                EnableChangeButtons();
                break;
            }
            KoniecTreninguMessageBox();
        }