- Timestamp:
- 07/28/09 19:24:23 (15 years ago)
- Location:
- branches/GP-Refactoring-713
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/GP-Refactoring-713/sources/HeuristicLab.LinearRegression/3.2/LinearRegressionOperator.cs
r2165 r2202 54 54 double[] targetVector = PrepareTargetVector(dataset, targetVariable, allowedRows); 55 55 double[] coefficients = CalculateCoefficients(inputMatrix, targetVector); 56 IFunctionTree tree = CreateModel(coefficients, allowedColumns );56 IFunctionTree tree = CreateModel(coefficients, allowedColumns.Select(i => dataset.GetVariableName(i)).ToList()); 57 57 58 58 scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("LinearRegressionModel"), tree)); … … 66 66 } 67 67 68 private IFunctionTree CreateModel(double[] coefficients, List< int> allowedColumns) {68 private IFunctionTree CreateModel(double[] coefficients, List<string> allowedVariables) { 69 69 IFunctionTree root = new Addition().GetTreeNode(); 70 70 IFunctionTree actNode = root; … … 73 73 GP.StructureIdentification.Variable v; 74 74 for (int i = 0; i < coefficients.Length - 1; i++) { 75 v = new GP.StructureIdentification.Variable();76 v .GetVariable(GP.StructureIdentification.Variable.INDEX).Value = new ConstrainedIntData(allowedColumns[i]);77 v .GetVariable(GP.StructureIdentification.Variable.WEIGHT).Value = new ConstrainedDoubleData(coefficients[i]);78 v .GetVariable(GP.StructureIdentification.Variable.OFFSET).Value = new ConstrainedIntData(0);79 nodes.Enqueue(v .GetTreeNode());75 var vNode = new GP.StructureIdentification.Variable().GetTreeNode(); 76 vNode.GetLocalVariable(GP.StructureIdentification.Variable.INDEX).Value = new StringData(allowedVariables[i]); 77 vNode.GetLocalVariable(GP.StructureIdentification.Variable.WEIGHT).Value = new DoubleData(coefficients[i]); 78 vNode.GetLocalVariable(GP.StructureIdentification.Variable.OFFSET).Value = new ConstrainedIntData(0); 79 nodes.Enqueue(vNode); 80 80 } 81 GP.StructureIdentification.Constant c = new Constant(); 82 c.GetVariable(GP.StructureIdentification.Constant.VALUE).Value = new ConstrainedDoubleData(coefficients[coefficients.Length - 1]); 83 nodes.Enqueue(c.GetTreeNode()); 81 var cNode = new Constant().GetTreeNode(); 82 83 cNode.GetLocalVariable(GP.StructureIdentification.Constant.VALUE).Value = new DoubleData(coefficients[coefficients.Length - 1]); 84 nodes.Enqueue(cNode); 84 85 85 86 IFunctionTree newTree;
Note: See TracChangeset
for help on using the changeset viewer.