Changeset 17080 for trunk/HeuristicLab.Algorithms.DataAnalysis.DecisionTrees/3.4/DecisionTreeRegression.cs
- Timestamp:
- 07/05/19 11:08:57 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.Algorithms.DataAnalysis.DecisionTrees/3.4/DecisionTreeRegression.cs
r17079 r17080 38 38 [StorableType("FC8D8E5A-D16D-41BB-91CF-B2B35D17ADD7")] 39 39 [Creatable(CreatableAttribute.Categories.DataAnalysisRegression, Priority = 95)] 40 [Item(" M5RegressionTree", "A M5 regression tree / rule set")]41 public sealed class M5Regression : FixedDataAnalysisAlgorithm<IRegressionProblem> {40 [Item("Decision tree regression", "A regression tree / rule set learner")] 41 public sealed class DecisionTreeRegression : FixedDataAnalysisAlgorithm<IRegressionProblem> { 42 42 public override bool SupportsPause { 43 43 get { return true; } … … 135 135 #region Constructors and Cloning 136 136 [StorableConstructor] 137 private M5Regression(StorableConstructorFlag _) : base(_) { }138 private M5Regression(M5Regression original, Cloner cloner) : base(original, cloner) {137 private DecisionTreeRegression(StorableConstructorFlag _) : base(_) { } 138 private DecisionTreeRegression(DecisionTreeRegression original, Cloner cloner) : base(original, cloner) { 139 139 stateScope = cloner.Clone(stateScope); 140 140 } 141 public M5Regression() {141 public DecisionTreeRegression() { 142 142 var modelSet = new ItemSet<ILeafModel>(ApplicationManager.Manager.GetInstances<ILeafModel>()); 143 143 var pruningSet = new ItemSet<IPruning>(ApplicationManager.Manager.GetInstances<IPruning>()); … … 145 145 Parameters.Add(new FixedValueParameter<BoolValue>(GenerateRulesParameterName, "Whether a set of rules or a decision tree shall be created (default=false)", new BoolValue(false))); 146 146 Parameters.Add(new FixedValueParameter<PercentValue>(HoldoutSizeParameterName, "How much of the training set shall be reserved for pruning (default=20%).", new PercentValue(0.2))); 147 Parameters.Add(new ConstrainedValueParameter<ISplitter>(SplitterParameterName, "The type of split function used to create node splits (default=' M5Splitter').", splitterSet, splitterSet.OfType<M5Splitter>().First()));147 Parameters.Add(new ConstrainedValueParameter<ISplitter>(SplitterParameterName, "The type of split function used to create node splits (default='Splitter').", splitterSet, splitterSet.OfType<M5Splitter>().First())); 148 148 Parameters.Add(new FixedValueParameter<IntValue>(MinimalNodeSizeParameterName, "The minimal number of samples in a leaf node (default=1).", new IntValue(1))); 149 149 Parameters.Add(new ConstrainedValueParameter<ILeafModel>(LeafModelParameterName, "The type of model used for the nodes (default='LinearLeaf').", modelSet, modelSet.OfType<LinearLeaf>().First())); … … 155 155 } 156 156 public override IDeepCloneable Clone(Cloner cloner) { 157 return new M5Regression(this, cloner);157 return new DecisionTreeRegression(this, cloner); 158 158 } 159 159 #endregion … … 204 204 var doubleVars = new HashSet<string>(problemData.Dataset.DoubleVariables); 205 205 var vars = problemData.AllowedInputVariables.Concat(new[] {problemData.TargetVariable}).ToArray(); 206 if (vars.Any(v => !doubleVars.Contains(v))) throw new NotSupportedException(" M5regression supports only double valued input or output features.");206 if (vars.Any(v => !doubleVars.Contains(v))) throw new NotSupportedException("Decision tree regression supports only double valued input or output features."); 207 207 var doubles = vars.Select(v => problemData.Dataset.GetDoubleValues(v, problemData.TrainingIndices).ToArray()).ToArray(); 208 208 if (doubles.Any(v => v.Any(x => double.IsNaN(x) || double.IsInfinity(x)))) 209 throw new NotSupportedException(" M5regression does not support NaN or infinity values in the input dataset.");209 throw new NotSupportedException("Decision tree regression does not support NaN or infinity values in the input dataset."); 210 210 var trainingData = new Dataset(vars, doubles); 211 211 var pd = new RegressionProblemData(trainingData, problemData.AllowedInputVariables, problemData.TargetVariable); … … 283 283 var ruleSet = solution.Model as RegressionRuleSetModel; 284 284 if (ruleSet != null) { 285 results.Add(RegressionTreeAnalyzer.CreateRulesResult(ruleSet, problemData, " M5Rules", true));285 results.Add(RegressionTreeAnalyzer.CreateRulesResult(ruleSet, problemData, "Rules", true)); 286 286 frequencies = RegressionTreeAnalyzer.GetRuleVariableFrequences(ruleSet); 287 287 results.Add(RegressionTreeAnalyzer.CreateCoverageDiagram(ruleSet, problemData));
Note: See TracChangeset
for help on using the changeset viewer.