Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17867 for trunk


Ignore:
Timestamp:
03/09/21 08:39:25 (4 years ago)
Author:
gkronber
Message:

#2898: simplified code in Spline1dModel

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Algorithms.DataAnalysis/3.4/GAM/Spline1dModel.cs

    r17839 r17867  
    3737    [Storable]
    3838    private readonly string[] variablesUsedForPrediction;
    39     public override IEnumerable<string> VariablesUsedForPrediction {
    40       get {
    41         return variablesUsedForPrediction;
    42       }
    43     }
     39    public override IEnumerable<string> VariablesUsedForPrediction => variablesUsedForPrediction;
    4440
    4541    [StorableConstructor]
     
    5450    public Spline1dModel(alglib.spline1d.spline1dinterpolant interpolant, string targetVar, string inputVar)
    5551      : base(targetVar, "Spline model (1d)") {
    56       this.interpolant = (alglib.spline1d.spline1dinterpolant)interpolant.make_copy();     
     52      this.interpolant = (alglib.spline1d.spline1dinterpolant)interpolant.make_copy();
    5753      this.variablesUsedForPrediction = new string[] { inputVar };
    5854    }
    5955
    6056
    61     public override IDeepCloneable Clone(Cloner cloner) {
    62       return new Spline1dModel(this, cloner);
    63     }
     57    public override IDeepCloneable Clone(Cloner cloner) => new Spline1dModel(this, cloner);
    6458
    6559    public override IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) {
     
    6761    }
    6862
    69     public double GetEstimatedValue(double x) {
    70       return alglib.spline1d.spline1dcalc(interpolant, x);
    71     }
     63    public double GetEstimatedValue(double x) => alglib.spline1d.spline1dcalc(interpolant, x);
    7264
    7365    public override IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows) {
    74       var x = dataset.GetDoubleValues(VariablesUsedForPrediction.First(), rows).ToArray();
    75       foreach (var xi in x) {
    76         yield return GetEstimatedValue(xi);
    77       }
     66      return dataset.GetDoubleValues(VariablesUsedForPrediction.First(), rows).Select(GetEstimatedValue);
    7867    }
    7968
Note: See TracChangeset for help on using the changeset viewer.