- Timestamp:
- 03/12/21 14:43:07 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.Algorithms.DataAnalysis/3.4/GAM/Spline1dModel.cs
r17867 r17889 26 26 using HeuristicLab.Core; 27 27 using HeuristicLab.Problems.DataAnalysis; 28 using System; 28 29 29 30 namespace HeuristicLab.Algorithms.DataAnalysis { … … 35 36 private alglib.spline1d.spline1dinterpolant interpolant; 36 37 38 [Storable(OldName = "variablesUsedForPrediction")] 39 private string[] StorableVariablesUsedForPrediction { 40 set { 41 if (value.Length > 1) throw new ArgumentException("A one-dimensional spline model supports only one input variable."); 42 inputVariable = value[0]; 43 } 44 } 45 37 46 [Storable] 38 private readonly string[] variablesUsedForPrediction;39 public override IEnumerable<string> VariablesUsedForPrediction => variablesUsedForPrediction;47 private string inputVariable; 48 public override IEnumerable<string> VariablesUsedForPrediction => new[] { inputVariable }; 40 49 41 50 [StorableConstructor] … … 45 54 46 55 private Spline1dModel(Spline1dModel orig, Cloner cloner) : base(orig, cloner) { 47 this. variablesUsedForPrediction = orig.VariablesUsedForPrediction.ToArray();56 this.inputVariable = orig.inputVariable; 48 57 this.interpolant = (alglib.spline1d.spline1dinterpolant)orig.interpolant.make_copy(); 49 58 } 50 59 public Spline1dModel(alglib.spline1d.spline1dinterpolant interpolant, string targetVar, string inputVar) 51 : base(targetVar, "Spline model (1d)") {60 : base(targetVar, $"Spline model ({inputVar})") { 52 61 this.interpolant = (alglib.spline1d.spline1dinterpolant)interpolant.make_copy(); 53 this. variablesUsedForPrediction = new string[] { inputVar };62 this.inputVariable = inputVar; 54 63 } 55 64 … … 58 67 59 68 public override IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) { 60 return new RegressionSolution(this, (IRegressionProblemData)problemData.Clone()); 69 var solution = new RegressionSolution(this, (IRegressionProblemData)problemData.Clone()); 70 solution.Name = $"Regression Spline ({inputVariable})"; 71 72 return solution; 61 73 } 62 74 … … 64 76 65 77 public override IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows) { 66 return dataset.GetDoubleValues( VariablesUsedForPrediction.First(), rows).Select(GetEstimatedValue);78 return dataset.GetDoubleValues(inputVariable, rows).Select(GetEstimatedValue); 67 79 } 68 80
Note: See TracChangeset
for help on using the changeset viewer.