Changeset 13089
- Timestamp:
- 10/29/15 19:48:17 (9 years ago)
- Location:
- branches/ClassificationModelComparison
- Files:
-
- 2 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis-3.4.csproj
r13085 r13089 318 318 <Compile Include="Linear\AlglibUtil.cs" /> 319 319 <Compile Include="Linear\OneRTest.cs" /> 320 <Compile Include="Linear\OneR.cs" />321 320 <Compile Include="Linear\OneR\OneRClassificationModel.cs" /> 322 321 <Compile Include="Linear\OneR\OneRClassificationSolution.cs" /> -
branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/OneRTest.cs
r10570 r13089 34 34 /// 1R classification algorithm. 35 35 /// </summary> 36 [Item("OneR Classification", " 1R classification algorithm.")]36 [Item("OneR Classification", "A simple classification algorithm the searches the best single-variable split (does not support categorical features correctly).")] 37 37 [StorableClass] 38 38 public sealed class OneRTest : FixedDataAnalysisAlgorithm<IClassificationProblem> { … … 63 63 } 64 64 65 public static IClassificationSolution CreateOneRSolution(IClassificationProblemData problemData, int minBucketSize ) {65 public static IClassificationSolution CreateOneRSolution(IClassificationProblemData problemData, int minBucketSize = 6) { 66 66 var bestClassified = 0; 67 67 List<Split> bestSplits = null; -
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; -
branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationSolutionComparisonView.cs
r13086 r13089 87 87 dataGridView.ColumnCount = 4; 88 88 dataGridView.RowCount = solutions.Count(); 89 dataGridView.Columns[0].HeaderText = " Training Accuracy";90 dataGridView.Columns[1].HeaderText = " Test Accuracy";91 dataGridView.Columns[2].HeaderText = "Matthews Correlation Coefficient Training";92 dataGridView.Columns[3].HeaderText = "Matthews Correlation Coefficient Test";89 dataGridView.Columns[0].HeaderText = "Accuracy (training)"; 90 dataGridView.Columns[1].HeaderText = "Accuracy (test)"; 91 dataGridView.Columns[2].HeaderText = "Matthews Correlation Coefficient (training)"; 92 dataGridView.Columns[3].HeaderText = "Matthews Correlation Coefficient (test)"; 93 93 if (problemData.Classes == 2) { 94 94 dataGridView.ColumnCount = 6; 95 dataGridView.Columns[4].HeaderText = "F1 Score Training";96 dataGridView.Columns[5].HeaderText = "F1 Score Test";95 dataGridView.Columns[4].HeaderText = "F1 Score (training)"; 96 dataGridView.Columns[5].HeaderText = "F1 Score (test)"; 97 97 } 98 98 … … 130 130 var newSolutions = new List<IClassificationSolution>(); 131 131 var zeroR = ZeroR.CreateZeroRSolution(problemData); 132 zeroR.Name = " 0R Classification Solution";132 zeroR.Name = "ZeroR Classification Solution"; 133 133 newSolutions.Add(zeroR); 134 var oneR = OneR .CreateOneRSolution(problemData, 6, new FastRandom());135 oneR.Name = " 1R Classification Solution";134 var oneR = OneRTest.CreateOneRSolution(problemData); 135 oneR.Name = "OneR Classification Solution"; 136 136 newSolutions.Add(oneR); 137 137 try { -
branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj
r13083 r13089 172 172 <Compile Include="Implementation\Classification\ConstantClassificationSolution.cs" /> 173 173 <Compile Include="Implementation\Classification\DiscriminantFunctionClassificationSolutionBase.cs" /> 174 <Compile Include="Implementation\Classification\ConstantClassificationModel.cs" />175 174 <Compile Include="Implementation\Clustering\ClusteringProblem.cs" /> 176 175 <Compile Include="Implementation\Clustering\ClusteringProblemData.cs" /> -
branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ConstantClassificationSolution.cs
r9119 r13089 28 28 [Item(Name = "Constant Classification Solution", Description = "Represents a constant classification solution (model + data).")] 29 29 public class ConstantClassificationSolution : ClassificationSolution { 30 public new Constant ClassificationModel Model {31 get { return (Constant ClassificationModel)base.Model; }30 public new ConstantRegressionModel Model { 31 get { return (ConstantRegressionModel)base.Model; } 32 32 set { base.Model = value; } 33 33 } … … 36 36 protected ConstantClassificationSolution(bool deserializing) : base(deserializing) { } 37 37 protected ConstantClassificationSolution(ConstantClassificationSolution original, Cloner cloner) : base(original, cloner) { } 38 public ConstantClassificationSolution(Constant ClassificationModel model, IClassificationProblemData problemData)38 public ConstantClassificationSolution(ConstantRegressionModel model, IClassificationProblemData problemData) 39 39 : base(model, problemData) { 40 40 RecalculateResults(); -
branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/ConstantRegressionModel.cs
r13083 r13089 30 30 namespace HeuristicLab.Problems.DataAnalysis { 31 31 [StorableClass] 32 [Item("Constant Regression Model", "A model that always returns the same constant value regardless of the presented input data.")] 33 public class ConstantRegressionModel : NamedItem, IRegressionModel, IStringConvertibleValue { 32 [Item("Constant Model", "A model that always returns the same constant value regardless of the presented input data.")] 33 // TODO this class should be renamed, since it is also used to handle the classification case now 34 public class ConstantRegressionModel : NamedItem, IRegressionModel, IClassificationModel, IStringConvertibleValue { 34 35 [Storable] 35 36 private double constant; … … 59 60 } 60 61 62 public IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) { 63 return GetEstimatedValues(dataset, rows); 64 } 65 61 66 public IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) { 62 67 return new ConstantRegressionSolution(this, new RegressionProblemData(problemData)); 68 } 69 70 public IClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) { 71 return new ConstantClassificationSolution(this, new ClassificationProblemData(problemData)); 63 72 } 64 73 … … 70 79 public bool ReadOnly { get; private set; } 71 80 public bool Validate(string value, out string errorMessage) { 72 throw new NotSupportedException(); // changing a constant regressionmodel is not supported81 throw new NotSupportedException(); // changing a constant model is not supported 73 82 } 74 83 … … 78 87 79 88 public bool SetValue(string value) { 80 throw new NotSupportedException(); // changing a constant regressionmodel is not supported89 throw new NotSupportedException(); // changing a constant model is not supported 81 90 } 82 91 83 92 public event EventHandler ValueChanged; 84 93 #endregion 94 85 95 } 86 96 }
Note: See TracChangeset
for help on using the changeset viewer.