- Timestamp:
- 12/01/21 13:40:55 (3 years ago)
- Location:
- branches/3140_NumberSymbol/HeuristicLab.Algorithms.DataAnalysis/3.4
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3140_NumberSymbol/HeuristicLab.Algorithms.DataAnalysis/3.4/GBM/GradientBoostingRegressionAlgorithm.cs
r17180 r18100 417 417 var addNode = new Addition().CreateTreeNode(); 418 418 var mulNode = new Multiplication().CreateTreeNode(); 419 var scaleNode = ( ConstantTreeNode)new Constant().CreateTreeNode(); // all models are scaled using the same nu419 var scaleNode = (NumberTreeNode)new Number().CreateTreeNode(); // all models are scaled using the same nu 420 420 scaleNode.Value = nu; 421 421 -
branches/3140_NumberSymbol/HeuristicLab.Algorithms.DataAnalysis/3.4/GradientBoostedTrees/RegressionTreeModel.cs
r17180 r18100 230 230 var startSy = new StartSymbol(); 231 231 var varCondSy = new VariableCondition() { IgnoreSlope = true }; 232 var constSy = new Constant();232 var numSy = new Number(); 233 233 234 234 var startNode = startSy.CreateTreeNode(); 235 startNode.AddSubtree(CreateSymbolicRegressionTreeRecursive(tree, 0, varCondSy, constSy));235 startNode.AddSubtree(CreateSymbolicRegressionTreeRecursive(tree, 0, varCondSy, numSy)); 236 236 var rootNode = rootSy.CreateTreeNode(); 237 237 rootNode.AddSubtree(startNode); … … 239 239 } 240 240 241 private ISymbolicExpressionTreeNode CreateSymbolicRegressionTreeRecursive(TreeNode[] treeNodes, int nodeIdx, VariableCondition varCondSy, ConstantconstSy) {241 private ISymbolicExpressionTreeNode CreateSymbolicRegressionTreeRecursive(TreeNode[] treeNodes, int nodeIdx, VariableCondition varCondSy, Number constSy) { 242 242 var curNode = treeNodes[nodeIdx]; 243 243 if (curNode.VarName == TreeNode.NO_VARIABLE) { 244 var node = ( ConstantTreeNode)constSy.CreateTreeNode();244 var node = (NumberTreeNode)constSy.CreateTreeNode(); 245 245 node.Value = curNode.Val; 246 246 return node; -
branches/3140_NumberSymbol/HeuristicLab.Algorithms.DataAnalysis/3.4/NonlinearRegression/NonlinearRegression.cs
r17180 r18100 123 123 : base() { 124 124 Problem = new RegressionProblem(); 125 Parameters.Add(new FixedValueParameter<StringValue>(ModelStructureParameterName, "The function for which the parameters must be fit (only numeric constants are tuned).", new StringValue(" 1.0* x*x + 0.0")));125 Parameters.Add(new FixedValueParameter<StringValue>(ModelStructureParameterName, "The function for which the parameters must be fit (only numeric constants are tuned).", new StringValue("<num> * x*x + 0.0"))); 126 126 Parameters.Add(new FixedValueParameter<IntValue>(IterationsParameterName, "The maximum number of iterations for constants optimization.", new IntValue(200))); 127 127 Parameters.Add(new FixedValueParameter<IntValue>(RestartsParameterName, "The number of independent random restarts (>0)", new IntValue(10))); … … 267 267 // initialize constants randomly 268 268 if (rand != null) { 269 foreach (var node in tree.IterateNodesPrefix().OfType< ConstantTreeNode>()) {269 foreach (var node in tree.IterateNodesPrefix().OfType<NumberTreeNode>()) { 270 270 double f = Math.Exp(NormalDistributedRandom.NextDouble(rand, 0, 1)); 271 271 double s = rand.NextDouble() < 0.5 ? -1 : 1; -
branches/3140_NumberSymbol/HeuristicLab.Algorithms.DataAnalysis/3.4/RandomForest/RandomForestModel.cs
r17931 r18100 220 220 } 221 221 222 var constSy = new Constant();222 var numSy = new Number(); 223 223 var varCondSy = new VariableCondition() { IgnoreSlope = true }; 224 224 225 var node = CreateRegressionTreeRec(rf.innerobj.trees, offset, offset + 1, constSy, varCondSy);225 var node = CreateRegressionTreeRec(rf.innerobj.trees, offset, offset + 1, numSy, varCondSy); 226 226 227 227 var startNode = new StartSymbol().CreateTreeNode(); … … 232 232 } 233 233 234 private ISymbolicExpressionTreeNode CreateRegressionTreeRec(double[] trees, int offset, int k, Constant constSy, VariableCondition varCondSy) {234 private ISymbolicExpressionTreeNode CreateRegressionTreeRec(double[] trees, int offset, int k, Number numSy, VariableCondition varCondSy) { 235 235 236 236 // alglib source for evaluation of one tree (dfprocessinternal) … … 262 262 263 263 if ((double)(trees[k]) == (double)(-1)) { 264 var constNode = (ConstantTreeNode)constSy.CreateTreeNode();265 constNode.Value = trees[k + 1];266 return constNode;264 var numNode = (NumberTreeNode)numSy.CreateTreeNode(); 265 numNode.Value = trees[k + 1]; 266 return numNode; 267 267 } else { 268 268 var condNode = (VariableConditionTreeNode)varCondSy.CreateTreeNode(); … … 271 271 condNode.Slope = double.PositiveInfinity; 272 272 273 var left = CreateRegressionTreeRec(trees, offset, k + 3, constSy, varCondSy);274 var right = CreateRegressionTreeRec(trees, offset, offset + (int)Math.Round(trees[k + 2]), constSy, varCondSy);273 var left = CreateRegressionTreeRec(trees, offset, k + 3, numSy, varCondSy); 274 var right = CreateRegressionTreeRec(trees, offset, offset + (int)Math.Round(trees[k + 2]), numSy, varCondSy); 275 275 276 276 condNode.AddSubtree(left); // not 100% correct because interpreter uses: if(x <= thres) left() else right() and RF uses if(x < thres) left() else right() (see above) -
branches/3140_NumberSymbol/HeuristicLab.Algorithms.DataAnalysis/3.4/RandomForest/RandomForestModelAlglib_3_7.cs
r17931 r18100 220 220 } 221 221 222 var constSy = new Constant();222 var numSy = new Number(); 223 223 var varCondSy = new VariableCondition() { IgnoreSlope = true }; 224 224 225 var node = CreateRegressionTreeRec(rf.innerobj.trees, offset, offset + 1, constSy, varCondSy);225 var node = CreateRegressionTreeRec(rf.innerobj.trees, offset, offset + 1, numSy, varCondSy); 226 226 227 227 var startNode = new StartSymbol().CreateTreeNode(); … … 232 232 } 233 233 234 private ISymbolicExpressionTreeNode CreateRegressionTreeRec(double[] trees, int offset, int k, ConstantconstSy, VariableCondition varCondSy) {234 private ISymbolicExpressionTreeNode CreateRegressionTreeRec(double[] trees, int offset, int k, Number constSy, VariableCondition varCondSy) { 235 235 236 236 // alglib source for evaluation of one tree (dfprocessinternal) … … 262 262 263 263 if ((double)(trees[k]) == (double)(-1)) { 264 var constNode = (ConstantTreeNode)constSy.CreateTreeNode();265 constNode.Value = trees[k + 1];266 return constNode;264 var numNode = (NumberTreeNode)constSy.CreateTreeNode(); 265 numNode.Value = trees[k + 1]; 266 return numNode; 267 267 } else { 268 268 var condNode = (VariableConditionTreeNode)varCondSy.CreateTreeNode(); -
branches/3140_NumberSymbol/HeuristicLab.Algorithms.DataAnalysis/3.4/RandomForest/RandomForestModelFull.cs
r17931 r18100 199 199 } 200 200 201 var constSy = new Constant();201 var numSy = new Number(); 202 202 var varCondSy = new VariableCondition() { IgnoreSlope = true }; 203 203 204 var node = CreateRegressionTreeRec(rf.innerobj.trees, offset, offset + 1, constSy, varCondSy);204 var node = CreateRegressionTreeRec(rf.innerobj.trees, offset, offset + 1, numSy, varCondSy); 205 205 206 206 var startNode = new StartSymbol().CreateTreeNode(); … … 211 211 } 212 212 213 private ISymbolicExpressionTreeNode CreateRegressionTreeRec(double[] trees, int offset, int k, ConstantconstSy, VariableCondition varCondSy) {213 private ISymbolicExpressionTreeNode CreateRegressionTreeRec(double[] trees, int offset, int k, Number constSy, VariableCondition varCondSy) { 214 214 215 215 // alglib source for evaluation of one tree (dfprocessinternal) … … 241 241 242 242 if ((double)(trees[k]) == (double)(-1)) { 243 var constNode = (ConstantTreeNode)constSy.CreateTreeNode();244 constNode.Value = trees[k + 1];245 return constNode;243 var numNode = (NumberTreeNode)constSy.CreateTreeNode(); 244 numNode.Value = trees[k + 1]; 245 return numNode; 246 246 } else { 247 247 var condNode = (VariableConditionTreeNode)varCondSy.CreateTreeNode();
Note: See TracChangeset
for help on using the changeset viewer.