Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/10/16 20:10:25 (8 years ago)
Author:
gkronber
Message:

#2650:

  • extended non-linear regression to work with factors
  • fixed bugs in constants optimizer and tree interpreter
  • improved simplification of factor variables
  • added support for factors to ERC view
  • added support for factors to solution comparison view
  • activated view for all factors
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionErrorCharacteristicsCurveView.cs

    r14249 r14251  
    2121
    2222using System;
     23using System.Collections;
    2324using System.Collections.Generic;
    2425using System.Diagnostics.Contracts;
     
    4748      if (!problemData.TrainingIndices.Any()) return null; // don't create an LR model if the problem does not have a training set (e.g. loaded into an existing model)
    4849
    49       var usedDoubleVariables =
    50         Content.Model.SymbolicExpressionTree.IterateNodesPostfix()
    51         .OfType<VariableTreeNode>()
    52         .Select(node => node.VariableName)
    53       .Concat(
    54         Content.Model.SymbolicExpressionTree.IterateNodesPostfix()
    55         .OfType<VariableConditionTreeNode>()
    56         .Select(node => node.VariableName)
    57         )
     50      var usedVariables = Content.Model.SymbolicExpressionTree.IterateNodesPostfix()
     51        .OfType<IVariableTreeNode>()
     52        .Select(node => node.VariableName).ToArray();
     53
     54      var usedDoubleVariables = usedVariables
     55        .Where(name => problemData.Dataset.VariableHasType<double>(name))
    5856      .Distinct();
    5957
    60       var usedFactorVariables =
    61         Content.Model.SymbolicExpressionTree.IterateNodesPostfix()
    62         .OfType<BinaryFactorVariableTreeNode>()
    63         .Select(node => Tuple.Create(node.VariableName, node.VariableValue))
     58      var usedFactorVariables = usedVariables
     59        .Where(name => problemData.Dataset.VariableHasType<string>(name))
    6460        .Distinct();
     61
     62      // gkronber: for binary factors we actually produce a binary variable in the new dataset
     63      // but only if the variable is not used as a full factor anyway (LR creates binary columns anyway)
     64      var usedBinaryFactors =
     65        Content.Model.SymbolicExpressionTree.IterateNodesPostfix().OfType<BinaryFactorVariableTreeNode>()
     66        .Where(node => !usedFactorVariables.Contains(node.VariableName))
     67        .Select(node => Tuple.Create(node.VariableValue, node.VariableValue));
    6568
    6669      // create a new problem and dataset
    6770      var variableNames =
    6871        usedDoubleVariables
    69         .Concat(usedFactorVariables.Select(t => t.Item1 + "=" + t.Item2))
     72        .Concat(usedFactorVariables)
     73        .Concat(usedBinaryFactors.Select(t => t.Item1 + "=" + t.Item2))
    7074        .Concat(new string[] { problemData.TargetVariable })
    7175        .ToArray();
    7276      var variableValues =
    73         usedDoubleVariables.Select(name => problemData.Dataset.GetDoubleValues(name).ToList())
     77        usedDoubleVariables.Select(name => (IList)problemData.Dataset.GetDoubleValues(name).ToList())
     78        .Concat(usedFactorVariables.Select(name => problemData.Dataset.GetStringValues(name).ToList()))
    7479        .Concat(
    75         // create binary variable
    76           usedFactorVariables.Select(t => problemData.Dataset.GetReadOnlyStringValues(t.Item1).Select(val => val == t.Item2 ? 1.0 : 0.0).ToList())
     80          // create binary variable
     81          usedBinaryFactors.Select(t => problemData.Dataset.GetReadOnlyStringValues(t.Item1).Select(val => val == t.Item2 ? 1.0 : 0.0).ToList())
    7782        )
    7883        .Concat(new[] { problemData.Dataset.GetDoubleValues(problemData.TargetVariable).ToList() });
Note: See TracChangeset for help on using the changeset viewer.