Changeset 17080
- Timestamp:
- 07/05/19 11:08:57 (5 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab 3.3.sln
r17079 r17080 468 468 EndProject 469 469 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.ExactOptimization.Views-3.3", "HeuristicLab.ExactOptimization.Views\3.3\HeuristicLab.ExactOptimization.Views-3.3.csproj", "{D1D69043-17E6-4B8C-BF41-0799C7E56032}" 470 EndProject471 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Algorithms.DataAnalysis.M5-3.4", "HeuristicLab.Algorithms.DataAnalysis.M5\3.4\HeuristicLab.Algorithms.DataAnalysis.M5-3.4.csproj", "{CCC5D1F9-0551-4BF3-8898-E4C44B52E5A6}"472 470 EndProject 473 471 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Algorithms.DataAnalysis.DecisionTrees-3.4", "HeuristicLab.Algorithms.DataAnalysis.DecisionTrees\3.4\HeuristicLab.Algorithms.DataAnalysis.DecisionTrees-3.4.csproj", "{541A53F3-E6A7-402F-91BB-D76041CDD9FD}" … … 2283 2281 {D1D69043-17E6-4B8C-BF41-0799C7E56032}.Release|x86.ActiveCfg = Release|x86 2284 2282 {D1D69043-17E6-4B8C-BF41-0799C7E56032}.Release|x86.Build.0 = Release|x86 2285 {CCC5D1F9-0551-4BF3-8898-E4C44B52E5A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU2286 {CCC5D1F9-0551-4BF3-8898-E4C44B52E5A6}.Debug|Any CPU.Build.0 = Debug|Any CPU2287 {CCC5D1F9-0551-4BF3-8898-E4C44B52E5A6}.Debug|x64.ActiveCfg = Debug|Any CPU2288 {CCC5D1F9-0551-4BF3-8898-E4C44B52E5A6}.Debug|x64.Build.0 = Debug|Any CPU2289 {CCC5D1F9-0551-4BF3-8898-E4C44B52E5A6}.Debug|x86.ActiveCfg = Debug|Any CPU2290 {CCC5D1F9-0551-4BF3-8898-E4C44B52E5A6}.Debug|x86.Build.0 = Debug|Any CPU2291 {CCC5D1F9-0551-4BF3-8898-E4C44B52E5A6}.Release|Any CPU.ActiveCfg = Release|Any CPU2292 {CCC5D1F9-0551-4BF3-8898-E4C44B52E5A6}.Release|Any CPU.Build.0 = Release|Any CPU2293 {CCC5D1F9-0551-4BF3-8898-E4C44B52E5A6}.Release|x64.ActiveCfg = Release|Any CPU2294 {CCC5D1F9-0551-4BF3-8898-E4C44B52E5A6}.Release|x64.Build.0 = Release|Any CPU2295 {CCC5D1F9-0551-4BF3-8898-E4C44B52E5A6}.Release|x86.ActiveCfg = Release|Any CPU2296 {CCC5D1F9-0551-4BF3-8898-E4C44B52E5A6}.Release|x86.Build.0 = Release|Any CPU2297 2283 {541A53F3-E6A7-402F-91BB-D76041CDD9FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 2298 2284 {541A53F3-E6A7-402F-91BB-D76041CDD9FD}.Debug|Any CPU.Build.0 = Debug|Any CPU -
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)); -
trunk/HeuristicLab.Algorithms.DataAnalysis.DecisionTrees/3.4/HeuristicLab.Algorithms.DataAnalysis.DecisionTrees-3.4.csproj
r17079 r17080 68 68 <ItemGroup> 69 69 <Compile Include="DecisionTreeRegression.cs" /> 70 <Compile Include="Interfaces\IDecisionTreeModel.cs" /> 70 71 <Compile Include="Interfaces\ILeafModel.cs" /> 71 <Compile Include="Interfaces\IM5Model.cs" />72 72 <Compile Include="Interfaces\IPruning.cs" /> 73 73 <Compile Include="Interfaces\ISplitter.cs" /> … … 79 79 <Compile Include="LeafTypes\ConstantLeaf.cs" /> 80 80 <Compile Include="LeafTypes\GaussianProcessLeaf.cs" /> 81 <Compile Include="LeafTypes\Leaf.cs" /> 81 82 <Compile Include="LeafTypes\LeafBase.cs" /> 82 83 <Compile Include="LeafTypes\LinearLeaf.cs" /> 83 <Compile Include="LeafTypes\M5Leaf.cs" /> 84 <Compile Include="LeafTypes\M5regLeaf.cs" /> 84 <Compile Include="LeafTypes\RegularizedLeaf.cs" /> 85 85 <Compile Include="MetaModels\RegressionNodeModel.cs" /> 86 86 <Compile Include="MetaModels\RegressionNodeTreeModel.cs" /> … … 93 93 <Compile Include="Splitting\CorrelationImpurityCalculator.cs" /> 94 94 <Compile Include="Splitting\CorrelationSplitter.cs" /> 95 <Compile Include="Splitting\M5Splitter.cs" />96 95 <Compile Include="Splitting\NeumaierSum.cs" /> 97 96 <Compile Include="Splitting\OrderImpurityCalculator.cs" /> 97 <Compile Include="Splitting\Splitter.cs" /> 98 98 <Compile Include="Splitting\SplitterBase.cs" /> 99 99 <Compile Include="Splitting\UnivariateOnlineLR.cs" /> -
trunk/HeuristicLab.Algorithms.DataAnalysis.DecisionTrees/3.4/LeafTypes/LeafBase.cs
r16847 r17080 72 72 73 73 public void Build(RegressionNodeTreeModel tree, IReadOnlyList<int> trainingRows, IScope stateScope, CancellationToken cancellationToken) { 74 var parameters = (RegressionTreeParameters)stateScope.Variables[ M5Regression.RegressionTreeParameterVariableName].Value;74 var parameters = (RegressionTreeParameters)stateScope.Variables[DecisionTreeRegression.RegressionTreeParameterVariableName].Value; 75 75 var state = (LeafBuildingState)stateScope.Variables[LeafBuildingStateVariableName].Value; 76 76 -
trunk/HeuristicLab.Algorithms.DataAnalysis.DecisionTrees/3.4/LeafTypes/LinearLeaf.cs
r16852 r17080 30 30 namespace HeuristicLab.Algorithms.DataAnalysis { 31 31 [StorableType("347CA25D-FB37-4C4F-9B61-9D79288B2B28")] 32 [Item("LinearLeaf", "A leaf type that uses linear models as leaf models. This is the standard for M5'regression")]32 [Item("LinearLeaf", "A leaf type that uses linear models as leaf models. This is the standard for decision tree regression")] 33 33 public class LinearLeaf : LeafBase { 34 34 #region Constructors & Cloning -
trunk/HeuristicLab.Algorithms.DataAnalysis.DecisionTrees/3.4/MetaModels/RegressionNodeTreeModel.cs
r16847 r17080 71 71 #region IM5Model 72 72 public void Build(IReadOnlyList<int> trainingRows, IReadOnlyList<int> pruningRows, IScope statescope, ResultCollection results, CancellationToken cancellationToken) { 73 var regressionTreeParams = (RegressionTreeParameters)statescope.Variables[ M5Regression.RegressionTreeParameterVariableName].Value;73 var regressionTreeParams = (RegressionTreeParameters)statescope.Variables[DecisionTreeRegression.RegressionTreeParameterVariableName].Value; 74 74 //start with one node 75 75 if (Root == null) … … 87 87 88 88 public void Update(IReadOnlyList<int> rows, IScope statescope, CancellationToken cancellationToken) { 89 var regressionTreeParams = (RegressionTreeParameters)statescope.Variables[ M5Regression.RegressionTreeParameterVariableName].Value;89 var regressionTreeParams = (RegressionTreeParameters)statescope.Variables[DecisionTreeRegression.RegressionTreeParameterVariableName].Value; 90 90 regressionTreeParams.LeafModel.Build(this, rows, statescope, cancellationToken); 91 91 } 92 92 93 93 public static void Initialize(IScope stateScope) { 94 var param = (RegressionTreeParameters)stateScope.Variables[ M5Regression.RegressionTreeParameterVariableName].Value;94 var param = (RegressionTreeParameters)stateScope.Variables[DecisionTreeRegression.RegressionTreeParameterVariableName].Value; 95 95 stateScope.Variables.Add(new Variable(RootVariableName, RegressionNodeModel.CreateNode(param.TargetVariable, param))); 96 96 } … … 98 98 99 99 public void BuildModel(IReadOnlyList<int> trainingRows, IReadOnlyList<int> pruningRows, IScope statescope, ResultCollection results, CancellationToken cancellationToken) { 100 var regressionTreeParams = (RegressionTreeParameters)statescope.Variables[ M5Regression.RegressionTreeParameterVariableName].Value;100 var regressionTreeParams = (RegressionTreeParameters)statescope.Variables[DecisionTreeRegression.RegressionTreeParameterVariableName].Value; 101 101 //start with one node 102 102 Root = RegressionNodeModel.CreateNode(regressionTreeParams.TargetVariable, regressionTreeParams); -
trunk/HeuristicLab.Algorithms.DataAnalysis.DecisionTrees/3.4/MetaModels/RegressionRuleModel.cs
r16847 r17080 83 83 84 84 public void Build(IReadOnlyList<int> trainingRows, IReadOnlyList<int> pruningRows, IScope statescope, ResultCollection results, CancellationToken cancellationToken) { 85 var regressionTreeParams = (RegressionTreeParameters)statescope.Variables[ M5Regression.RegressionTreeParameterVariableName].Value;85 var regressionTreeParams = (RegressionTreeParameters)statescope.Variables[DecisionTreeRegression.RegressionTreeParameterVariableName].Value; 86 86 variables = regressionTreeParams.AllowedInputVariables.ToList(); 87 87 … … 109 109 110 110 public void Update(IReadOnlyList<int> rows, IScope statescope, CancellationToken cancellationToken) { 111 var regressionTreeParams = (RegressionTreeParameters)statescope.Variables[ M5Regression.RegressionTreeParameterVariableName].Value;111 var regressionTreeParams = (RegressionTreeParameters)statescope.Variables[DecisionTreeRegression.RegressionTreeParameterVariableName].Value; 112 112 int np; 113 113 RuleModel = regressionTreeParams.LeafModel.BuildModel(rows, regressionTreeParams, cancellationToken, out np); -
trunk/HeuristicLab.Algorithms.DataAnalysis.DecisionTrees/3.4/MetaModels/RegressionRuleSetModel.cs
r16847 r17080 77 77 #region IM5Model 78 78 public void Build(IReadOnlyList<int> trainingRows, IReadOnlyList<int> pruningRows, IScope stateScope, ResultCollection results, CancellationToken cancellationToken) { 79 var regressionTreeParams = (RegressionTreeParameters)stateScope.Variables[ M5Regression.RegressionTreeParameterVariableName].Value;79 var regressionTreeParams = (RegressionTreeParameters)stateScope.Variables[DecisionTreeRegression.RegressionTreeParameterVariableName].Value; 80 80 var ruleSetState = (RuleSetState)stateScope.Variables[RuleSetStateVariableName].Value; 81 81 -
trunk/HeuristicLab.Algorithms.DataAnalysis.DecisionTrees/3.4/Pruning/ComplexityPruning.cs
r16847 r17080 86 86 87 87 public void Prune(RegressionNodeTreeModel treeModel, IReadOnlyList<int> trainingRows, IReadOnlyList<int> pruningRows, IScope statescope, CancellationToken cancellationToken) { 88 var regressionTreeParams = (RegressionTreeParameters)statescope.Variables[ M5Regression.RegressionTreeParameterVariableName].Value;88 var regressionTreeParams = (RegressionTreeParameters)statescope.Variables[DecisionTreeRegression.RegressionTreeParameterVariableName].Value; 89 89 var state = (PruningState)statescope.Variables[PruningStateVariableName].Value; 90 90 -
trunk/HeuristicLab.Algorithms.DataAnalysis.DecisionTrees/3.4/Splitting/Splitter.cs
r17079 r17080 30 30 namespace HeuristicLab.Algorithms.DataAnalysis { 31 31 [StorableType("502B1429-7A28-45C1-A60A-93E72CB3AF4A")] 32 [Item(" M5Splitter", "A split selector that uses the ratio between Variances^(1/Order) to determine good splits.")]32 [Item("Splitter", "A split selector that uses the ratio between Variances^(1/Order) to determine good splits.")] 33 33 public sealed class M5Splitter : SplitterBase { 34 34 public const string OrderParameterName = "Order"; -
trunk/HeuristicLab.Algorithms.DataAnalysis.DecisionTrees/3.4/Splitting/SplitterBase.cs
r16852 r17080 48 48 49 49 public void Split(RegressionNodeTreeModel tree, IReadOnlyList<int> trainingRows, IScope stateScope, CancellationToken cancellationToken) { 50 var regressionTreeParams = (RegressionTreeParameters)stateScope.Variables[ M5Regression.RegressionTreeParameterVariableName].Value;50 var regressionTreeParams = (RegressionTreeParameters)stateScope.Variables[DecisionTreeRegression.RegressionTreeParameterVariableName].Value; 51 51 var splittingState = (SplittingState)stateScope.Variables[SplittingStateVariableName].Value; 52 52 var variables = regressionTreeParams.AllowedInputVariables.ToArray();
Note: See TracChangeset
for help on using the changeset viewer.