Changeset 5664
- Timestamp:
- 03/10/11 16:27:48 (14 years ago)
- Location:
- branches/DataAnalysis Refactoring
- Files:
-
- 4 edited
- 6 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis Refactoring/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/LinearDiscriminantAnalysis.cs
r5658 r5664 79 79 // change class values into class index 80 80 int targetVariableColumn = inputMatrix.GetLength(1) - 1; 81 List<double> classValues = problemData.ClassValues.OrderBy(x =>x).ToList();81 List<double> classValues = problemData.ClassValues.OrderBy(x => x).ToList(); 82 82 for (int row = 0; row < inputMatrix.GetLength(0); row++) { 83 83 inputMatrix[row, targetVariableColumn] = classValues.IndexOf(inputMatrix[row, targetVariableColumn]); -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationSolutionConfusionMatrixView.Designer.cs
r5642 r5664 1 1 namespace HeuristicLab.Problems.DataAnalysis.Classification.Views { 2 partial class C onfusionMatrixView {2 partial class ClassificationSolutionConfusionMatrixView { 3 3 /// <summary> 4 4 /// Required designer variable. -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationSolutionConfusionMatrixView.cs
r5642 r5664 28 28 29 29 namespace HeuristicLab.Problems.DataAnalysis.Classification.Views { 30 [View("C onfusion Matrix View")]31 [Content(typeof( SymbolicClassificationSolution))]32 public partial class C onfusionMatrixView : AsynchronousContentView {30 [View("Classification solution confusion matrix view")] 31 [Content(typeof(IClassificationSolution))] 32 public partial class ClassificationSolutionConfusionMatrixView : AsynchronousContentView { 33 33 private const string TrainingSamples = "Training"; 34 34 private const string TestSamples = "Test"; 35 public C onfusionMatrixView() {35 public ClassificationSolutionConfusionMatrixView() { 36 36 InitializeComponent(); 37 37 cmbSamples.Items.Add(TrainingSamples); … … 40 40 } 41 41 42 public new SymbolicClassificationSolution Content {43 get { return ( SymbolicClassificationSolution)base.Content; }42 public new IClassificationSolution Content { 43 get { return (IClassificationSolution)base.Content; } 44 44 set { base.Content = value; } 45 45 } … … 47 47 protected override void RegisterContentEvents() { 48 48 base.RegisterContentEvents(); 49 Content. EstimatedValuesChanged += new EventHandler(Content_EstimatedValuesChanged);49 Content.ModelChanged += new EventHandler(Content_ModelChanged); 50 50 Content.ProblemDataChanged += new EventHandler(Content_ProblemDataChanged); 51 Content.ThresholdsChanged += new EventHandler(Content_ThresholdsChanged);52 51 } 53 52 … … 55 54 protected override void DeregisterContentEvents() { 56 55 base.DeregisterContentEvents(); 57 Content. EstimatedValuesChanged -= new EventHandler(Content_EstimatedValuesChanged);56 Content.ModelChanged -= new EventHandler(Content_ModelChanged); 58 57 Content.ProblemDataChanged -= new EventHandler(Content_ProblemDataChanged); 59 Content.ThresholdsChanged -= new EventHandler(Content_ThresholdsChanged);60 58 } 61 59 62 private void Content_ EstimatedValuesChanged(object sender, EventArgs e) {60 private void Content_ModelChanged(object sender, EventArgs e) { 63 61 FillDataGridView(); 64 62 } 65 63 private void Content_ProblemDataChanged(object sender, EventArgs e) { 66 64 UpdateDataGridView(); 67 }68 private void Content_ThresholdsChanged(object sender, EventArgs e) {69 FillDataGridView();70 65 } 71 66 … … 82 77 dataGridView.ColumnCount = 1; 83 78 } else { 84 dataGridView.ColumnCount = Content.ProblemData. NumberOfClasses;85 dataGridView.RowCount = Content.ProblemData. NumberOfClasses;79 dataGridView.ColumnCount = Content.ProblemData.Classes; 80 dataGridView.RowCount = Content.ProblemData.Classes; 86 81 87 82 int i = 0; … … 104 99 if (Content == null) return; 105 100 106 double[,] confusionMatrix = new double[Content.ProblemData. NumberOfClasses, Content.ProblemData.NumberOfClasses];101 double[,] confusionMatrix = new double[Content.ProblemData.Classes, Content.ProblemData.Classes]; 107 102 IEnumerable<int> rows; 108 103 … … 115 110 Dictionary<double, int> classValueIndexMapping = new Dictionary<double, int>(); 116 111 int index = 0; 117 foreach (double classValue in Content.ProblemData. SortedClassValues) {112 foreach (double classValue in Content.ProblemData.ClassValues.OrderBy(x => x)) { 118 113 classValueIndexMapping.Add(classValue, index); 119 114 index++; 120 115 } 121 116 122 double[] targetValues = Content.ProblemData.Dataset.GetEnumeratedVariableValues(Content.ProblemData.TargetVariable .Value, rows).ToArray();117 double[] targetValues = Content.ProblemData.Dataset.GetEnumeratedVariableValues(Content.ProblemData.TargetVariable, rows).ToArray(); 123 118 double[] predictedValues = Content.GetEstimatedClassValues(rows).ToArray(); 124 119 -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/DiscriminantFunctionClassificationRocCurvesView.Designer.cs
r5642 r5664 1 1 namespace HeuristicLab.Problems.DataAnalysis.Classification.Views { 2 partial class RocCurvesView {2 partial class DiscriminantFunctionClassificationRocCurvesView { 3 3 /// <summary> 4 4 /// Required designer variable. -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/DiscriminantFunctionClassificationRocCurvesView.cs
r5642 r5664 31 31 using HeuristicLab.MainForm.WindowsForms; 32 32 namespace HeuristicLab.Problems.DataAnalysis.Classification.Views { 33 [View(" ROC Curves View")]34 [Content(typeof( SymbolicClassificationSolution))]35 public partial class RocCurvesView : AsynchronousContentView {33 [View("Discriminant function classification solution ROC curves view")] 34 [Content(typeof(IDiscriminantFunctionClassificationSolution))] 35 public partial class DiscriminantFunctionClassificationRocCurvesView : AsynchronousContentView { 36 36 private const string xAxisTitle = "False Positive Rate"; 37 37 private const string yAxisTitle = "True Positive Rate"; … … 40 40 private Dictionary<string, List<ROCPoint>> cachedRocPoints; 41 41 42 public RocCurvesView() {42 public DiscriminantFunctionClassificationRocCurvesView() { 43 43 InitializeComponent(); 44 44 … … 61 61 } 62 62 63 public new SymbolicClassificationSolution Content {64 get { return ( SymbolicClassificationSolution)base.Content; }63 public new IDiscriminantFunctionClassificationSolution Content { 64 get { return (IDiscriminantFunctionClassificationSolution)base.Content; } 65 65 set { base.Content = value; } 66 66 } … … 68 68 protected override void RegisterContentEvents() { 69 69 base.RegisterContentEvents(); 70 Content. EstimatedValuesChanged += new EventHandler(Content_EstimatedValuesChanged);70 Content.ModelChanged += new EventHandler(Content_ModelChanged); 71 71 Content.ProblemDataChanged += new EventHandler(Content_ProblemDataChanged); 72 72 } 73 73 protected override void DeregisterContentEvents() { 74 74 base.DeregisterContentEvents(); 75 Content. EstimatedValuesChanged -= new EventHandler(Content_EstimatedValuesChanged);75 Content.ModelChanged -= new EventHandler(Content_ModelChanged); 76 76 Content.ProblemDataChanged -= new EventHandler(Content_ProblemDataChanged); 77 77 } 78 78 79 private void Content_ EstimatedValuesChanged(object sender, EventArgs e) {79 private void Content_ModelChanged(object sender, EventArgs e) { 80 80 UpdateChart(); 81 81 } … … 107 107 108 108 double[] estimatedValues = Content.GetEstimatedValues(rows).ToArray(); 109 double[] targetClassValues = Content.ProblemData.Dataset.GetEnumeratedVariableValues(Content.ProblemData.TargetVariable .Value, rows).ToArray();109 double[] targetClassValues = Content.ProblemData.Dataset.GetEnumeratedVariableValues(Content.ProblemData.TargetVariable, rows).ToArray(); 110 110 double minThreshold = estimatedValues.Min(); 111 111 double maxThreshold = estimatedValues.Max(); … … 114 114 maxThreshold += thresholdIncrement; 115 115 116 List<double> classValues = Content.ProblemData. SortedClassValues.ToList();116 List<double> classValues = Content.ProblemData.ClassValues.OrderBy(x => x).ToList(); 117 117 118 118 foreach (double classValue in classValues) { -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/DiscriminantFunctionClassificationSolutionView.Designer.cs
r5642 r5664 1 1 namespace HeuristicLab.Problems.DataAnalysis.Classification.Views { 2 partial class SymbolicClassificationSolutionView {2 partial class DiscriminantFunctionClassificationSolutionView { 3 3 /// <summary> 4 4 /// Required designer variable. -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/DiscriminantFunctionClassificationSolutionView.cs
r5642 r5664 31 31 32 32 namespace HeuristicLab.Problems.DataAnalysis.Classification.Views { 33 [View(" Symbolic Classification View")]34 [Content(typeof( SymbolicClassificationSolution), true)]35 public sealed partial class SymbolicClassificationSolutionView : AsynchronousContentView {33 [View("Discriminant function classification solution view")] 34 [Content(typeof(IDiscriminantFunctionClassificationSolution), true)] 35 public sealed partial class DiscriminantFunctionClassificationSolutionView : AsynchronousContentView { 36 36 private const double TrainingAxisValue = 0.0; 37 37 private const double TestAxisValue = 10.0; … … 40 40 private const string TestLabelText = "Test Samples"; 41 41 42 public new SymbolicClassificationSolution Content {43 get { return ( SymbolicClassificationSolution)base.Content; }42 public new IDiscriminantFunctionClassificationSolution Content { 43 get { return (IDiscriminantFunctionClassificationSolution)base.Content; } 44 44 set { base.Content = value; } 45 45 } … … 49 49 private bool updateInProgress; 50 50 51 public SymbolicClassificationSolutionView()51 public DiscriminantFunctionClassificationSolutionView() 52 52 : base() { 53 53 InitializeComponent(); … … 85 85 protected override void RegisterContentEvents() { 86 86 base.RegisterContentEvents(); 87 Content. EstimatedValuesChanged += new EventHandler(Content_EstimatedValuesChanged);87 Content.ModelChanged += new EventHandler(Content_ModelChanged); 88 88 Content.ProblemDataChanged += new EventHandler(Content_ProblemDataChanged); 89 89 Content.ThresholdsChanged += new EventHandler(Content_ThresholdsChanged); … … 91 91 protected override void DeregisterContentEvents() { 92 92 base.DeregisterContentEvents(); 93 Content. EstimatedValuesChanged -= new EventHandler(Content_EstimatedValuesChanged);93 Content.ModelChanged -= new EventHandler(Content_ModelChanged); 94 94 Content.ProblemDataChanged -= new EventHandler(Content_ProblemDataChanged); 95 95 Content.ThresholdsChanged -= new EventHandler(Content_ThresholdsChanged); … … 99 99 UpdateChart(); 100 100 } 101 private void Content_ EstimatedValuesChanged(object sender, EventArgs e) {101 private void Content_ModelChanged(object sender, EventArgs e) { 102 102 UpdateChart(); 103 103 } … … 118 118 if (Content != null) { 119 119 IEnumerator<string> classNameEnumerator = Content.ProblemData.ClassNames.GetEnumerator(); 120 IEnumerator<double> classValueEnumerator = Content.ProblemData. SortedClassValues.GetEnumerator();120 IEnumerator<double> classValueEnumerator = Content.ProblemData.ClassValues.OrderBy(x => x).GetEnumerator(); 121 121 while (classNameEnumerator.MoveNext() && classValueEnumerator.MoveNext()) { 122 122 Series series = new Series(classNameEnumerator.Current); … … 138 138 foreach (int row in Content.ProblemData.TrainingIndizes) { 139 139 double estimatedValue = estimatedValues[row]; 140 double targetValue = Content.ProblemData.Dataset[Content.ProblemData.TargetVariable .Value, row];140 double targetValue = Content.ProblemData.Dataset[Content.ProblemData.TargetVariable, row]; 141 141 if (targetValue.IsAlmost((double)series.Tag)) { 142 142 double jitterValue = random.NextDouble() * 2.0 - 1.0; … … 151 151 foreach (int row in Content.ProblemData.TestIndizes) { 152 152 double estimatedValue = estimatedValues[row]; 153 double targetValue = Content.ProblemData.Dataset[Content.ProblemData.TargetVariable .Value, row];153 double targetValue = Content.ProblemData.Dataset[Content.ProblemData.TargetVariable, row]; 154 154 if (targetValue == (double)series.Tag) { 155 155 double jitterValue = random.NextDouble() * 2.0 - 1.0; … … 235 235 private void chart_AnnotationPositionChanging(object sender, AnnotationPositionChangingEventArgs e) { 236 236 int classIndex = (int)e.Annotation.Tag; 237 238 double classValue = Content.ProblemData.SortedClassValues.ElementAt(classIndex);239 if (e.NewLocationY >= classValue)240 e.NewLocationY = classValue;241 242 classValue = Content.ProblemData.SortedClassValues.ElementAt(classIndex - 1);243 if (e.NewLocationY <= classValue)244 e.NewLocationY = classValue;245 246 237 double[] thresholds = Content.Thresholds.ToArray(); 238 double max = thresholds[classIndex + 1]; 239 double min = thresholds[classIndex - 1]; 240 241 if (e.NewLocationY >= max) 242 e.NewLocationY = max; 243 244 if (e.NewLocationY <= min) 245 e.NewLocationY = min; 246 247 247 thresholds[classIndex] = e.NewLocationY; 248 248 Content.Thresholds = thresholds; -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj
r5663 r5664 110 110 </ItemGroup> 111 111 <ItemGroup> 112 <Compile Include="Classification\ClassificationSolutionConfusionMatrixView.cs"> 113 <SubType>UserControl</SubType> 114 </Compile> 115 <Compile Include="Classification\ClassificationSolutionConfusionMatrixView.Designer.cs"> 116 <DependentUpon>ClassificationSolutionConfusionMatrixView.cs</DependentUpon> 117 </Compile> 112 118 <Compile Include="Classification\ClassificationSolutionEstimatedClassValuesView.cs"> 113 119 <SubType>UserControl</SubType> … … 115 121 <Compile Include="Classification\ClassificationSolutionEstimatedClassValuesView.Designer.cs"> 116 122 <DependentUpon>ClassificationSolutionEstimatedClassValuesView.cs</DependentUpon> 123 </Compile> 124 <Compile Include="Classification\DiscriminantFunctionClassificationRocCurvesView.cs"> 125 <SubType>UserControl</SubType> 126 </Compile> 127 <Compile Include="Classification\DiscriminantFunctionClassificationRocCurvesView.Designer.cs"> 128 <DependentUpon>DiscriminantFunctionClassificationRocCurvesView.cs</DependentUpon> 129 </Compile> 130 <Compile Include="Classification\DiscriminantFunctionClassificationSolutionView.cs"> 131 <SubType>UserControl</SubType> 132 </Compile> 133 <Compile Include="Classification\DiscriminantFunctionClassificationSolutionView.Designer.cs"> 134 <DependentUpon>DiscriminantFunctionClassificationSolutionView.cs</DependentUpon> 117 135 </Compile> 118 136 <Compile Include="Regression\RegressionSolutionEstimatedValuesView.cs"> -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis/3.4/DiscriminantFunctionClassificationSolution.cs
r5657 r5664 77 77 return Model.Thresholds; 78 78 } 79 protected set { Model.Thresholds = value; }79 set { Model.Thresholds = new List<double>(value); } 80 80 } 81 81 … … 117 117 thresholds[thresholds.Length - 1] = double.PositiveInfinity; 118 118 119 double thresholdIncrement = (maxEstimatedValue - minEstimatedValue) / slices; 120 119 121 for (int i = 1; i < thresholds.Length - 1; i++) { 120 122 double lowerThreshold = thresholds[i - 1]; 121 double actualThreshold = minEstimatedValue; 122 double thresholdIncrement = (maxEstimatedValue - minEstimatedValue) / slices; 123 123 double actualThreshold = Math.Max(lowerThreshold, minEstimatedValue); 124 124 double lowestBestThreshold = double.NaN; 125 125 double highestBestThreshold = double.NaN; -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Classification/IDiscriminantFunctionClassificationSolution.cs
r5649 r5664 31 31 IEnumerable<double> GetEstimatedValues(IEnumerable<int> rows); 32 32 33 IEnumerable<double> Thresholds { get; }33 IEnumerable<double> Thresholds { get; set; } 34 34 35 35 event EventHandler ThresholdsChanged;
Note: See TracChangeset
for help on using the changeset viewer.