private void Btn_rebuild_Click(object sender, RoutedEventArgs e)
        {
            if (filepath == "")
            {
                MessageBox.Show("Click on the green box above to open CSV file.", "CSV File not set", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            if (forest != null)
            {
                if (MessageBox.Show("This will create new forest, replacing the previous one.", "Confirmation", MessageBoxButton.OKCancel, MessageBoxImage.Warning) != MessageBoxResult.OK)
                {
                    return;
                }
            }

            btn_rebuild.IsEnabled = false;

            TrainingSet = CSVPreprocessor.CSVtoDataTable(filepath, ref TestSet, random);
            var nTree   = int.Parse(tbx_numTrees.Text.Replace(" ", "").TrimStart('0'));
            var nSample = int.Parse(tbx_numSamples.Text.Replace(" ", "").TrimStart('0'));

            RandomForest.OnCultivateStart += Forest_OnCultivateStart;
            forest = new RandomForest(TrainingSet, ref TestSet, nTree, nSample, 0);
            forest.OnCultivateFinished += Forest_OnCultivateFinished;
            forest.OnCultivateProgress += Forest_OnCultivateProgress;
            forest.OnVotingProgress    += Forest_OnVotingProgress;
        }
        private void Tbx_dataset_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (fd.ShowDialog() == true)
            {
                try
                {
                    var testDt = CSVPreprocessor.CSVtoDataTable(fd.FileName, ref TestSet, random);
                    tbx_numSamples.Text = Math.Round(testDt.Rows.Count * 0.7, 0).ToString();
                    tbx_dataset.Text    = Path.GetFileName(fd.FileName);
                    filepath            = fd.FileName;

                    btn_rebuild.IsEnabled = true;
                    txt_btm.Text          = "File loaded, click 'Build Forest' to create Model";
                }
                catch (Exception er)
                {
                    MessageBox.Show("Failed to load CSV file. Try another file.\n\nError msg: " + er.Message);
                }
            }
        }