Changeset 5010


Ignore:
Timestamp:
12/02/10 15:25:55 (11 years ago)
Author:
gkronber
Message:

commit of local changes in data-analysis feature exploration branch. #1142

Location:
branches/DataAnalysis
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.TimeSeriesPrognosis.Views/3.3/PrognosisView.cs

    r4556 r5010  
    7676      DoubleMatrix matrix = null;
    7777        if (Content != null) {
    78           IEnumerable<string> targetVariables = Content.ProblemData.TargetVariables.CheckedItems.Select(x => x.Value.Value);
    79           List<double[]> prognosis = Content.GetPrognosis(currentTimePoint).ToList();
    80           double[,] values = new double[prognosis.Count, targetVariables.Count() * 2];
    81           for (int row = 0; row < prognosis.Count; row++) {
    82             int col = 0;
    83             int t = currentTimePoint + row;
    84             foreach (string targetVariable in targetVariables) {
    85               values[row, col++] = t<Content.ProblemData.Dataset.Rows ? Content.ProblemData.Dataset[targetVariable, t] : double.NaN;
    86               values[row, col++] = prognosis[row][(col - 1) / 2];
    87             }
    88           }
    89           matrix = new DoubleMatrix(values);
    90           string[] partitions = new string[] { "(original)", "(estimated)" };
    91           matrix.ColumnNames = from targetVariable in targetVariables
    92                                from partition in partitions
    93                                select targetVariable + " " + partition;
    94           ;
     78          matrix = CalculateMatrix();
    9579        }
    9680        valuesView.Content = matrix;
     81    }
     82
     83    public DoubleMatrix CalculateMatrix() {
     84      DoubleMatrix matrix = null;
     85      IEnumerable<string> targetVariables = Content.ProblemData.TargetVariables.CheckedItems.Select(x => x.Value.Value);
     86      List<double[]> prognosis = Content.GetPrognosis(currentTimePoint).ToList();
     87      double[,] values = new double[prognosis.Count, targetVariables.Count() * 2];
     88      for (int row = 0; row < prognosis.Count; row++) {
     89        int col = 0;
     90        int t = currentTimePoint + row;
     91        foreach (string targetVariable in targetVariables) {
     92          values[row, col++] = t < Content.ProblemData.Dataset.Rows ? Content.ProblemData.Dataset[targetVariable, t] : double.NaN;
     93          values[row, col++] = prognosis[row][(col - 1) / 2];
     94        }
     95      }
     96      matrix = new DoubleMatrix(values);
     97      string[] partitions = new string[] { "(original)", "(estimated)" };
     98      matrix.ColumnNames = from targetVariable in targetVariables
     99                           from partition in partitions
     100                           select targetVariable + " " + partition;
     101      ;
     102      return matrix;
    97103    }
    98104
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.TimeSeriesPrognosis.Views/3.3/ResultsView.cs

    r4556 r5010  
    8585    private void UpdateView() {
    8686      if (Content != null) {
    87         List<string> targetVariables = Content.ProblemData.TargetVariables.CheckedItems.Select(x => x.Value.Value).ToList();
    88         DoubleMatrix matrix = new DoubleMatrix(rowNames.Count, targetVariables.Count() * 2);
    89         matrix.RowNames = rowNames;
    90         matrix.ColumnNames = targetVariables.SelectMany(x => new List<string>() { x + " (training)", x + " (test)" });
    91         matrix.SortableView = false;
    92 
    93         int trainingStart = Content.ProblemData.TrainingSamplesStart.Value;
    94         int trainingEnd = Content.ProblemData.TrainingSamplesEnd.Value;
    95         int testStart = Content.ProblemData.TestSamplesStart.Value;
    96         int testEnd = Content.ProblemData.TestSamplesEnd.Value;
    97         // create a list of time series evaluators for each target variable
    98         Dictionary<string, List<IOnlineEvaluator>> trainingEvaluators =
    99           new Dictionary<string, List<IOnlineEvaluator>>();
    100         Dictionary<string, List<IOnlineEvaluator>> testEvaluators =
    101           new Dictionary<string, List<IOnlineEvaluator>>();
    102         foreach (string targetVariable in targetVariables) {
    103           trainingEvaluators.Add(targetVariable, new List<IOnlineEvaluator>());
    104           trainingEvaluators[targetVariable].Add(new OnlineMeanSquaredErrorEvaluator());
    105           trainingEvaluators[targetVariable].Add(new OnlinePearsonsRSquaredEvaluator());
    106           trainingEvaluators[targetVariable].Add(new OnlineMeanAbsolutePercentageErrorEvaluator());
    107           trainingEvaluators[targetVariable].Add(new OnlineDirectionalSymmetryEvaluator());
    108           trainingEvaluators[targetVariable].Add(new OnlineWeightedDirectionalSymmetryEvaluator());
    109           trainingEvaluators[targetVariable].Add(new OnlineTheilsUStatisticEvaluator());
    110 
    111           testEvaluators.Add(targetVariable, new List<IOnlineEvaluator>());
    112           testEvaluators[targetVariable].Add(new OnlineMeanSquaredErrorEvaluator());
    113           testEvaluators[targetVariable].Add(new OnlinePearsonsRSquaredEvaluator());
    114           testEvaluators[targetVariable].Add(new OnlineMeanAbsolutePercentageErrorEvaluator());
    115           testEvaluators[targetVariable].Add(new OnlineDirectionalSymmetryEvaluator());
    116           testEvaluators[targetVariable].Add(new OnlineWeightedDirectionalSymmetryEvaluator());
    117           testEvaluators[targetVariable].Add(new OnlineTheilsUStatisticEvaluator());
    118         }
    119 
    120         Evaluate(trainingStart, trainingEnd, trainingEvaluators);
    121         Evaluate(testStart, testEnd, testEvaluators);
    122 
    123         int columnIndex = 0;
    124         foreach (string targetVariable in targetVariables) {
    125           int rowIndex = 0;
    126           // training
    127           foreach (var evaluator in trainingEvaluators[targetVariable]) {
    128             matrix[rowIndex++, columnIndex] = evaluator.Value;
    129           }
    130           columnIndex++;
    131           // test
    132           rowIndex = 0;
    133           foreach (var evaluator in testEvaluators[targetVariable]) {
    134             matrix[rowIndex++, columnIndex] = evaluator.Value;
    135           }
    136           columnIndex++;
    137         }
    138 
    139         matrixView.Content = matrix;
     87        matrixView.Content = CalculateMatrix();
    14088      } else
    14189        matrixView.Content = null;
     90    }
     91
     92    public DoubleMatrix CalculateMatrix() {
     93      List<string> targetVariables = Content.ProblemData.TargetVariables.CheckedItems.Select(x => x.Value.Value).ToList();
     94      DoubleMatrix matrix = new DoubleMatrix(rowNames.Count, targetVariables.Count() * 2);
     95      matrix.RowNames = rowNames;
     96      matrix.ColumnNames = targetVariables.SelectMany(x => new List<string>() { x + " (training)", x + " (test)" });
     97      matrix.SortableView = false;
     98
     99      int trainingStart = Content.ProblemData.TrainingSamplesStart.Value;
     100      int trainingEnd = Content.ProblemData.TrainingSamplesEnd.Value;
     101      int testStart = Content.ProblemData.TestSamplesStart.Value;
     102      int testEnd = Content.ProblemData.TestSamplesEnd.Value;
     103      // create a list of time series evaluators for each target variable
     104      Dictionary<string, List<IOnlineEvaluator>> trainingEvaluators =
     105        new Dictionary<string, List<IOnlineEvaluator>>();
     106      Dictionary<string, List<IOnlineEvaluator>> testEvaluators =
     107        new Dictionary<string, List<IOnlineEvaluator>>();
     108      foreach (string targetVariable in targetVariables) {
     109        trainingEvaluators.Add(targetVariable, new List<IOnlineEvaluator>());
     110        trainingEvaluators[targetVariable].Add(new OnlineMeanSquaredErrorEvaluator());
     111        trainingEvaluators[targetVariable].Add(new OnlinePearsonsRSquaredEvaluator());
     112        trainingEvaluators[targetVariable].Add(new OnlineMeanAbsolutePercentageErrorEvaluator());
     113        trainingEvaluators[targetVariable].Add(new OnlineDirectionalSymmetryEvaluator());
     114        trainingEvaluators[targetVariable].Add(new OnlineWeightedDirectionalSymmetryEvaluator());
     115        trainingEvaluators[targetVariable].Add(new OnlineTheilsUStatisticEvaluator());
     116
     117        testEvaluators.Add(targetVariable, new List<IOnlineEvaluator>());
     118        testEvaluators[targetVariable].Add(new OnlineMeanSquaredErrorEvaluator());
     119        testEvaluators[targetVariable].Add(new OnlinePearsonsRSquaredEvaluator());
     120        testEvaluators[targetVariable].Add(new OnlineMeanAbsolutePercentageErrorEvaluator());
     121        testEvaluators[targetVariable].Add(new OnlineDirectionalSymmetryEvaluator());
     122        testEvaluators[targetVariable].Add(new OnlineWeightedDirectionalSymmetryEvaluator());
     123        testEvaluators[targetVariable].Add(new OnlineTheilsUStatisticEvaluator());
     124      }
     125
     126      Evaluate(trainingStart, trainingEnd, trainingEvaluators);
     127      Evaluate(testStart, testEnd, testEvaluators);
     128
     129      int columnIndex = 0;
     130      foreach (string targetVariable in targetVariables) {
     131        int rowIndex = 0;
     132        // training
     133        foreach (var evaluator in trainingEvaluators[targetVariable]) {
     134          matrix[rowIndex++, columnIndex] = evaluator.Value;
     135        }
     136        columnIndex++;
     137        // test
     138        rowIndex = 0;
     139        foreach (var evaluator in testEvaluators[targetVariable]) {
     140          matrix[rowIndex++, columnIndex] = evaluator.Value;
     141        }
     142        columnIndex++;
     143      }
     144      return matrix;
    142145    }
    143146
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.TimeSeriesPrognosis/3.3/Symbolic/SymbolicTimeSeriesPrognosisSolution.cs

    r4556 r5010  
    220220      foreach (var xs in values) {
    221221        for (int i = 0; i < xs.Length; i++) {
    222           xs[i] = Math.Max(lowerEstimationLimit[i], Math.Min(upperEstimationLimit[i], xs[i]));
     222          if (double.IsNaN(xs[i])) {
     223            xs[i] = (upperEstimationLimit[i] - lowerEstimationLimit[i]) / 2.0 + lowerEstimationLimit[i];
     224          } else {
     225            xs[i] = Math.Max(lowerEstimationLimit[i], Math.Min(upperEstimationLimit[i], xs[i]));
     226          }
    223227        }
    224228        yield return xs;
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/Analyzers/OverfittingAnalyzer.cs

    r4326 r5010  
    119119      get { return (ILookupParameter<DoubleValue>)Parameters["InitialTrainingQuality"]; }
    120120    }
    121     public ILookupParameter<DoubleMatrix> TrainingAndValidationQualitiesParameter {
    122       get { return (ILookupParameter<DoubleMatrix>)Parameters["TrainingAndValidationQualities"]; }
     121    public ILookupParameter<ItemList<DoubleMatrix>> TrainingAndValidationQualitiesParameter {
     122      get { return (ILookupParameter<ItemList<DoubleMatrix>>)Parameters["TrainingAndValidationQualities"]; }
    123123    }
    124124    public IValueLookupParameter<DoubleValue> PercentileParameter {
     
    187187      Parameters.Add(new LookupParameter<ResultCollection>("Results"));
    188188      Parameters.Add(new LookupParameter<DoubleValue>("InitialTrainingQuality"));
    189       Parameters.Add(new LookupParameter<DoubleMatrix>("TrainingAndValidationQualities"));
     189      Parameters.Add(new LookupParameter<ItemList<DoubleMatrix>>("TrainingAndValidationQualities"));
    190190      Parameters.Add(new ValueLookupParameter<DoubleValue>("Percentile", new DoubleValue(1)));
    191191
     
    207207      //}
    208208      if (!Parameters.ContainsKey("TrainingAndValidationQualities")) {
    209         Parameters.Add(new LookupParameter<DoubleMatrix>("TrainingAndValidationQualities"));
     209        Parameters.Add(new LookupParameter<ItemList<DoubleMatrix>>("TrainingAndValidationQualities"));
    210210      }
    211211      if (!Parameters.ContainsKey("Percentile")) {
     
    290290      double[] validationArr = new double[n];
    291291      double[] trainingArr = new double[n];
    292       //double[,] qualitiesArr = new double[n, 2];
     292      double[,] qualitiesArr = new double[n, 2];
    293293      for (int i = 0; i < n; i++) {
    294294        validationArr[i] = orderedDistinctPairs[i].Validation;
    295295        trainingArr[i] = orderedDistinctPairs[i].Training;
    296296
    297         //qualitiesArr[i, 0] = trainingArr[i];
    298         //qualitiesArr[i, 1] = validationArr[i];
     297        qualitiesArr[i, 0] = trainingArr[i];
     298        qualitiesArr[i, 1] = validationArr[i];
    299299      }
    300300      double r = alglib.correlation.spearmanrankcorrelation(trainingArr, validationArr, n);
     
    309309
    310310      OverfittingParameter.ActualValue = new BoolValue(overfitting);
    311       //TrainingAndValidationQualitiesParameter.ActualValue = new DoubleMatrix(qualitiesArr);
     311      ItemList<DoubleMatrix> list = TrainingAndValidationQualitiesParameter.ActualValue;
     312      if (list == null) {
     313        TrainingAndValidationQualitiesParameter.ActualValue = new ItemList<DoubleMatrix>();
     314      }
     315      TrainingAndValidationQualitiesParameter.ActualValue.Add(new DoubleMatrix(qualitiesArr));
    312316      return base.Apply();
    313317    }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionSolution.cs

    r4443 r5010  
    6161          let boundedX = Math.Min(UpperEstimationLimit, Math.Max(LowerEstimationLimit, x))
    6262          select double.IsNaN(boundedX) ? UpperEstimationLimit : boundedX;
    63       estimatedValues = Enumerable.Repeat(double.NaN, Math.Abs(minLag)).Concat(calculatedValues).ToList();
     63      estimatedValues = Enumerable.Repeat(UpperEstimationLimit, Math.Abs(minLag)).Concat(calculatedValues).ToList();
    6464      OnEstimatedValuesChanged();
    6565    }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.Views/3.3/RunCollectionMonteCarloVariableImpactView.cs

    r4475 r5010  
    7979    }
    8080
    81     private DoubleMatrix CalculateVariableImpactMatrix() {
     81    public DoubleMatrix CalculateVariableImpactMatrix() {
    8282      DoubleMatrix matrix = null;
    8383      if (Content != null) {
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.Views/3.3/RunCollectionVariableImpactView.cs

    r4143 r5010  
    7676    }
    7777
    78     private DoubleMatrix CalculateVariableImpactMatrix() {
     78    public DoubleMatrix CalculateVariableImpactMatrix() {
    7979      DoubleMatrix matrix = null;
    8080      if (Content != null) {
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.Views/3.3/RunCollectionWinklerVariableImpactView.cs

    r4475 r5010  
    7979    }
    8080
    81     private DoubleMatrix CalculateVariableImpactMatrix() {
     81    public DoubleMatrix CalculateVariableImpactMatrix() {
    8282      DoubleMatrix matrix = null;
    8383      if (Content != null) {
Note: See TracChangeset for help on using the changeset viewer.