Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/28/09 19:24:23 (15 years ago)
Author:
gkronber
Message:

Created a branch for #713

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  
    5454      double[] targetVector = PrepareTargetVector(dataset, targetVariable, allowedRows);
    5555      double[] coefficients = CalculateCoefficients(inputMatrix, targetVector);
    56       IFunctionTree tree = CreateModel(coefficients, allowedColumns);
     56      IFunctionTree tree = CreateModel(coefficients, allowedColumns.Select(i => dataset.GetVariableName(i)).ToList());
    5757
    5858      scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("LinearRegressionModel"), tree));
     
    6666    }
    6767
    68     private IFunctionTree CreateModel(double[] coefficients, List<int> allowedColumns) {
     68    private IFunctionTree CreateModel(double[] coefficients, List<string> allowedVariables) {
    6969      IFunctionTree root = new Addition().GetTreeNode();
    7070      IFunctionTree actNode = root;
     
    7373      GP.StructureIdentification.Variable v;
    7474      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);
    8080      }
    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);
    8485
    8586      IFunctionTree newTree;
Note: See TracChangeset for help on using the changeset viewer.