- Timestamp:
- 01/15/17 09:57:50 (8 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/MemPRAlgorithm/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/ConfidenceConstantModel.cs
r14561 r14573 30 30 namespace HeuristicLab.Problems.DataAnalysis { 31 31 [StorableClass] 32 [Item("Con stant Model", "A model that always returns the same constant value regardless of the presented input data.")]33 public class Con stantModel : RegressionModel, IClassificationModel, ITimeSeriesPrognosisModel, IStringConvertibleValue {32 [Item("Confidence Constant Model", "A model that always returns the same constant mean value and variance regardless of the presented input data.")] 33 public class ConfidenceConstantModel : RegressionModel, IConfidenceRegressionModel, IStringConvertibleValue { 34 34 public override IEnumerable<string> VariablesUsedForPrediction { get { return Enumerable.Empty<string>(); } } 35 35 … … 42 42 } 43 43 44 [Storable] 45 private readonly double variance; 46 public double Variance { 47 get { return variance; } 48 // setter not implemented because manipulation of the variance is not allowed 49 } 50 44 51 [StorableConstructor] 45 protected Con stantModel(bool deserializing) : base(deserializing) { }46 protected Con stantModel(ConstantModel original, Cloner cloner)52 protected ConfidenceConstantModel(bool deserializing) : base(deserializing) { } 53 protected ConfidenceConstantModel(ConfidenceConstantModel original, Cloner cloner) 47 54 : base(original, cloner) { 48 55 this.constant = original.constant; 56 this.variance = original.variance; 49 57 } 50 58 51 public override IDeepCloneable Clone(Cloner cloner) { return new Con stantModel(this, cloner); }59 public override IDeepCloneable Clone(Cloner cloner) { return new ConfidenceConstantModel(this, cloner); } 52 60 53 public Con stantModel(double constant, string targetVariable)61 public ConfidenceConstantModel(double constant, double variance, string targetVariable) 54 62 : base(targetVariable) { 55 63 this.name = ItemName; 56 64 this.description = ItemDescription; 57 65 this.constant = constant; 66 this.variance = variance; 58 67 this.ReadOnly = true; // changing a constant regression model is not supported 59 68 } … … 62 71 return rows.Select(row => Constant); 63 72 } 64 public IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) { 65 return GetEstimatedValues(dataset, rows); 66 } 67 public IEnumerable<IEnumerable<double>> GetPrognosedValues(IDataset dataset, IEnumerable<int> rows, IEnumerable<int> horizons) { 68 return rows.Select(_ => horizons.Select(__ => Constant)); 73 74 public IEnumerable<double> GetEstimatedVariances(IDataset dataset, IEnumerable<int> rows) { 75 return rows.Select(x => Variance); 69 76 } 70 77 71 78 public override IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) { 72 return new ConstantRegressionSolution(this, new RegressionProblemData(problemData)); 73 } 74 public IClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) { 75 return new ConstantClassificationSolution(this, new ClassificationProblemData(problemData)); 76 } 77 public ITimeSeriesPrognosisSolution CreateTimeSeriesPrognosisSolution(ITimeSeriesPrognosisProblemData problemData) { 78 return new TimeSeriesPrognosisSolution(this, new TimeSeriesPrognosisProblemData(problemData)); 79 return new ConfidenceRegressionSolution(this, new RegressionProblemData(problemData)); 79 80 } 80 81 81 82 public override string ToString() { 82 return string.Format("Constant: {0 }", GetValue());83 return string.Format("Constant: {0:E4}, Variance: {1:E4}", Constant, Variance); 83 84 } 84 85 … … 101 102 #pragma warning restore 0067 102 103 #endregion 103 104 104 } 105 105 }
Note: See TracChangeset
for help on using the changeset viewer.