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.Classification.Views/3.4/SolutionComparisonView.cs

    r14249 r14251  
    2121
    2222using System;
     23using System.Collections;
    2324using System.Collections.Generic;
    2425using System.Linq;
     
    5354      if (!problemData.TrainingIndices.Any()) return null; // don't create an comparison models if the problem does not have a training set (e.g. loaded into an existing model)
    5455
    55       var usedDoubleVariables =
    56         symbolicSolution.Model.SymbolicExpressionTree.IterateNodesPostfix()
    57         .OfType<VariableTreeNode>()
    58         .Select(node => node.VariableName)
    59       .Concat(
    60         symbolicSolution.Model.SymbolicExpressionTree.IterateNodesPostfix()
    61         .OfType<VariableConditionTreeNode>()
    62         .Select(node => node.VariableName)
    63         )
     56      var usedVariables = Content.Model.SymbolicExpressionTree.IterateNodesPostfix()
     57      .OfType<IVariableTreeNode>()
     58      .Select(node => node.VariableName).ToArray();
     59
     60      var usedDoubleVariables = usedVariables
     61        .Where(name => problemData.Dataset.VariableHasType<double>(name))
    6462      .Distinct();
    6563
    66       var usedFactorVariables =
    67         symbolicSolution.Model.SymbolicExpressionTree.IterateNodesPostfix()
    68         .OfType<BinaryFactorVariableTreeNode>()
    69         .Select(node => Tuple.Create(node.VariableName, node.VariableValue))
     64      var usedFactorVariables = usedVariables
     65        .Where(name => problemData.Dataset.VariableHasType<string>(name))
    7066        .Distinct();
     67
     68      // gkronber: for binary factors we actually produce a binary variable in the new dataset
     69      // but only if the variable is not used as a full factor anyway (LR creates binary columns anyway)
     70      var usedBinaryFactors =
     71        Content.Model.SymbolicExpressionTree.IterateNodesPostfix().OfType<BinaryFactorVariableTreeNode>()
     72        .Where(node => !usedFactorVariables.Contains(node.VariableName))
     73        .Select(node => Tuple.Create(node.VariableValue, node.VariableValue));
    7174
    7275      // create a new problem and dataset
    7376      var variableNames =
    7477        usedDoubleVariables
    75         .Concat(usedFactorVariables.Select(t => t.Item1 + "=" + t.Item2))
     78        .Concat(usedFactorVariables)
     79        .Concat(usedBinaryFactors.Select(t => t.Item1 + "=" + t.Item2))
    7680        .Concat(new string[] { problemData.TargetVariable })
    7781        .ToArray();
    7882      var variableValues =
    79         usedDoubleVariables.Select(name => problemData.Dataset.GetDoubleValues(name).ToList())
     83        usedDoubleVariables.Select(name => (IList)problemData.Dataset.GetDoubleValues(name).ToList())
     84        .Concat(usedFactorVariables.Select(name => problemData.Dataset.GetStringValues(name).ToList()))
    8085        .Concat(
    81         // create binary variable
    82           usedFactorVariables.Select(t => problemData.Dataset.GetReadOnlyStringValues(t.Item1).Select(val => val == t.Item2 ? 1.0 : 0.0).ToList())
     86          // create binary variable
     87          usedBinaryFactors.Select(t => problemData.Dataset.GetReadOnlyStringValues(t.Item1).Select(val => val == t.Item2 ? 1.0 : 0.0).ToList())
    8388        )
    8489        .Concat(new[] { problemData.Dataset.GetDoubleValues(problemData.TargetVariable).ToList() });
Note: See TracChangeset for help on using the changeset viewer.