Free cookie consent management tool by TermsFeed Policy Generator

Changeset 18034


Ignore:
Timestamp:
07/27/21 14:43:06 (3 years ago)
Author:
chaider
Message:

#3073 Moved VariableRanges from RegressionProblemData to DataAnalysisProblemData to make it also available in classification problems

Location:
trunk/HeuristicLab.Problems.DataAnalysis/3.4
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblemData.cs

    r17180 r18034  
    3838    protected const string TestPartitionParameterName = "TestPartition";
    3939    protected const string TransformationsParameterName = "Transformations";
     40    protected const string VariableRangesParameterName = "VariableRanges";
    4041
    4142    #region parameter properites
     
    4849      }
    4950    }
     51
     52    public IFixedValueParameter<IntervalCollection> VariableRangesParameter => (IFixedValueParameter<IntervalCollection>)Parameters[VariableRangesParameterName];
     53    public IntervalCollection VariableRanges => VariableRangesParameter.Value;
    5054
    5155    private IFixedValueParameter<ReadOnlyCheckedItemList<StringValue>> inputVariablesParameter;
     
    151155        TransformationsParameter.Hidden = true;
    152156      }
     157      if (!Parameters.ContainsKey(VariableRangesParameterName)) {
     158        var variableRanges = Dataset.GetVariableRanges();
     159        Parameters.Add(new FixedValueParameter<IntervalCollection>(VariableRangesParameterName, variableRanges));
     160      }
    153161      RegisterEventHandlers();
    154162    }
    155163
    156     protected DataAnalysisProblemData(IDataset dataset, IEnumerable<string> allowedInputVariables, IEnumerable<ITransformation> transformations = null) {
     164    protected DataAnalysisProblemData(IDataset dataset, IEnumerable<string> allowedInputVariables, IEnumerable<ITransformation> transformations = null, IntervalCollection variableRanges = null) {
    157165      if (dataset == null) throw new ArgumentNullException("The dataset must not be null.");
    158166      if (allowedInputVariables == null) throw new ArgumentNullException("The allowed input variables must not be null.");
     
    178186      Parameters.Add(new FixedValueParameter<IntRange>(TestPartitionParameterName, "", new IntRange(testPartitionStart, testPartitionEnd)));
    179187      Parameters.Add(new FixedValueParameter<ReadOnlyItemList<ITransformation>>(TransformationsParameterName, "", transformationsList.AsReadOnly()));
     188
     189      if (variableRanges == null) {
     190        variableRanges = Dataset.GetVariableRanges();
     191      }
     192      Parameters.Add(new FixedValueParameter<IntervalCollection>(VariableRangesParameterName, variableRanges));
    180193
    181194      TransformationsParameter.Hidden = true;
  • trunk/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionProblemData.cs

    r18000 r18034  
    3434  public class RegressionProblemData : DataAnalysisProblemData, IRegressionProblemData, IStorableContent {
    3535    protected const string TargetVariableParameterName = "TargetVariable";
    36     protected const string VariableRangesParameterName = "VariableRanges";
     36    //protected const string VariableRangesParameterName = "VariableRanges";
    3737    public string Filename { get; set; }
    3838
     
    9999    #region parameter properties
    100100    public IConstrainedValueParameter<StringValue> TargetVariableParameter => (IConstrainedValueParameter<StringValue>)Parameters[TargetVariableParameterName];
    101     public IFixedValueParameter<IntervalCollection> VariableRangesParameter => (IFixedValueParameter<IntervalCollection>)Parameters[VariableRangesParameterName];
     101    /*public IFixedValueParameter<IntervalCollection> VariableRangesParameter => (IFixedValueParameter<IntervalCollection>)Parameters[VariableRangesParameterName];
    102102    #endregion
    103103
     
    105105    public IntervalCollection VariableRanges {
    106106      get => VariableRangesParameter.Value;
    107     }
     107    }*/
    108108
    109109    public string TargetVariable {
     
    129129    [StorableHook(HookType.AfterDeserialization)]
    130130    private void AfterDeserialization() {
    131       if (!Parameters.ContainsKey(VariableRangesParameterName)) {
     131      /*if (!Parameters.ContainsKey(VariableRangesParameterName)) {
    132132        var variableRanges = Dataset.GetVariableRanges();
    133133        Parameters.Add(new FixedValueParameter<IntervalCollection>(VariableRangesParameterName, variableRanges));
    134       }
     134      }*/
    135135
    136136      RegisterParameterEvents();
     
    158158
    159159    public RegressionProblemData(IDataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable,
    160       IEnumerable<ITransformation> transformations = null,
    161       IntervalCollection variableRanges = null)
     160      IEnumerable<ITransformation> transformations = null/*,
     161      IntervalCollection variableRanges = null*/)
    162162      : base(dataset, allowedInputVariables, transformations ?? Enumerable.Empty<ITransformation>()) {
    163163      var variables = InputVariables.Select(x => x.AsReadOnly()).ToList();
    164164      Parameters.Add(new ConstrainedValueParameter<StringValue>(TargetVariableParameterName, new ItemSet<StringValue>(variables), variables.Where(x => x.Value == targetVariable).First()));
    165       if (variableRanges == null) {
     165      /*if (variableRanges == null) {
    166166        variableRanges = Dataset.GetVariableRanges();
    167167      }
    168       Parameters.Add(new FixedValueParameter<IntervalCollection>(VariableRangesParameterName, variableRanges));
     168      Parameters.Add(new FixedValueParameter<IntervalCollection>(VariableRangesParameterName, variableRanges));*/
    169169    }
    170170    private void RegisterParameterEvents() {
  • trunk/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/ShapeConstrainedRegressionProblemData.cs

    r17999 r18034  
    152152                                                 IntRange trainingPartition, IntRange testPartition,
    153153                                                 IEnumerable<ITransformation> transformations = null, ShapeConstraints sc = null, IntervalCollection variableRanges = null)
    154     : base(dataset, allowedInputVariables, targetVariable, transformations ?? Enumerable.Empty<ITransformation>(), variableRanges) {
     154    : base(dataset, allowedInputVariables, targetVariable, transformations ?? Enumerable.Empty<ITransformation>()) {
    155155      TrainingPartition.Start = trainingPartition.Start;
    156156      TrainingPartition.End = trainingPartition.End;
  • trunk/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataAnalysisProblemData.cs

    r17180 r18034  
    3535    IEnumerable<string> AllowedInputVariables { get; }
    3636
     37    IntervalCollection VariableRanges { get; }
     38
    3739    double[,] AllowedInputsTrainingValues { get; }
    3840    double[,] AllowedInputsTestValues { get; }
  • trunk/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Regression/IRegressionProblemData.cs

    r17958 r18034  
    2929  public interface IRegressionProblemData : IDataAnalysisProblemData {
    3030    string TargetVariable { get; set; }
    31     IntervalCollection VariableRanges { get; }
     31   
    3232    IEnumerable<double> TargetVariableValues { get; }
    3333    IEnumerable<double> TargetVariableTrainingValues { get; }
Note: See TracChangeset for help on using the changeset viewer.