Changeset 13083 for branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/ConstantRegressionModel.cs
- Timestamp:
- 10/29/15 18:33:51 (8 years ago)
- Location:
- branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis
- Property svn:mergeinfo changed
-
branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/ConstantRegressionModel.cs
r10556 r13083 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 3Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Linq; 24 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; 27 using HeuristicLab.Data; 26 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 29 … … 29 31 [StorableClass] 30 32 [Item("Constant Regression Model", "A model that always returns the same constant value regardless of the presented input data.")] 31 public class ConstantRegressionModel : NamedItem, IRegressionModel {33 public class ConstantRegressionModel : NamedItem, IRegressionModel, IStringConvertibleValue { 32 34 [Storable] 33 pr otecteddouble constant;35 private double constant; 34 36 public double Constant { 35 37 get { return constant; } 38 // setter not implemented because manipulation of the constant is not allowed 36 39 } 37 40 … … 49 52 this.description = ItemDescription; 50 53 this.constant = constant; 54 this.ReadOnly = true; // changing a constant regression model is not supported 51 55 } 52 56 53 public IEnumerable<double> GetEstimatedValues( Dataset dataset, IEnumerable<int> rows) {57 public IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows) { 54 58 return rows.Select(row => Constant); 55 59 } … … 58 62 return new ConstantRegressionSolution(this, new RegressionProblemData(problemData)); 59 63 } 64 65 public override string ToString() { 66 return string.Format("Constant: {0}", GetValue()); 67 } 68 69 #region IStringConvertibleValue 70 public bool ReadOnly { get; private set; } 71 public bool Validate(string value, out string errorMessage) { 72 throw new NotSupportedException(); // changing a constant regression model is not supported 73 } 74 75 public string GetValue() { 76 return string.Format("{0:E4}", constant); 77 } 78 79 public bool SetValue(string value) { 80 throw new NotSupportedException(); // changing a constant regression model is not supported 81 } 82 83 public event EventHandler ValueChanged; 84 #endregion 60 85 } 61 86 }
Note: See TracChangeset
for help on using the changeset viewer.