コード例 #1
0
        private void btnEvaluateFile_Click(object sender, EventArgs e)
        {
            if (!File.Exists(txtEvaluationFile.Text))
            {
                MessageBox.Show("Chemin invalide");
                return;
            }

            var rawDataset        = new DrugDataset();
            var normalizedDataset = new DrugDataset();

            var rawLines = File.ReadAllLines(txtEvaluationFile.Text).Select(x => x.Split(',')).ToList();
            var lines    = File.ReadAllLines(txtEvaluationFile.Text).Select(x => x.Split(',')).ToList();

            Logger.LogMessage($"All lines were read from evaluation file ${txtEvaluationFile.Text}");

            try
            {
                rawDataset.CreateDataset(rawLines);
                normalizedDataset.CreateDataset(lines);
            }
            catch (Exception ex)
            {
                Logger.LogError($"Error happened while creating Dataset: ${ex.Message}");
            }

            normalizedDataset.CleanAllColumns();

            DecisionTreePrediction prediction = new DecisionTreePrediction(rawDataset, normalizedDataset, _tree);

            prediction.Predict();
        }
コード例 #2
0
ファイル: FormData.cs プロジェクト: Mezion/WhatsYourAddiction
        private void CreateDataset()
        {
            var lines = File.ReadAllLines(_csvFile).Select(x => x.Split(',')).ToList();

            Logger.LogMessage($"All lines were read from file ${_csvFile}");

            try
            {
                _drugDataset.CreateDataset(lines);
            }
            catch (Exception ex)
            {
                Logger.LogError($"Error happened while creating Dataset: ${ex.Message}");
            }

            dataGridView1.DataSource = _drugDataset.DrugDataTable;
        }
コード例 #3
0
        private DrugDataset CreateFilteredDataset(DrugDataset fromDataset, string filterExpression)
        {
            var dataRows = fromDataset.DrugDataTable.Select(filterExpression);

            var rows = new List <string[]>();

            rows.Add(_dataset.Columns.ToArray());

            foreach (var dataRow in dataRows)
            {
                rows.Add(dataRow.ItemArray.Select(i => i.ToString()).ToArray());
            }

            var newDataset = new DrugDataset();

            newDataset.CreateDataset(rows);

            return(newDataset);
        }
コード例 #4
0
ファイル: FormKnn.cs プロジェクト: Mezion/WhatsYourAddiction
        private void btnEvaluateFile_Click(object sender, EventArgs e)
        {
            if (!File.Exists(txtEvaluationFile.Text))
            {
                MessageBox.Show("Chemin invalide");
                return;
            }

            int neighborInConsideration = 0;

            if (!int.TryParse(txtNbNeighbor.Text, out neighborInConsideration) || neighborInConsideration <= 0)
            {
                MessageBox.Show("Le nombre de voisin à prendre en considération est invalide");
                return;
            }


            var columnsInConsideration = new List <string>();

            for (int i = 0; i < checkedListBox1.Items.Count; i++)
            {
                if (checkedListBox1.GetItemCheckState(i) == CheckState.Checked)
                {
                    columnsInConsideration.Add(checkedListBox1.Items[i].ToString());
                }
            }

            if (columnsInConsideration.Contains("Nicotine"))
            {
                MessageBox.Show("Les colonnes en considération ne peuvent pas contenir la colonne Nicotine");
                return;
            }

            var dataset = new DrugDataset();

            var lines = File.ReadAllLines(txtEvaluationFile.Text).Select(x => x.Split(',')).ToList();

            Logger.LogMessage($"All lines were read from evaluation file ${txtEvaluationFile.Text}");

            try
            {
                dataset.CreateDataset(lines);
            }
            catch (Exception ex)
            {
                Logger.LogError($"Error happened while creating Dataset: ${ex.Message}");
            }

            KNNInterpretation interpretation = KNNInterpretation.Mode;

            if (rbMediane.Checked)
            {
                interpretation = KNNInterpretation.Median;
            }
            else if (rbMode.Checked)
            {
                interpretation = KNNInterpretation.Mode;
            }
            else if (rbMoyenne.Checked)
            {
                interpretation = KNNInterpretation.Mean;
            }

            Logger.BringToFront();
            _knn2 = new KNN2(_drugDataset, columnsInConsideration, dataset, neighborInConsideration, interpretation);
        }