Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4112 for trunk


Ignore:
Timestamp:
07/27/10 14:36:27 (14 years ago)
Author:
gkronber
Message:

Fixed some bugs in multi-variate regression classes. #1089

Location:
trunk/sources
Files:
9 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.MultiVariate.Regression/3.3/Symbolic/Analyzer/ValidationBestScaledSymbolicVectorRegressionSolutionAnalyzer.cs

    r4068 r4112  
    145145      if (Alpha.Length == trees.Length) {
    146146        scaledTrees = from i in Enumerable.Range(0, trees.Length)
    147                       select SymbolicVectorRegressionSolutionLinearScaler.Scale(trees[i], Alpha[i].ToArray(), Beta[i].ToArray());
     147                      select SymbolicVectorRegressionSolutionLinearScaler.Scale(trees[i], Beta[i].ToArray(), Alpha[i].ToArray());
    148148      } else {
    149149        scaledTrees = trees;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.MultiVariate.Regression/3.3/Symbolic/Evaluators/SymbolicRegressionNormalizedMeanSquaredErrorEvaluator.cs

    r4068 r4112  
    6565
    6666    public static double Calculate(ISymbolicExpressionTreeInterpreter interpreter, SymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, Dataset dataset, string targetVariable, IEnumerable<int> rows) {
    67       int targetVariableIndex = dataset.GetVariableIndex(targetVariable);
    68       var estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, dataset, rows);
    69       var originalValues = dataset.GetEnumeratedVariableValues(targetVariableIndex, rows);
    70       IEnumerator<double> originalEnumerator = originalValues.GetEnumerator();
    71       IEnumerator<double> estimatedEnumerator = estimatedValues.GetEnumerator();
    72       OnlineNormalizedMeanSquaredErrorEvaluator mseEvaluator = new OnlineNormalizedMeanSquaredErrorEvaluator();
    73 
    74       while (originalEnumerator.MoveNext() & estimatedEnumerator.MoveNext()) {
    75         double estimated = estimatedEnumerator.Current;
    76         double original = originalEnumerator.Current;
    77         if (double.IsNaN(estimated))
    78           estimated = upperEstimationLimit;
    79         else
    80           estimated = Math.Min(upperEstimationLimit, Math.Max(lowerEstimationLimit, estimated));
    81         mseEvaluator.Add(original, estimated);
    82       }
    83 
    84       if (estimatedEnumerator.MoveNext() || originalEnumerator.MoveNext()) {
    85         throw new ArgumentException("Number of elements in original and estimated enumeration doesn't match.");
    86       } else {
    87         return mseEvaluator.NormalizedMeanSquaredError;
    88       }
     67      return SymbolicRegressionScaledNormalizedMeanSquaredErrorEvaluator.CalculateWithScaling(interpreter, solution, lowerEstimationLimit, upperEstimationLimit, dataset, targetVariable, rows, 1.0, 0.0);
    8968    }
    9069  }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.MultiVariate.Regression/3.3/Symbolic/Evaluators/SymbolicVectorRegressionNormalizedMseEvaluator.cs

    r4068 r4112  
    7373        tree.Root.SubTrees[0].AddSubTree(treeNode);
    7474      }
    75       return nmseSum / targetVariablesList.Count;
     75      return nmseSum;
    7676    }
    7777  }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.MultiVariate.Regression/3.3/Symbolic/Evaluators/SymbolicVectorRegressionScaledMseEvaluator.cs

    r4068 r4112  
    7575        double mse = SymbolicRegressionScaledMeanSquaredErrorEvaluator.Calculate(interpreter, tree,
    7676          lowerEstimationBound[i], upperEstimationBound[i],
    77           problemData.Dataset, targetVariablesList[i], rows, out compAlpha, out compBeta);
     77          problemData.Dataset, targetVariablesList[i], rows, out compBeta, out compAlpha);
    7878
    7979        qualities[i] = mse;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.MultiVariate.Regression/3.3/Symbolic/Evaluators/SymbolicVectorRegressionScaledNormalizedMseEvaluator.cs

    r4087 r4112  
    8787      AlphaParameter.ActualValue = alpha;
    8888      BetaParameter.ActualValue = beta;
    89       QualityParameter.ActualValue = new DoubleValue(nmseSum / targetVariables.Count());
     89      QualityParameter.ActualValue = new DoubleValue(nmseSum);
    9090    }
    9191  }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.MultiVariate.Regression/3.3/Symbolic/SymbolicVectorRegressionSolutionLinearScaler.cs

    r4068 r4112  
    6868      DoubleArray beta = BetaParameter.ActualValue;
    6969      if (alpha != null && beta != null) {
    70         ScaledSymbolicExpressionTreeParameter.ActualValue = Scale(tree, alpha.ToArray(), beta.ToArray());
     70        ScaledSymbolicExpressionTreeParameter.ActualValue = Scale(tree, beta.ToArray(), alpha.ToArray());
    7171      } else {
    7272        // alpha or beta parameter not available => do not scale tree
     
    7777    }
    7878
    79     public static SymbolicExpressionTree Scale(SymbolicExpressionTree original, double[] alpha, double[] beta) {
     79    public static SymbolicExpressionTree Scale(SymbolicExpressionTree original, double[] beta, double[] alpha) {
    8080      List<SymbolicExpressionTreeNode> resultProducingBranches = new List<SymbolicExpressionTreeNode>(original.Root.SubTrees[0].SubTrees);
    8181      // remove the main branch before cloning to prevent cloning of sub-trees
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.MultiVariate/3.3/MultiVariateDataAnalysisProblem.cs

    r4098 r4112  
    5151
    5252    [StorableConstructor]
    53     private MultiVariateDataAnalysisProblem(bool deserializing) : base() { }
     53    protected MultiVariateDataAnalysisProblem(bool deserializing) : base(deserializing) { }
    5454    public MultiVariateDataAnalysisProblem()
    5555      : base() {
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/HeuristicLab.Problems.DataAnalysis.Regression-3.3.csproj

    r4065 r4112  
    115115    <Compile Include="LinearRegression\LinearRegressionSolutionCreator.cs" />
    116116    <Compile Include="LinearRegression\LinearRegressionUtil.cs" />
    117     <Compile Include="RandomEnumerable.cs" />
    118117    <Compile Include="Properties\AssemblyInfo.cs" />
    119118    <Compile Include="SupportVectorRegression\BestSupportVectorRegressionSolutionAnalyzer.cs" />
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/HeuristicLab.Problems.DataAnalysis-3.3.csproj

    r4065 r4112  
    135135    <Compile Include="Operators\WeightedParentsQualityVarianceComparator.cs" />
    136136    <Compile Include="Properties\AssemblyInfo.cs" />
     137    <Compile Include="RandomEnumerable.cs" />
    137138    <Compile Include="SupportVectorMachine\ParameterAdjustmentProblem\SupportVectorMachineParameterAdjustmentBestSolutionAnalyzer.cs" />
    138139    <Compile Include="SupportVectorMachine\ParameterAdjustmentProblem\SupportVectorMachineParameterAdjustmentEvaluator.cs" />
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/RandomEnumerable.cs

    r4105 r4112  
    2424using HeuristicLab.Random;
    2525
    26 namespace HeuristicLab.Problems.DataAnalysis.Regression {
     26namespace HeuristicLab.Problems.DataAnalysis {
    2727  public class RandomEnumerable {
    2828    public static IEnumerable<int> SampleRandomNumbers(int maxElement, int count) {
Note: See TracChangeset for help on using the changeset viewer.