Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/13/17 12:55:06 (8 years ago)
Author:
abeham
Message:

#2701: Updated branch to trunk

Location:
branches/MemPRAlgorithm
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/MemPRAlgorithm

  • branches/MemPRAlgorithm/HeuristicLab.Problems.DataAnalysis

  • branches/MemPRAlgorithm/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblemData.cs

    r14400 r14562  
    4141
    4242    #region parameter properites
     43    //mkommend: inserted parameter caching due to performance reasons
     44    private IFixedValueParameter<Dataset> datasetParameter;
    4345    public IFixedValueParameter<Dataset> DatasetParameter {
    44       get { return (IFixedValueParameter<Dataset>)Parameters[DatasetParameterName]; }
    45     }
     46      get {
     47        if (datasetParameter == null) datasetParameter = (IFixedValueParameter<Dataset>)Parameters[DatasetParameterName];
     48        return datasetParameter;
     49      }
     50    }
     51
     52    private IFixedValueParameter<ReadOnlyCheckedItemList<StringValue>> inputVariablesParameter;
    4653    public IFixedValueParameter<ReadOnlyCheckedItemList<StringValue>> InputVariablesParameter {
    47       get { return (IFixedValueParameter<ReadOnlyCheckedItemList<StringValue>>)Parameters[InputVariablesParameterName]; }
    48     }
     54      get {
     55        if (inputVariablesParameter == null) inputVariablesParameter = (IFixedValueParameter<ReadOnlyCheckedItemList<StringValue>>)Parameters[InputVariablesParameterName];
     56        return inputVariablesParameter;
     57      }
     58    }
     59
     60    private IFixedValueParameter<IntRange> trainingPartitionParameter;
    4961    public IFixedValueParameter<IntRange> TrainingPartitionParameter {
    50       get { return (IFixedValueParameter<IntRange>)Parameters[TrainingPartitionParameterName]; }
    51     }
     62      get {
     63        if (trainingPartitionParameter == null) trainingPartitionParameter = (IFixedValueParameter<IntRange>)Parameters[TrainingPartitionParameterName];
     64        return trainingPartitionParameter;
     65      }
     66    }
     67
     68    private IFixedValueParameter<IntRange> testPartitionParameter;
    5269    public IFixedValueParameter<IntRange> TestPartitionParameter {
    53       get { return (IFixedValueParameter<IntRange>)Parameters[TestPartitionParameterName]; }
    54     }
     70      get {
     71        if (testPartitionParameter == null) testPartitionParameter = (IFixedValueParameter<IntRange>)Parameters[TestPartitionParameterName];
     72        return testPartitionParameter;
     73      }
     74    }
     75
    5576    public IFixedValueParameter<ReadOnlyItemList<ITransformation>> TransformationsParameter {
    5677      get { return (IFixedValueParameter<ReadOnlyItemList<ITransformation>>)Parameters[TransformationsParameterName]; }
     
    102123    public virtual bool IsTrainingSample(int index) {
    103124      return index >= 0 && index < Dataset.Rows &&
    104         TrainingPartition.Start <= index && index < TrainingPartition.End &&
    105         (index < TestPartition.Start || TestPartition.End <= index);
     125             TrainingPartition.Start <= index && index < TrainingPartition.End &&
     126             (index < TestPartition.Start || TestPartition.End <= index);
    106127    }
    107128
     
    214235        InputVariables.SetItemCheckedState(inputVariable, variable != null && data.InputVariables.ItemChecked(variable));
    215236      }
    216 
    217       TrainingPartition.Start = TrainingPartition.End = 0;
    218       TestPartition.Start = 0;
    219       TestPartition.End = Dataset.Rows;
    220237    }
    221238  }
  • branches/MemPRAlgorithm/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolutionVariableImpactsCalculator.cs

    r14348 r14562  
    122122      }
    123123
    124 
    125124      var impacts = new Dictionary<string, double>();
    126125      var modifiableDataset = ((Dataset)dataset).ToModifiable();
    127126
    128       foreach (var inputVariable in problemData.AllowedInputVariables) {
     127      var inputvariables = new HashSet<string>(problemData.AllowedInputVariables.Union(solution.Model.VariablesUsedForPrediction));
     128      var allowedInputVariables = dataset.VariableNames.Where(v => inputvariables.Contains(v)).ToList();
     129
     130      foreach (var inputVariable in allowedInputVariables) {
    129131        var newEstimates = EvaluateModelWithReplacedVariable(solution.Model, inputVariable, modifiableDataset, rows, replacement);
    130132        var newR2 = OnlinePearsonsRCalculator.Calculate(targetValues, newEstimates, out error);
  • branches/MemPRAlgorithm/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisSolution.cs

    r14185 r14562  
    2121
    2222using System.Collections.Generic;
     23using System.Linq;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    4344      return Model.GetPrognosedValues(ProblemData.Dataset, rows, horizons);
    4445    }
     46
     47    public override IEnumerable<double> PrognosedTestValues {
     48      get {
     49        return Model.GetPrognosedValues(ProblemData.Dataset, ProblemData.TestIndices.Take(1),
     50          new int[] { ProblemData.TestIndices.Count() }).First();
     51      }
     52    }
    4553  }
    4654}
  • branches/MemPRAlgorithm/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisSolutionBase.cs

    r14185 r14562  
    6464    }
    6565
     66    public abstract IEnumerable<double> PrognosedTestValues { get; }
    6667    public abstract IEnumerable<IEnumerable<double>> GetPrognosedValues(IEnumerable<int> rows, IEnumerable<int> horizon);
    6768
     
    150151      OnlineCalculatorError errorState;
    151152      double trainingMean = ProblemData.TrainingIndices.Any() ? ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices).Average() : double.NaN;
    152       var meanModel = new ConstantModel(trainingMean,ProblemData.TargetVariable);
     153      var meanModel = new ConstantModel(trainingMean, ProblemData.TargetVariable);
    153154
    154155      double alpha, beta;
Note: See TracChangeset for help on using the changeset viewer.