Exemplo n.º 1
0
        private async Task LoadFileInfoAsync()
        {
            var dataFileInfoArr = await DataFilesStorageCtrl.GetDataFilesInfoAsync();

            var pDataFilesInfoArr = await PDataFilesStorageCtrl.GetFilesInfoAsync();

            Cmb_dataFileName.ItemsSource          = dataFileInfoArr.Select(e => e.FileName).ToArray();
            Cmb_testDataFileName.ItemsSource      = dataFileInfoArr.Select(e => e.FileName).ToArray();
            Cmb_processedDataFileName.ItemsSource = pDataFilesInfoArr.Select(e => e.FileName).ToArray();
        }
        private async void CreateDataFile(object sender, RoutedEventArgs e)
        {
            var result = InputDialogBox.Show("Please enter the name of the new data file!", "My title");

            if (result != null && result.ClickedBtn == InputDialogBoxButton.Okay &&
                !string.IsNullOrWhiteSpace(result.InputString))
            {
                await DataFilesStorageCtrl.CreateDataFileAsync(result.InputString);
                await LoadFileInfoAsync();
            }
        }
        private async Task LoadFileInfoAsync()
        {
            var fileInfoArr = await DataFilesStorageCtrl.GetDataFilesInfoAsync();

            var modelFilesInfoArr = await ModelFilesStorageController.GetModelFilesInfoAsync();

            var lst = modelFilesInfoArr.Select(e => e.FileName).ToList();

            lst.Add("DefaultSelector");

            cmb_dataFileName.ItemsSource    = fileInfoArr.Select(e => e.FileName).ToArray();
            cmb_modelFileName.ItemsSource   = lst;
            cmb_modelFileName.SelectedIndex = lst.Count - 1;
        }
Exemplo n.º 4
0
        private async Task StartAsync()
        {
            var dataFileName      = Cmb_dataFileName.SelectedValue.ToString();
            var pDataFileName     = Cmb_processedDataFileName.SelectedValue.ToString();
            var modelFileName     = Txt_modelFileName.Text;
            var testPDataFileName = Cmb_testDataFileName.SelectedValue.ToString();

            if (string.IsNullOrWhiteSpace(dataFileName) || string.IsNullOrWhiteSpace(pDataFileName) ||
                string.IsNullOrWhiteSpace(modelFileName) || string.IsNullOrWhiteSpace(testPDataFileName))
            {
                throw new InvalidOperationException("Carefully select all the required values");
            }

            try
            {
                EnableControls(false);
                if (ModelFilesStorageCtrl.Exists(modelFileName))
                {
                    throw new InvalidOperationException("FAE");
                }
                if (!DataFilesStorageCtrl.Exists(dataFileName))
                {
                    throw new InvalidOperationException("DFDNE");
                }
                if (!DataFilesStorageCtrl.Exists(testPDataFileName))
                {
                    throw new InvalidOperationException("TDFDNE");
                }

                if (dataFileName == testPDataFileName)
                {
                    throw new InvalidOperationException("SameName");
                }

                TrainerCtrl.OnPhaseChangedEvent   += OnTrainerPhaseChanged;
                TrainerCtrl.OnPreprocessorChanged += OnPreprocessorChanged;

                await TrainerCtrl.Start(options =>
                {
                    options.DataFileName          = dataFileName;
                    options.ProcessedDataFileName = pDataFileName;
                    options.MLModelFileName       = modelFileName;
                    options.TestDataFileName      = testPDataFileName;
                });
            }
            catch (InvalidOperationException ex)
            {
                if (ex.Message == "FAE")
                {
                    MessageBox.Show(
                        "ML file already exists. Use a different name",
                        "File already exists",
                        MessageBoxButton.OK,
                        MessageBoxImage.Stop);
                }
                else if (ex.Message == "DFDNE")
                {
                    MessageBox.Show(
                        "Data file does not exists",
                        "File not found",
                        MessageBoxButton.OK,
                        MessageBoxImage.Stop);
                }
                else if (ex.Message == "TDFDNE")
                {
                    MessageBox.Show(
                        "Test data file does not exists",
                        "File not found",
                        MessageBoxButton.OK,
                        MessageBoxImage.Stop);
                }
                else if (ex.Message == "SameName")
                {
                    MessageBox.Show(
                        "Data file and the test data file cannot have the same name",
                        "File not found",
                        MessageBoxButton.OK,
                        MessageBoxImage.Stop);
                }
                else
                {
                    MessageBox.Show("Unexpected error occured", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unexpected error occured", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                EnableControls();
            }
        }