Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/30/21 12:18:19 (3 years ago)
Author:
gkronber
Message:

#3106 merged r17856:17969 from trunk to branch

Location:
branches/3106_AnalyticContinuedFractionsRegression
Files:
14 edited
7 copied

Legend:

Unmodified
Added
Removed
  • branches/3106_AnalyticContinuedFractionsRegression

  • branches/3106_AnalyticContinuedFractionsRegression/HeuristicLab.Problems.DataAnalysis

  • branches/3106_AnalyticContinuedFractionsRegression/HeuristicLab.Problems.DataAnalysis/3.4

  • branches/3106_AnalyticContinuedFractionsRegression/HeuristicLab.Problems.DataAnalysis/3.4/DatasetExtensions.cs

    r17180 r17970  
    9696    }
    9797
     98    public static IntervalCollection GetIntervals(this IDataset dataset) {
     99      IntervalCollection intervalCollection = new IntervalCollection();
     100      foreach (var variable in dataset.DoubleVariables) { // intervals are only possible for double variables
     101        var variableInterval = Interval.GetInterval(dataset.GetDoubleValues(variable));
     102        intervalCollection.AddInterval(variable, variableInterval);
     103      }
     104
     105      return intervalCollection;
     106    }
     107
    98108    public static IEnumerable<KeyValuePair<string, IEnumerable<string>>> GetFactorVariableValues(
    99109      this IDataset ds, IEnumerable<string> factorVariables, IEnumerable<int> rows) {
  • branches/3106_AnalyticContinuedFractionsRegression/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj

    r17579 r17970  
    9999  </PropertyGroup>
    100100  <ItemGroup>
    101     <Reference Include="ALGLIB-3.7.0, Version=3.7.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    102       <HintPath>..\..\bin\ALGLIB-3.7.0.dll</HintPath>
     101    <Reference Include="ALGLIB-3.17.0, Version=3.17.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     102      <SpecificVersion>False</SpecificVersion>
     103      <HintPath>..\..\bin\ALGLIB-3.17.0.dll</HintPath>
    103104      <Private>False</Private>
    104105    </Reference>
     
    145146    <Compile Include="Implementation\Regression\ConstantRegressionModel.cs" />
    146147    <Compile Include="Implementation\Regression\ConstantRegressionSolution.cs" />
     148    <Compile Include="Implementation\Regression\ShapeConstrainedRegressionProblem.cs" />
     149    <Compile Include="Implementation\Regression\ShapeConstrainedRegressionProblemData.cs" />
     150    <Compile Include="Implementation\Regression\ShapeConstraint.cs" />
     151    <Compile Include="Implementation\Regression\ShapeConstraints.cs" />
    147152    <Compile Include="Implementation\Regression\RegressionEnsembleProblemData.cs" />
    148153    <Compile Include="Implementation\Regression\RegressionEnsembleModel.cs">
     
    152157    <Compile Include="Implementation\Regression\RegressionModel.cs" />
    153158    <Compile Include="Implementation\Regression\RegressionSolutionVariableImpactsCalculator.cs" />
     159    <Compile Include="Implementation\Regression\ShapeConstraintsParser.cs" />
    154160    <Compile Include="Implementation\TimeSeriesPrognosis\Models\ConstantTimeSeriesPrognosisModel.cs" />
    155161    <Compile Include="Implementation\TimeSeriesPrognosis\Models\TimeSeriesPrognosisAutoRegressiveModel.cs" />
     
    187193    <Compile Include="Interfaces\Regression\IRegressionEnsembleSolution.cs" />
    188194    <Compile Include="Implementation\Regression\RegressionSolutionBase.cs" />
     195    <Compile Include="Interfaces\Regression\IShapeConstrainedRegressionProblem.cs" />
     196    <Compile Include="Interfaces\Regression\IShapeConstrainedRegressionProblemData.cs" />
    189197    <Compile Include="Interfaces\TimeSeriesPrognosis\IOnlineTimeSeriesCalculator.cs" />
    190198    <Compile Include="Interfaces\TimeSeriesPrognosis\ITimeSeriesPrognosisModel.cs" />
  • branches/3106_AnalyticContinuedFractionsRegression/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationSolutionBase.cs

    r17180 r17970  
    3434    private const string TrainingAccuracyResultName = "Accuracy (training)";
    3535    private const string TestAccuracyResultName = "Accuracy (test)";
    36     private const string TrainingNormalizedGiniCoefficientResultName = "Normalized Gini Coefficient (training)";
    37     private const string TestNormalizedGiniCoefficientResultName = "Normalized Gini Coefficient (test)";
     36    private const string TrainingNormalizedGiniCoefficientResultName = "Norm. Gini coeff. (training)";
     37    private const string TestNormalizedGiniCoefficientResultName = "Norm. Gini coeff. (test)";
    3838    private const string ClassificationPerformanceMeasuresResultName = "Classification Performance Measures";
    3939
     
    9797      if (string.IsNullOrEmpty(Model.TargetVariable))
    9898        Model.TargetVariable = this.ProblemData.TargetVariable;
    99 
    100       if (!this.ContainsKey(TrainingNormalizedGiniCoefficientResultName))
     99      var newResult = false;
     100      if (!this.ContainsKey(TrainingNormalizedGiniCoefficientResultName)) {
    101101        Add(new Result(TrainingNormalizedGiniCoefficientResultName, "Normalized Gini coefficient of the model on the training partition.", new DoubleValue()));
    102       if (!this.ContainsKey(TestNormalizedGiniCoefficientResultName))
     102        newResult = true;
     103      }
     104      if (!this.ContainsKey(TestNormalizedGiniCoefficientResultName)) {
    103105        Add(new Result(TestNormalizedGiniCoefficientResultName, "Normalized Gini coefficient of the model on the test partition.", new DoubleValue()));
     106        newResult = true;
     107      }
    104108      if (!this.ContainsKey(ClassificationPerformanceMeasuresResultName)) {
    105109        Add(new Result(ClassificationPerformanceMeasuresResultName, @"Classification performance measures.\n
    106110                              In a multiclass classification all misclassifications of the negative class will be treated as true negatives except on positive class estimations.",
    107111                              new ClassificationPerformanceMeasuresResultCollection()));
    108         CalculateClassificationResults();
     112        newResult = true;
    109113      }
     114      if (newResult) CalculateClassificationResults();
    110115    }
    111116
  • branches/3106_AnalyticContinuedFractionsRegression/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/DiscriminantFunctionClassificationSolutionBase.cs

    r17180 r17970  
    4040    private const string TrainingRSquaredResultName = "Pearson's R² (training)";
    4141    private const string TestRSquaredResultName = "Pearson's R² (test)";
     42    private const string TrainingNormalizedGiniCoefficientResultName = "Norm. Gini coeff. (training, discriminant values)";
     43    private const string TestNormalizedGiniCoefficientResultName = "Norm. Gini coeff. (test, discriminant values)";
     44
    4245
    4346    public new IDiscriminantFunctionClassificationModel Model {
     
    7174      private set { ((DoubleValue)this[TestRSquaredResultName].Value).Value = value; }
    7275    }
     76    public double TrainingNormalizedGiniCoefficientForDiscriminantValues {
     77      get { return ((DoubleValue)this[TrainingNormalizedGiniCoefficientResultName].Value).Value; }
     78      protected set { ((DoubleValue)this[TrainingNormalizedGiniCoefficientResultName].Value).Value = value; }
     79    }
     80    public double TestNormalizedGiniCoefficientForDiscriminantValues {
     81      get { return ((DoubleValue)this[TestNormalizedGiniCoefficientResultName].Value).Value; }
     82      protected set { ((DoubleValue)this[TestNormalizedGiniCoefficientResultName].Value).Value = value; }
     83    }
    7384    #endregion
    7485
     
    8596      Add(new Result(TrainingRSquaredResultName, "Squared Pearson's correlation coefficient of the model output and the actual values on the training partition", new DoubleValue()));
    8697      Add(new Result(TestRSquaredResultName, "Squared Pearson's correlation coefficient of the model output and the actual values on the test partition", new DoubleValue()));
     98      Add(new Result(TrainingNormalizedGiniCoefficientResultName, "Normalized Gini coefficient of the discriminant values produced by the model on the training partition.", new DoubleValue()));
     99      Add(new Result(TestNormalizedGiniCoefficientResultName, "Normalized Gini coefficient of the discriminant values produced by the model on the test partition.", new DoubleValue()));
    87100      RegisterEventHandler();
    88101    }
     
    90103    [StorableHook(HookType.AfterDeserialization)]
    91104    private void AfterDeserialization() {
     105      #region backwards compatibility
     106      if (!ContainsKey(TrainingNormalizedGiniCoefficientResultName)) {
     107        Add(new Result(TrainingNormalizedGiniCoefficientResultName, "Normalized Gini coefficient of the discriminant values produced by the model on the training partition.", new DoubleValue()));
     108        Add(new Result(TestNormalizedGiniCoefficientResultName, "Normalized Gini coefficient of the discriminant values produced by the model on the test partition.", new DoubleValue()));
     109        double[] estimatedTrainingValues = EstimatedTrainingValues.ToArray(); // cache values
     110        double[] originalTrainingValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices).ToArray();
     111        double[] estimatedTestValues = EstimatedTestValues.ToArray(); // cache values
     112        double[] originalTestValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TestIndices).ToArray();
     113        double trainingNormalizedGini = NormalizedGiniCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out var errorState);
     114        if (errorState != OnlineCalculatorError.None) trainingNormalizedGini = double.NaN;
     115        double testNormalizedGini = NormalizedGiniCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
     116        if (errorState != OnlineCalculatorError.None) testNormalizedGini = double.NaN;
     117
     118        TrainingNormalizedGiniCoefficientForDiscriminantValues = trainingNormalizedGini;
     119        TestNormalizedGiniCoefficientForDiscriminantValues = testNormalizedGini;
     120      }
     121      #endregion
    92122      RegisterEventHandler();
    93123    }
     
    106136
    107137      double trainingR = OnlinePearsonsRCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
    108       TrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR*trainingR : double.NaN;
     138      TrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR * trainingR : double.NaN;
    109139      double testR = OnlinePearsonsRCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
    110       TestRSquared = errorState == OnlineCalculatorError.None ? testR*testR : double.NaN;
     140      TestRSquared = errorState == OnlineCalculatorError.None ? testR * testR : double.NaN;
    111141
    112142      double trainingNormalizedGini = NormalizedGiniCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
     
    115145      if (errorState != OnlineCalculatorError.None) testNormalizedGini = double.NaN;
    116146
    117       TrainingNormalizedGiniCoefficient = trainingNormalizedGini;
    118       TestNormalizedGiniCoefficient = testNormalizedGini;
     147      TrainingNormalizedGiniCoefficientForDiscriminantValues = trainingNormalizedGini;
     148      TestNormalizedGiniCoefficientForDiscriminantValues = testNormalizedGini;
    119149    }
    120150
  • branches/3106_AnalyticContinuedFractionsRegression/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/Interval.cs

    r17583 r17970  
    3333    [Storable]
    3434    public double UpperBound { get; private set; }
     35
     36    public double Width => UpperBound - LowerBound;
    3537
    3638    [StorableConstructor]
     
    6769    }
    6870
     71    private Interval(double v) : this(v, v) { }
     72
    6973    public bool Contains(double value) {
    7074      return LowerBound <= value && value <= UpperBound;
     
    7478      if (double.IsNegativeInfinity(LowerBound) && double.IsPositiveInfinity(UpperBound)) return true;
    7579      if (other.LowerBound >= LowerBound && other.UpperBound <= UpperBound) return true;
    76  
     80
    7781      return false;
    7882    }
     
    9397    /// </summary>
    9498    public bool IsPositive {
    95       get => LowerBound > 0.0; 
     99      get => LowerBound > 0.0;
    96100    }
    97101
     
    126130        return false;
    127131
    128       return (UpperBound.IsAlmost(other.UpperBound) || (double.IsNaN(UpperBound) && double.IsNaN(other.UpperBound)))
    129         && (LowerBound.IsAlmost(other.LowerBound) || (double.IsNaN(LowerBound) && double.IsNaN(other.LowerBound)));
     132      return (UpperBound == other.UpperBound || (double.IsNaN(UpperBound) && double.IsNaN(other.UpperBound)))
     133        && (LowerBound == other.LowerBound || (double.IsNaN(LowerBound) && double.IsNaN(other.LowerBound)));
    130134    }
    131135
     
    234238    public static Interval Cube(Interval a) {
    235239      return new Interval(Math.Pow(a.LowerBound, 3), Math.Pow(a.UpperBound, 3));
     240    }
     241
     242    public static Interval Power(Interval a, int b) {
     243      if (b < 0) return Power(1.0 / a, -b); // a^(-b) = 1/(a^b)
     244      if (b == 0 && (a.Contains(0.0) || a.IsInfiniteOrUndefined)) return new Interval(double.NaN, double.NaN);  // 0^0, +/-inf^0 are undefined
     245      if (b == 0) return new Interval(1.0, 1.0); // x^0 = 1
     246      if (b == 1) return a;
     247      if (b % 2 == 0) {
     248        // even powers (see x²)
     249        if (a.UpperBound <= 0) return new Interval(Math.Pow(a.UpperBound, b), Math.Pow(a.LowerBound, b));     // interval is negative
     250        if (a.LowerBound >= 0) return new Interval(Math.Pow(a.LowerBound, b), Math.Pow(a.UpperBound, b)); // interval is positive
     251        return new Interval(0, Math.Max(Math.Pow(a.LowerBound, b), Math.Pow(a.UpperBound, b))); // interval goes over zero
     252      } else {
     253        // odd powers (see x³)
     254        return new Interval(Math.Pow(a.LowerBound, b), Math.Pow(a.UpperBound, b));
     255      }
    236256    }
    237257
     
    267287    }
    268288
    269     public static Interval AnalyticalQuotient(Interval a, Interval b) {
     289    public static Interval AnalyticQuotient(Interval a, Interval b) {
    270290      var dividend = a;
    271291      var divisor = Add(Square(b), new Interval(1.0, 1.0));
     
    276296    }
    277297    #endregion
     298
     299    #region arithmetic overloads
     300    public static Interval operator +(Interval a, Interval b) => Add(a, b);
     301    public static Interval operator +(Interval a, double b) => Add(a, new Interval(b));
     302    public static Interval operator +(double a, Interval b) => Add(new Interval(a), b);
     303    public static Interval operator -(Interval a, Interval b) => Subtract(a, b);
     304    public static Interval operator -(Interval a, double b) => Subtract(a, new Interval(b));
     305    public static Interval operator -(double a, Interval b) => Subtract(new Interval(a), b);
     306    public static Interval operator -(Interval a) => Subtract(new Interval(0), a);
     307    public static Interval operator *(Interval a, Interval b) => Multiply(a, b);
     308    public static Interval operator *(Interval a, double b) => Multiply(a, new Interval(b));
     309    public static Interval operator *(double a, Interval b) => Multiply(new Interval(a), b);
     310    public static Interval operator /(Interval a, Interval b) => Divide(a, b);
     311    public static Interval operator /(Interval a, double b) => Divide(a, new Interval(b));
     312    public static Interval operator /(double a, Interval b) => Divide(new Interval(a), b);
     313    public static Interval Exponential(double a) { return Exponential(new Interval(a)); }
     314    public static Interval Logarithm(double a) { return Logarithm(new Interval(a)); }
     315    public static Interval Sine(double a) { return Sine(new Interval(a)); }
     316    public static Interval Cosine(double a) { return Cosine(new Interval(a)); }
     317    public static Interval Tangens(double a) { return Tangens(new Interval(a)); }
     318    public static Interval HyperbolicTangent(double a) { return HyperbolicTangent(new Interval(a)); }
     319    public static Interval Square(double a) { return Square(new Interval(a)); }
     320    public static Interval Cube(double a) { return Cube(new Interval(a)); }
     321    public static Interval SquareRoot(double a) { return SquareRoot(new Interval(a)); }
     322    public static Interval CubicRoot(double a) { return CubicRoot(new Interval(a)); }
     323    public static Interval Absolute(double a) { return Absolute(new Interval(a)); }
     324    public static Interval AnalyticQuotient(Interval a, double b) { return AnalyticQuotient(a, new Interval(b)); }
     325    public static Interval AnalyticQuotient(double a, Interval b) { return AnalyticQuotient(new Interval(a), b); }
     326    public static Interval AnalyticQuotient(double a, double b) { return AnalyticQuotient(new Interval(a), new Interval(b)); }
     327    #endregion
    278328  }
    279329}
  • branches/3106_AnalyticContinuedFractionsRegression/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/IntervalCollection.cs

    r17564 r17970  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2019 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    3434      get => HeuristicLab.Common.Resources.VSImageLibrary.Object;
    3535    }
    36     private IDictionary<string, Interval> intervals { get; } = new Dictionary<string, Interval>();
    3736
    38     [Storable(Name = "StorableIntervalInformation")]
     37    private IDictionary<string, Interval> intervals { get; set; } = new Dictionary<string, Interval>();
     38
     39    [Storable(OldName = "StorableIntervalInformation")]
    3940    private KeyValuePair<string, double[]>[] StorableIntervalInformation {
     41      set {
     42        foreach (var varInt in value)
     43          intervals.Add(varInt.Key, new Interval(varInt.Value[0], varInt.Value[1]));
     44      }
     45    }
     46
     47    [Storable]
     48    private object[] StorableIntervals {
    4049      get {
    41         var l = new List<KeyValuePair<string, double[]>>();
    42         foreach (var varInt in intervals)
     50        var names = intervals.Keys.ToArray();
     51        var lowerBounds = intervals.Values.Select(i => i.LowerBound).ToArray();
     52        var upperBounds = intervals.Values.Select(i => i.UpperBound).ToArray();
    4353
    44           l.Add(new KeyValuePair<string, double[]>(varInt.Key,
    45             new double[] { varInt.Value.LowerBound, varInt.Value.UpperBound }));
    46         return l.ToArray();
     54        return new object[] { names, lowerBounds, upperBounds };
    4755      }
    4856
    4957      set {
    50         foreach (var varInt in value)
    51           intervals.Add(varInt.Key, new Interval(varInt.Value[0], varInt.Value[1]));
     58        var names = (string[])value[0];
     59        var lowerBounds = (double[])value[1];
     60        var upperBounds = (double[])value[2];
     61
     62        for (int i = 0; i < names.Length; i++) {
     63          intervals.Add(names[i], new Interval(lowerBounds[i], upperBounds[i]));
     64        }
    5265      }
    5366    }
     
    8093    public void SetInterval(string identifier, Interval interval) {
    8194      intervals[identifier] = interval;
     95      RaiseChanged();
    8296    }
    8397
    8498    public void AddInterval(string identifier, Interval interval) {
    8599      intervals.Add(identifier, interval);
     100      RaiseChanged();
    86101    }
    87102
    88103    public void DeleteInterval(string identifier) {
    89104      intervals.Remove(identifier);
     105      RaiseChanged();
    90106    }
    91107
    92108    public IReadOnlyDictionary<string, Interval> GetReadonlyDictionary() {
     109      return intervals.ToDictionary(pair => pair.Key, pair => pair.Value);
     110    }
     111
     112    public IDictionary<string, Interval> GetDictionary() {
    93113      return intervals.ToDictionary(pair => pair.Key, pair => pair.Value);
    94114    }
     
    98118        yield return Tuple.Create(variableInterval.Key, variableInterval.Value);
    99119    }
     120
     121    public event EventHandler Changed;
     122    private void RaiseChanged() {
     123      var handler = Changed;
     124      if (handler != null)
     125        handler(this, EventArgs.Empty);
     126    }
     127
    100128  }
    101129}
  • branches/3106_AnalyticContinuedFractionsRegression/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionProblemData.cs

    r17579 r17970  
    3535    protected const string TargetVariableParameterName = "TargetVariable";
    3636    protected const string VariableRangesParameterName = "VariableRanges";
    37     protected const string IntervalConstraintsParameterName = "IntervalConstraints";
    3837    public string Filename { get; set; }
    3938
     
    7877      defaultDataset = new Dataset(new string[] { "y", "x" }, kozaF1);
    7978      defaultDataset.Name = "Fourth-order Polynomial Function Benchmark Dataset";
    80       defaultDataset.Description = "f(x) = x^4 + x^3 + x^2 + x^1";
     79      defaultDataset.Description = "f(x) = x^4 + x^3 + x^2 + x";
    8180      defaultAllowedInputVariables = new List<string>() { "x" };
    8281      defaultTargetVariable = "y";
     
    9897    #endregion
    9998
    100     public IConstrainedValueParameter<StringValue> TargetVariableParameter {
    101       get { return (IConstrainedValueParameter<StringValue>)Parameters[TargetVariableParameterName]; }
    102     }
     99    #region parameter properties
     100    public IConstrainedValueParameter<StringValue> TargetVariableParameter => (IConstrainedValueParameter<StringValue>)Parameters[TargetVariableParameterName];
     101    public IFixedValueParameter<IntervalCollection> VariableRangesParameter => (IFixedValueParameter<IntervalCollection>)Parameters[VariableRangesParameterName];
     102    #endregion
    103103
    104     public IFixedValueParameter<IntervalCollection> VariableRangesParameter => (IFixedValueParameter<IntervalCollection>)Parameters[VariableRangesParameterName];
    105 
     104    #region properties
    106105    public IntervalCollection VariableRanges {
    107106      get => VariableRangesParameter.Value;
    108107    }
    109 
    110108
    111109    public string TargetVariable {
     
    120118      }
    121119    }
     120    public IEnumerable<double> TargetVariableValues => Dataset.GetDoubleValues(TargetVariable);
     121    public IEnumerable<double> TargetVariableTrainingValues => Dataset.GetDoubleValues(TargetVariable, TrainingIndices);
     122    public IEnumerable<double> TargetVariableTestValues => Dataset.GetDoubleValues(TargetVariable, TestIndices);
     123    #endregion
    122124
    123     public IEnumerable<double> TargetVariableValues {
    124       get { return Dataset.GetDoubleValues(TargetVariable); }
    125     }
    126     public IEnumerable<double> TargetVariableTrainingValues {
    127       get { return Dataset.GetDoubleValues(TargetVariable, TrainingIndices); }
    128     }
    129     public IEnumerable<double> TargetVariableTestValues {
    130       get { return Dataset.GetDoubleValues(TargetVariable, TestIndices); }
    131     }
    132125
    133126
     
    137130    private void AfterDeserialization() {
    138131      if (!Parameters.ContainsKey(VariableRangesParameterName)) {
    139         var intervalCollection = CalculateDatasetIntervals(this.Dataset);
     132        var intervalCollection = Dataset.GetIntervals();
    140133        Parameters.Add(new FixedValueParameter<IntervalCollection>(VariableRangesParameterName, intervalCollection));
    141134      }
     135
    142136      RegisterParameterEvents();
    143137    }
     
    163157    }
    164158
    165     public RegressionProblemData(IDataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable, IEnumerable<ITransformation> transformations = null)
     159    public RegressionProblemData(IDataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable,
     160      IEnumerable<ITransformation> transformations = null,
     161      IntervalCollection variableRanges = null)
    166162      : base(dataset, allowedInputVariables, transformations ?? Enumerable.Empty<ITransformation>()) {
    167163      var variables = InputVariables.Select(x => x.AsReadOnly()).ToList();
    168164      Parameters.Add(new ConstrainedValueParameter<StringValue>(TargetVariableParameterName, new ItemSet<StringValue>(variables), variables.Where(x => x.Value == targetVariable).First()));
    169       var intervalCollection = CalculateDatasetIntervals(this.Dataset);
    170       Parameters.Add(new FixedValueParameter<IntervalCollection>(VariableRangesParameterName, intervalCollection));
    171       RegisterParameterEvents();
     165      if (variableRanges == null) {
     166        variableRanges = Dataset.GetIntervals();
     167      }
     168      Parameters.Add(new FixedValueParameter<IntervalCollection>(VariableRangesParameterName, variableRanges));
    172169    }
    173 
    174     private static IntervalCollection CalculateDatasetIntervals(IDataset dataset) {
    175       IntervalCollection intervalCollection = new IntervalCollection();
    176       foreach (var variable in dataset.DoubleVariables) {// intervals are only possible for double variables
    177         var variableInterval = Interval.GetInterval(dataset.GetDoubleValues(variable));
    178         intervalCollection.AddInterval(variable, variableInterval);
    179       }
    180 
    181       return intervalCollection;
     170    private void RegisterParameterEvents() {
     171      TargetVariableParameter.ValueChanged += new EventHandler(Parameter_ValueChanged);
     172      // VariableRanges are fixed parameters
    182173    }
    183 
    184     private void RegisterParameterEvents() {
    185       TargetVariableParameter.ValueChanged += new EventHandler(TargetVariableParameter_ValueChanged);
    186     }
    187     private void TargetVariableParameter_ValueChanged(object sender, EventArgs e) {
     174    private void Parameter_ValueChanged(object sender, EventArgs e) {
    188175      OnChanged();
    189176    }
  • branches/3106_AnalyticContinuedFractionsRegression/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Regression/IRegressionProblemData.cs

    r17579 r17970  
    11#region License Information
     2
    23/* HeuristicLab
    34 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     
    1819 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
    1920 */
     21
    2022#endregion
    2123
     
    2729  public interface IRegressionProblemData : IDataAnalysisProblemData {
    2830    string TargetVariable { get; set; }
    29 
    30     IntervalCollection VariableRanges { get;}
    31 
     31    IntervalCollection VariableRanges { get; }
    3232    IEnumerable<double> TargetVariableValues { get; }
    3333    IEnumerable<double> TargetVariableTrainingValues { get; }
  • branches/3106_AnalyticContinuedFractionsRegression/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/AutoCorrelationCalculator.cs

    r17180 r17970  
    3131      }
    3232
    33       double[] correlations = new double[values.Length];
    34       alglib.corr.corrr1dcircular(values, values.Length, values, values.Length, ref correlations);
     33      alglib.corrr1dcircular(values, values.Length, values, values.Length, out var correlations);
    3534      return correlations;
    3635    }
  • branches/3106_AnalyticContinuedFractionsRegression/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/DependencyCalculator/SpearmansRankCorrelationCoefficientCalculator.cs

    r17180 r17970  
    4545        var original = originalValues.ToArray();
    4646        var estimated = estimatedValues.ToArray();
    47         rs = alglib.basestat.spearmancorr2(original, estimated, original.Length);
     47        rs = alglib.spearmancorr2(original, estimated, original.Length);
    4848        errorState = OnlineCalculatorError.None;
    4949      }
  • branches/3106_AnalyticContinuedFractionsRegression/HeuristicLab.Problems.DataAnalysis/3.4/Plugin.cs.frame

    r17184 r17970  
    2828  [Plugin("HeuristicLab.Problems.DataAnalysis","Provides base classes for data analysis tasks.", "3.4.12.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Problems.DataAnalysis-3.4.dll", PluginFileType.Assembly)]
    30   [PluginDependency("HeuristicLab.ALGLIB","3.7.0")]
     30  [PluginDependency("HeuristicLab.ALGLIB","3.17.0")]
    3131  [PluginDependency("HeuristicLab.Collections", "3.3")]
    3232  [PluginDependency("HeuristicLab.Common", "3.3")]
Note: See TracChangeset for help on using the changeset viewer.