Changeset 13089 for branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/ZeroR.cs
- Timestamp:
- 10/29/15 19:48:17 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/ZeroR.cs
r13086 r13089 31 31 /// 0R classification algorithm. 32 32 /// </summary> 33 [Item("ZeroR", " 0R classification algorithm.")]34 [Creatable("Data Analysis")] 33 [Item("ZeroR", "The simplest possible classifier, ZeroR always predicts the majority class.")] 34 [Creatable("Data Analysis")] // TODO 35 35 [StorableClass] 36 36 public sealed class ZeroR : FixedDataAnalysisAlgorithm<IClassificationProblem> { … … 52 52 protected override void Run() { 53 53 var solution = CreateZeroRSolution(Problem.ProblemData); 54 Results.Add(new Result("ZeroR solution", "The 0R classifier.", solution));54 Results.Add(new Result("ZeroR solution", "The simplest possible classifier, ZeroR always predicts the majority class.", solution)); 55 55 } 56 56 … … 60 60 var targetValues = dataset.GetDoubleValues(target, problemData.TrainingIndices); 61 61 62 63 // if multiple classes have the same number of observations then simply take the first one 62 64 var dominantClass = targetValues.GroupBy(x => x).ToDictionary(g => g.Key, g => g.Count()) 63 65 .MaxItems(kvp => kvp.Value).Select(x => x.Key).First(); 64 66 65 var model = new Constant ClassificationModel(dominantClass);67 var model = new ConstantRegressionModel(dominantClass); 66 68 var solution = new ConstantClassificationSolution(model, (IClassificationProblemData)problemData.Clone()); 67 69 return solution;
Note: See TracChangeset
for help on using the changeset viewer.