コード例 #1
0
        private void importLearnSolver(ArchiveLearnedSolver archSolver)
        {
            LearnedSolver solver = new LearnedSolver(archSolver);

            solver.save();
            archSolver.ID = solver.ID;
            importQualities(archSolver.Qualities, archSolver.ID);
        }
コード例 #2
0
        private void learnSolver()
        {
            foreach (LearningModel learningModel in LearningList)
            {
                TaskTemplate taskTemplate = (TaskTemplate)TaskTemplate.where (new Query("TaskTemplate").addTypeQuery(TypeQuery.select)
                                                                              .addCondition("Name", "=", learningModel.SelectedPreprocessing), typeof(TaskTemplate))[0];
                Selection selection = (Selection)Selection.where (new Query("Selection").addTypeQuery(TypeQuery.select)
                                                                  .addCondition("TaskTemplateID", "=", taskTemplate.ID.ToString())
                                                                  .addCondition("Name", "=", learningModel.SelectedSelection), typeof(Selection))[0];
                int countRows = selection.RowCount;
                LearningScenario learningScenario = (LearningScenario)LearningScenario.where (new Query("LearningScenario").addTypeQuery(TypeQuery.select)
                                                                                              .addCondition("Name", "=", learningModel.SelectedScenario), typeof(LearningScenario))[0];

                List <Entity> selectionRows = SelectionRow.where (new Query("SelectionRow").addTypeQuery(TypeQuery.select)
                                                                  .addCondition("SelectionID", "=", selection.ID.ToString()), typeof(SelectionRow));
                List <Entity> parameters = dms.models.Parameter.where (new Query("Parameter").addTypeQuery(TypeQuery.select)
                                                                       .addCondition("TaskTemplateID", "=", selection.TaskTemplateID.ToString()), typeof(dms.models.Parameter));
                int       stepRow    = 0;
                float[][] inputData  = new float[countRows][];
                float[]   outputData = new float[countRows];
                for (int i = 0; i < countRows; i++)
                {
                    inputData[i] = new float[parameters.Count - 1];
                }
                int outputParam = 0;
                for (int i = 0; i < parameters.Count; i++)
                {
                    if (((models.Parameter)parameters[i]).IsOutput == 1)
                    {
                        outputParam = parameters[i].ID;
                    }
                }

                string[][] vals  = Selection.valuesOfSelectionId(selection.ID);
                float[][]  fvals = new float[selection.RowCount][];
                for (int i = 0; i < selection.RowCount; i++)
                {
                    fvals[i] = new float[parameters.Count];
                    for (int j = 0; j < parameters.Count - 1; j++)
                    {
                        inputData[i][j] = float.Parse(vals[i][j].Replace(".", ","));
                    }
                    outputData[i] = float.Parse(vals[i][parameters.Count - 1].Replace(".", ","));
                }
                ISolver isolver = null;
                if (Solver.Description is PerceptronTopology)
                {
                    PerceptronTopology topology = Solver.Description as PerceptronTopology;
                    isolver = new PerceptronManaged(topology);
                }
                else if (Solver.Description is ConvNNTopology)
                {
                    ConvNNTopology topology = Solver.Description as ConvNNTopology;
                    isolver = new ConvNNManaged(topology);
                }
                else if (Solver.Description is WardNNTopology)
                {
                    WardNNTopology topology = Solver.Description as WardNNTopology;
                    isolver = new WardNNManaged(topology);
                }
                else if (Solver.Description is KohonenNNTopology)
                {
                    KohonenNNTopology topology = Solver.Description as KohonenNNTopology;
                    isolver = new KohonenManaged(topology);
                }
                else if (Solver.Description is TreeDescription)
                {
                    TreeDescription topology = Solver.Description as TreeDescription;
                    isolver = new DecisionTree(topology);
                }
                else if (Solver.Description is TreeDescriptionC4_5)
                {
                    TreeDescriptionC4_5 topology = Solver.Description as TreeDescriptionC4_5;
                    isolver = new DecisionTreeC4_5(topology);
                }
                else
                {
                    throw new EntryPointNotFoundException();
                }
                SeparationOfDataSet s  = new SeparationOfDataSet(isolver, learningScenario, inputData, outputData);
                LearnedSolver       ls = new LearnedSolver()
                {
                    SelectionID        = selection.ID,
                    LearningScenarioID = learningScenario.ID,
                    TaskSolverID       = Solver.ID,
                    Soul = s.separationAndLearn(selection.ID, outputParam)
                };
                ls.save();

                LearningQuality lq = new LearningQuality()
                {
                    LearnedSolverID = ls.ID,
                    MistakeTrain    = Convert.ToInt32(s.MistakeTrain),
                    MistakeTest     = Convert.ToInt32(s.MistakeTest),
                    ClosingError    = s.ClosingError
                };
                lq.save();
            }
            OnClose?.Invoke(this, null);
        }
コード例 #3
0
        private void learnSolver()
        {
            foreach (LearningModel learningModel in LearningList)
            {
                TaskTemplate taskTemplate = (TaskTemplate)TaskTemplate.where (new Query("TaskTemplate").addTypeQuery(TypeQuery.select)
                                                                              .addCondition("Name", "=", learningModel.SelectedPreprocessing), typeof(TaskTemplate))[0];
                Selection selection = (Selection)Selection.where (new Query("Selection").addTypeQuery(TypeQuery.select)
                                                                  .addCondition("TaskTemplateID", "=", taskTemplate.ID.ToString())
                                                                  .addCondition("Name", "=", learningModel.SelectedSelection), typeof(Selection))[0];
                int countRows = selection.RowCount;
                LearningScenario learningScenario = (LearningScenario)LearningScenario.where (new Query("LearningScenario").addTypeQuery(TypeQuery.select)
                                                                                              .addCondition("Name", "=", learningModel.SelectedScenario), typeof(LearningScenario))[0];

                List <Entity> selectionRows = SelectionRow.where (new Query("SelectionRow").addTypeQuery(TypeQuery.select)
                                                                  .addCondition("SelectionID", "=", selection.ID.ToString()), typeof(SelectionRow));
                List <Entity> parameters = dms.models.Parameter.where (new Query("Parameter").addTypeQuery(TypeQuery.select)
                                                                       .addCondition("TaskTemplateID", "=", selection.TaskTemplateID.ToString()), typeof(dms.models.Parameter));
                int       stepRow    = 0;
                float[][] inputData  = new float[countRows][];
                float[]   outputData = new float[countRows];
                for (int i = 0; i < countRows; i++)
                {
                    inputData[i] = new float[parameters.Count - 1];
                }
                int outputParam = 0;
                foreach (Entity selRow in selectionRows)
                {
                    int selectionRowId = selRow.ID;
                    int stepParam      = 0;
                    foreach (Entity param in parameters)
                    {
                        int           paramId = param.ID;
                        List <Entity> value   = ValueParameter.where (new Query("ValueParameter").addTypeQuery(TypeQuery.select)
                                                                      .addCondition("ParameterID", "=", paramId.ToString()).
                                                                      addCondition("SelectionRowID", "=", selectionRowId.ToString()), typeof(ValueParameter));
                        if (((dms.models.Parameter)param).IsOutput == 1)
                        {
                            outputParam = param.ID;
                            string outputValue = ((ValueParameter)value[0]).Value;
                            float  outputFloat;
                            if (float.TryParse(outputValue, out outputFloat))
                            {
                                outputData[stepRow] = outputFloat;
                            }
                        }
                        else
                        {
                            inputData[stepRow][stepParam] = float.Parse(((ValueParameter)value[0]).Value, CultureInfo.InvariantCulture.NumberFormat);
                        }
                        stepParam++;
                    }
                    stepRow++;
                }
                ISolver isolver = null;
                if (Solver.Description is PerceptronTopology)
                {
                    PerceptronTopology topology = Solver.Description as PerceptronTopology;
                    isolver = new PerceptronManaged(topology);
                }
                else if (Solver.Description is ConvNNTopology)
                {
                    ConvNNTopology topology = Solver.Description as ConvNNTopology;
                    isolver = new ConvNNManaged(topology);
                }
                else if (Solver.Description is WardNNTopology)
                {
                    WardNNTopology topology = Solver.Description as WardNNTopology;
                    isolver = new WardNNManaged(topology);
                }
                else if (Solver.Description is TreeDescription)
                {
                    TreeDescription topology = Solver.Description as TreeDescription;
                    isolver = new DecisionTree(topology);
                }
                else
                {
                    throw new EntryPointNotFoundException();
                }
                SeparationOfDataSet s  = new SeparationOfDataSet(isolver, learningScenario, inputData, outputData);
                LearnedSolver       ls = new LearnedSolver()
                {
                    SelectionID        = selection.ID,
                    LearningScenarioID = learningScenario.ID,
                    TaskSolverID       = Solver.ID,
                    Soul = s.separationAndLearn(selection.ID, outputParam)
                };
                ls.save();

                LearningQuality lq = new LearningQuality()
                {
                    LearnedSolverID = ls.ID,
                    MistakeTrain    = Convert.ToInt32(s.MistakeTrain),
                    MistakeTest     = Convert.ToInt32(s.MistakeTest),
                    ClosingError    = s.ClosingError
                };
                lq.save();
            }
            OnClose?.Invoke(this, null);
        }