コード例 #1
0
ファイル: MainForm.cs プロジェクト: qwad1000/NEFClassLib
        private void selectLearningDatasetFileButton_Click(object sender, EventArgs e)
        {
            if (trainDatasetFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string filename = trainDatasetFileDialog.FileName;
                
                learningDatasetFileTExtBox.Text = filename;
                trainDataset = new NCDataSet(filename);

                learningDatasetSizeTextBox.Text = trainDataset.Length.ToString();
                learningDatasetAttrsCountTextBox.Text = trainDataset.Dimension.ToString();
                learningDatasetClassesCountTextBox.Text = trainDataset.GetClassesList().Length.ToString();

                classesListView.Clear();
                foreach (string cls in trainDataset.GetClassesList())
                    classesListView.Items.Add(cls);

                sectionsDataGridView.Rows.Clear();
                for (int i = 0; i < trainDataset.Dimension; ++i)
                {
                    sectionsDataGridView.Rows.Add();
                    sectionsDataGridView.Rows[i].Cells[0].Value = "x" + (i + 1).ToString();
                    sectionsDataGridView.Rows[i].Cells[1].Value = 3;
                }

                trainButton.Enabled = true;
            }
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: qwad1000/NEFClassLib
        private void checkButton_Click(object sender, EventArgs e)
        {
            if (checkFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string filename = checkFileDialog.FileName;

                NCDataSet dataset = new NCDataSet(filename);

                int goodCount = 0;
                double rmse = 0;
                for (int i = 0; i < dataset.Length; ++i)
                {
                    string result = network.Classify(dataset[i]);
                    if (dataset[i].Class == result)
                        ++goodCount;

                    double[] desiredOutput = new double[dataset.GetClassesList().Length];
                    desiredOutput[network.GetClassIndex(dataset[i].Class)] = 1;
                    double[] output = network.GetOutput(dataset[i]);

                    for (int z = 0; z < output.Length; ++z)
                        rmse += (desiredOutput[z] - output[z]) * (desiredOutput[z] - output[z]);
                }

                rmse /= dataset.Length;

                string results = String.Format("Размер выборки: {0}\nТочность: {1}%\nНеудачных попыток: {2}\nError: {3}", dataset.Length, (goodCount * 100.0 / dataset.Length).ToString("0.##"), dataset.Length - goodCount, rmse.ToString("0.##"));
                MessageBox.Show(results, "Результаты");
            }
        }