Changeset 15103
- Timestamp:
- 07/01/17 08:23:22 (7 years ago)
- Location:
- trunk/sources/HeuristicLab.Algorithms.DataAnalysis.Views/3.4
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/GradientBoostedTreesModelView.Designer.cs
r14345 r15103 74 74 this.listBox.TabIndex = 1; 75 75 this.listBox.SelectedIndexChanged += new System.EventHandler(this.listBox_SelectedIndexChanged); 76 this.listBox.DoubleClick += new System.EventHandler(this.listBox_DoubleClick); 76 77 // 77 78 // GradientBoostedTreesModelView -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/GradientBoostedTreesModelView.cs
r14345 r15103 21 21 22 22 using System.Drawing; 23 using HeuristicLab.Common; 24 using HeuristicLab.Core; 23 25 using HeuristicLab.MainForm; 24 26 using HeuristicLab.Problems.DataAnalysis; … … 67 69 if (model == null) viewHost.Content = null; 68 70 else { 69 var treeModel = model as RegressionTreeModel; 70 if (treeModel != null) 71 viewHost.Content = treeModel.CreateSymbolicRegressionSolution(Content.ProblemData); 72 else { 73 var regModel = model as IRegressionModel; 74 viewHost.Content = regModel; 75 } 71 viewHost.Content = ConvertModel(model); 72 } 73 } 74 75 private void listBox_DoubleClick(object sender, System.EventArgs e) { 76 var selectedItem = listBox.SelectedItem; 77 if (selectedItem == null) return; 78 MainFormManager.MainForm.ShowContent(ConvertModel(selectedItem)); 79 } 80 81 private IContent ConvertModel(object model) { 82 var treeModel = model as RegressionTreeModel; 83 if (treeModel != null) 84 return treeModel.CreateSymbolicRegressionSolution(Content.ProblemData); 85 else { 86 var regModel = model as IRegressionModel; 87 return regModel; 76 88 } 77 89 } -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/RandomForestModelView.Designer.cs
r14345 r15103 79 79 this.listBox.TabIndex = 1; 80 80 this.listBox.SelectedIndexChanged += new System.EventHandler(this.listBox_SelectedIndexChanged); 81 this.listBox.DoubleClick += new System.EventHandler(this.listBox_DoubleClick); 81 82 // 82 83 // RandomForestModelView -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/RandomForestModelView.cs
r14345 r15103 19 19 */ 20 20 #endregion 21 21 using System; 22 22 using System.Drawing; 23 using HeuristicLab.Common; 23 24 using HeuristicLab.MainForm; 24 25 using HeuristicLab.Problems.DataAnalysis; … … 69 70 else { 70 71 var idx = (int)listBox.SelectedItem; 71 idx -= 1; 72 var rfModel = Content.Model as RandomForestModel; 73 var regProblemData = Content.ProblemData as IRegressionProblemData; 74 var classProblemData = Content.ProblemData as IClassificationProblemData; 75 if (rfModel != null) { 76 if (idx < 0 || idx >= rfModel.NumberOfTrees) return; 77 if (regProblemData != null) { 78 var syModel = new SymbolicRegressionModel(regProblemData.TargetVariable, rfModel.ExtractTree(idx), 79 new SymbolicDataAnalysisExpressionTreeLinearInterpreter()); 80 viewHost.Content = syModel.CreateRegressionSolution(regProblemData); 81 } else if (classProblemData != null) { 82 var syModel = new SymbolicDiscriminantFunctionClassificationModel(classProblemData.TargetVariable, rfModel.ExtractTree(idx), 83 new SymbolicDataAnalysisExpressionTreeLinearInterpreter(), new NormalDistributionCutPointsThresholdCalculator()); 84 syModel.RecalculateModelParameters(classProblemData, classProblemData.TrainingIndices); 85 viewHost.Content = syModel.CreateClassificationSolution(classProblemData); 86 } 87 } 72 viewHost.Content = CreateModel(idx); 88 73 } 74 } 75 76 private void listBox_DoubleClick(object sender, System.EventArgs e) { 77 var selectedItem = listBox.SelectedItem; 78 if (selectedItem == null) return; 79 var idx = (int)listBox.SelectedItem; 80 MainFormManager.MainForm.ShowContent(CreateModel(idx)); 81 } 82 83 private IContent CreateModel(int idx) { 84 idx -= 1; 85 var rfModel = Content.Model as RandomForestModel; 86 if (rfModel == null) return null; 87 var regProblemData = Content.ProblemData as IRegressionProblemData; 88 var classProblemData = Content.ProblemData as IClassificationProblemData; 89 if (idx < 0 || idx >= rfModel.NumberOfTrees) 90 return null; 91 if (regProblemData != null) { 92 var syModel = new SymbolicRegressionModel(regProblemData.TargetVariable, rfModel.ExtractTree(idx), 93 new SymbolicDataAnalysisExpressionTreeLinearInterpreter()); 94 return syModel.CreateRegressionSolution(regProblemData); 95 } else if (classProblemData != null) { 96 var syModel = new SymbolicDiscriminantFunctionClassificationModel(classProblemData.TargetVariable, rfModel.ExtractTree(idx), 97 new SymbolicDataAnalysisExpressionTreeLinearInterpreter(), new NormalDistributionCutPointsThresholdCalculator()); 98 syModel.RecalculateModelParameters(classProblemData, classProblemData.TrainingIndices); 99 return syModel.CreateClassificationSolution(classProblemData); 100 } else throw new InvalidProgramException(); 89 101 } 90 102 }
Note: See TracChangeset
for help on using the changeset viewer.