Changeset 5601
- Timestamp:
- 03/03/11 16:14:13 (14 years ago)
- Location:
- branches/DataAnalysis Refactoring
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis Refactoring/HeuristicLab 3.3.sln
r5574 r5601 85 85 {DF87C13E-A889-46FF-8153-66DCAA8C5674} = {DF87C13E-A889-46FF-8153-66DCAA8C5674} 86 86 {3D28463F-EC96-4D82-AFEE-38BE91A0CA00} = {3D28463F-EC96-4D82-AFEE-38BE91A0CA00} 87 {3E9E8944-44FF-40BB-A622-3A4A7DD0F198} = {3E9E8944-44FF-40BB-A622-3A4A7DD0F198} 87 88 {678E2145-8152-4E19-9646-07D439D00301} = {678E2145-8152-4E19-9646-07D439D00301} 88 89 {49F28045-7B5F-411B-8D59-16C846FA26E0} = {49F28045-7B5F-411B-8D59-16C846FA26E0} … … 373 374 EndProject 374 375 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.DataAnalysis.Symbolic.Tests-3.4", "HeuristicLab.Problems.DataAnalysis.Symbolic\3.4\Tests\HeuristicLab.Problems.DataAnalysis.Symbolic.Tests-3.4.csproj", "{2A976109-67B9-4FF0-89DE-A26A8307A1CE}" 376 EndProject 377 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.DataAnalysis.Views-3.4", "HeuristicLab.Problems.DataAnalysis.Views\3.4\HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj", "{3E9E8944-44FF-40BB-A622-3A4A7DD0F198}" 375 378 EndProject 376 379 Global … … 1719 1722 {2A976109-67B9-4FF0-89DE-A26A8307A1CE}.Release|x86.ActiveCfg = Release|x86 1720 1723 {2A976109-67B9-4FF0-89DE-A26A8307A1CE}.Release|x86.Build.0 = Release|x86 1724 {3E9E8944-44FF-40BB-A622-3A4A7DD0F198}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 1725 {3E9E8944-44FF-40BB-A622-3A4A7DD0F198}.Debug|Any CPU.Build.0 = Debug|Any CPU 1726 {3E9E8944-44FF-40BB-A622-3A4A7DD0F198}.Debug|x64.ActiveCfg = Debug|x64 1727 {3E9E8944-44FF-40BB-A622-3A4A7DD0F198}.Debug|x64.Build.0 = Debug|x64 1728 {3E9E8944-44FF-40BB-A622-3A4A7DD0F198}.Debug|x86.ActiveCfg = Debug|x86 1729 {3E9E8944-44FF-40BB-A622-3A4A7DD0F198}.Debug|x86.Build.0 = Debug|x86 1730 {3E9E8944-44FF-40BB-A622-3A4A7DD0F198}.Release|Any CPU.ActiveCfg = Release|Any CPU 1731 {3E9E8944-44FF-40BB-A622-3A4A7DD0F198}.Release|Any CPU.Build.0 = Release|Any CPU 1732 {3E9E8944-44FF-40BB-A622-3A4A7DD0F198}.Release|x64.ActiveCfg = Release|x64 1733 {3E9E8944-44FF-40BB-A622-3A4A7DD0F198}.Release|x64.Build.0 = Release|x64 1734 {3E9E8944-44FF-40BB-A622-3A4A7DD0F198}.Release|x86.ActiveCfg = Release|x86 1735 {3E9E8944-44FF-40BB-A622-3A4A7DD0F198}.Release|x86.Build.0 = Release|x86 1721 1736 EndGlobalSection 1722 1737 GlobalSection(SolutionProperties) = preSolution -
branches/DataAnalysis Refactoring/HeuristicLab.Parameters/3.3/OptionalValueParameter.cs
r5445 r5601 92 92 if (value != reactOnValueToStringChangedAndValueItemImageChanged) { 93 93 reactOnValueToStringChangedAndValueItemImageChanged = value; 94 if (reactOnValueToStringChangedAndValueItemImageChanged) 94 if (reactOnValueToStringChangedAndValueItemImageChanged) { 95 95 RegisterValueEvents(); 96 else 96 OnToStringChanged(); 97 OnItemImageChanged(); 98 } else 97 99 DeregisterValueEvents(); 98 100 } … … 187 189 ((IValueParameter)this).Value = value; 188 190 } 189 191 190 192 public event EventHandler ValueChanged; 191 193 protected virtual void OnValueChanged() { -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectiveMeanSquaredErrorTreeSizeEvaluator.cs
r5586 r5601 53 53 public static double[] Calculate(ISymbolicDataAnalysisTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows) { 54 54 IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows); 55 IEnumerable<double> originalValues = problemData.Dataset.GetEnumeratedVariableValues(problemData.TargetVariable .Value, rows);55 IEnumerable<double> originalValues = problemData.Dataset.GetEnumeratedVariableValues(problemData.TargetVariable, rows); 56 56 IEnumerable<double> boundedEstimationValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit); 57 57 double mse = OnlineMeanSquaredErrorEvaluator.Calculate(originalValues, boundedEstimationValues); -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectivePearsonRSquaredTreeSizeEvaluator.cs
r5586 r5601 53 53 public static double[] Calculate(ISymbolicDataAnalysisTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows) { 54 54 IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows); 55 IEnumerable<double> originalValues = problemData.Dataset.GetEnumeratedVariableValues(problemData.TargetVariable .Value, rows);55 IEnumerable<double> originalValues = problemData.Dataset.GetEnumeratedVariableValues(problemData.TargetVariable, rows); 56 56 double r2 = OnlinePearsonsRSquaredEvaluator.Calculate(originalValues, estimatedValues); 57 57 return new double[2] { r2, solution.Length }; -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/SymbolicRegressionSingleObjectiveMeanSquaredErrorEvaluator.cs
r5586 r5601 53 53 public static double Calculate(ISymbolicDataAnalysisTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows) { 54 54 IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows); 55 IEnumerable<double> originalValues = problemData.Dataset.GetEnumeratedVariableValues(problemData.TargetVariable .Value, rows);55 IEnumerable<double> originalValues = problemData.Dataset.GetEnumeratedVariableValues(problemData.TargetVariable, rows); 56 56 IEnumerable<double> boundedEstimationValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit); 57 57 return OnlineMeanSquaredErrorEvaluator.Calculate(originalValues, boundedEstimationValues); -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.cs
r5586 r5601 53 53 public static double Calculate(ISymbolicDataAnalysisTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows) { 54 54 IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows); 55 IEnumerable<double> originalValues = problemData.Dataset.GetEnumeratedVariableValues(problemData.TargetVariable .Value, rows);55 IEnumerable<double> originalValues = problemData.Dataset.GetEnumeratedVariableValues(problemData.TargetVariable, rows); 56 56 return OnlinePearsonsRSquaredEvaluator.Calculate(originalValues, estimatedValues); 57 57 } -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis/3.4/ClassificationProblemData.cs
r5579 r5601 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.IO; 24 25 using System.Linq; 25 26 using HeuristicLab.Common; 27 using HeuristicLab.Core; 28 using HeuristicLab.Data; 29 using HeuristicLab.Parameters; 26 30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 31 28 32 namespace HeuristicLab.Problems.DataAnalysis { 29 33 [StorableClass] 34 [Item("ClassificationProblemData", "Represents an item containing all data defining a classification problem.")] 30 35 public class ClassificationProblemData : DataAnalysisProblemData, IClassificationProblemData { 36 private const string TargetVariableParameterName = "TargetVariable"; 37 private const string ClassNamesParameterName = "ClassNames"; 38 private const string ClassificationPenaltiesParameterName = "ClassificationPenalties"; 39 31 40 #region default data 32 41 private static string[] defaultVariableNames = new string[] { "sample", "clump thickness", "cell size", "cell shape", "marginal adhesion", "epithelial cell size", "bare nuclei", "chromatin", "nucleoli", "mitoses", "class" }; … … 173 182 #endregion 174 183 184 #region parameter properties 185 public IValueParameter<StringValue> TargetVariableParameter { 186 get { return (IValueParameter<StringValue>)Parameters[TargetVariableParameterName]; } 187 } 188 public IFixedValueParameter<StringMatrix> ClassNamesParameter { 189 get { return (IFixedValueParameter<StringMatrix>)Parameters[ClassNamesParameterName]; } 190 } 191 public IFixedValueParameter<DoubleMatrix> ClassificationPenaltiesParameter { 192 get { return (IFixedValueParameter<DoubleMatrix>)Parameters[ClassificationPenaltiesParameterName]; } 193 } 194 #endregion 195 175 196 #region propeties 176 [Storable]177 private string targetVariable;178 197 public string TargetVariable { 179 get { return targetVariable; } 180 set { 181 if (!Dataset.VariableNames.Contains(value)) 182 throw new ArgumentException(string.Format("The target variable {0} is not present in the dataset", value)); 183 if (targetVariable != value) { 184 targetVariable = value; 185 186 InitializeTargetVariableDependentMembers(); 187 OnChanged(); 198 get { return TargetVariableParameter.Value.Value; } 199 } 200 201 private List<double> classValues; 202 public List<double> ClassValues { 203 get { 204 if (classValues == null) { 205 classValues = Dataset.GetEnumeratedVariableValues(TargetVariableParameter.Value.Value).Distinct().ToList(); 206 classValues.Sort(); 207 } 208 return classValues; 209 } 210 } 211 IEnumerable<double> IClassificationProblemData.ClassValues { 212 get { return ClassValues; } 213 } 214 215 public int Classes { 216 get { return ClassValues.Count; } 217 } 218 219 private List<string> classNames; 220 public List<string> ClassNames { 221 get { 222 if (classNames == null) { 223 classNames = new List<string>(); 224 for (int i = 0; i < ClassNamesParameter.Value.Rows; i++) 225 classNames.Add(ClassNamesParameter.Value[i, 0]); 226 } 227 return classNames; 228 } 229 } 230 IEnumerable<string> IClassificationProblemData.ClassNames { 231 get { return ClassNames; } 232 } 233 234 private Dictionary<Tuple<double, double>, double> classificationPenaltiesCache = new Dictionary<Tuple<double, double>, double>(); 235 #endregion 236 237 238 [StorableConstructor] 239 protected ClassificationProblemData(bool deserializing) : base(deserializing) { } 240 [StorableHook(HookType.AfterDeserialization)] 241 private void AfterDeserialization() { 242 RegisterParameterEvents(); 243 } 244 245 protected ClassificationProblemData(ClassificationProblemData original, Cloner cloner) 246 : base(original, cloner) { 247 RegisterParameterEvents(); 248 } 249 public override IDeepCloneable Clone(Cloner cloner) { return new ClassificationProblemData(this, cloner); } 250 251 public ClassificationProblemData() : this(defaultDataset, defaultAllowedInputVariables, defaultTargetVariable) { } 252 public ClassificationProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable) 253 : base(dataset, allowedInputVariables) { 254 var variables = InputVariables.Select(x => x.AsReadOnly()).ToList(); 255 Parameters.Add(new ConstrainedValueParameter<StringValue>(TargetVariableParameterName, new ItemSet<StringValue>(variables), variables.Where(x => x.Value == targetVariable).First())); 256 Parameters.Add(new FixedValueParameter<StringMatrix>(ClassNamesParameterName, "", new StringMatrix())); 257 Parameters.Add(new FixedValueParameter<DoubleMatrix>(ClassificationPenaltiesParameterName, "", new DoubleMatrix())); 258 259 ResetTargetVariableDependentMembers(); 260 RegisterParameterEvents(); 261 } 262 263 private void ResetTargetVariableDependentMembers() { 264 DergisterParameterEvents(); 265 266 classNames = null; 267 ((IStringConvertibleMatrix)ClassNamesParameter.Value).Columns = 1; 268 ((IStringConvertibleMatrix)ClassNamesParameter.Value).Rows = ClassValues.Count; 269 for (int i = 0; i < Classes; i++) 270 ClassNamesParameter.Value[i, 0] = "Class " + ClassValues[i]; 271 ClassNamesParameter.Value.ColumnNames = new List<string>() { "ClassNames" }; 272 ClassNamesParameter.Value.RowNames = ClassValues.Select(s => "ClassValue: " + s); 273 274 classificationPenaltiesCache.Clear(); 275 ((ValueParameter<DoubleMatrix>)ClassificationPenaltiesParameter).ReactOnValueToStringChangedAndValueItemImageChanged = false; 276 ((IStringConvertibleMatrix)ClassificationPenaltiesParameter.Value).Rows = Classes; 277 ((IStringConvertibleMatrix)ClassificationPenaltiesParameter.Value).Columns = Classes; 278 ClassificationPenaltiesParameter.Value.RowNames = ClassNames.Select(name => "Actual " + name); 279 ClassificationPenaltiesParameter.Value.ColumnNames = ClassNames.Select(name => "Estimated " + name); 280 for (int i = 0; i < Classes; i++) { 281 for (int j = 0; j < Classes; j++) { 282 if (i != j) ClassificationPenaltiesParameter.Value[i, j] = 1; 283 else ClassificationPenaltiesParameter.Value[i, j] = 0; 188 284 } 189 285 } 190 } 191 192 private List<double> classValues; 193 [Storable] 194 public IEnumerable<double> ClassValues { 195 get { return classValues; } 196 private set { classValues = new List<double>(value); } 197 } 198 199 public int Classes { 200 get { return classValues.Count; } 201 } 202 203 private Dictionary<double, string> classValueClassNameMapping; 204 private Dictionary<string, double> classNameClassValueMapping; 205 [Storable(Name = "ClassNames")] 206 private IEnumerable<KeyValuePair<double, string>> classValueClassNameMappingStorable { 207 get { return classValueClassNameMapping; } 208 set { 209 classValueClassNameMapping = new Dictionary<double, string>(); 210 foreach (var mapping in value) 211 classValueClassNameMapping[mapping.Key] = mapping.Value; 212 213 classNameClassValueMapping = classValueClassNameMapping.ToDictionary(x => x.Value, x => x.Key); 214 } 215 } 216 public IEnumerable<string> ClassNames { 217 get { return classValueClassNameMapping.Values; } 218 } 219 220 [Storable] 221 private Dictionary<Tuple<double, double>, double> misclassificationMatrix; 222 #endregion 223 224 225 [StorableConstructor] 226 protected ClassificationProblemData(bool deserializing) : base(deserializing) { } 227 protected ClassificationProblemData(ClassificationProblemData original, Cloner cloner) : base(original, cloner) { } 228 public override IDeepCloneable Clone(Cloner cloner) { return new ClassificationProblemData(this, cloner); } 229 230 public ClassificationProblemData() 231 : this(defaultDataset, defaultAllowedInputVariables, defaultTargetVariable) { 232 } 233 234 public ClassificationProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable) 235 : base(dataset, allowedInputVariables) { 236 TargetVariable = targetVariable; 237 238 InitializeTargetVariableDependentMembers(); 239 } 240 241 private void InitializeTargetVariableDependentMembers() { 242 classValues = Dataset.GetEnumeratedVariableValues(targetVariable).Distinct().ToList(); 243 classValues.Sort(); 244 245 classValueClassNameMapping = new Dictionary<double, string>(); 246 foreach (double classValue in ClassValues) { 247 classValueClassNameMapping.Add(classValue, "Class " + classValue); 248 } 249 classNameClassValueMapping = classValueClassNameMapping.ToDictionary(x => x.Value, x => x.Key); 250 OnClassNamesChanged(); 251 252 //set default misclassification matrix 253 misclassificationMatrix = new Dictionary<Tuple<double, double>, double>(); 254 foreach (double classValue1 in ClassValues) { 255 foreach (double classValue2 in ClassValues) { 256 double penalty = 1.0; 257 if (classValue1 == classValue2) penalty = 0.0; 258 SetClassificationPenalty(classValue1, classValue1, penalty); 259 } 260 } 261 OnClassificationPenaltyChanged(); 286 ((ValueParameter<DoubleMatrix>)ClassificationPenaltiesParameter).ReactOnValueToStringChangedAndValueItemImageChanged = true; 287 RegisterParameterEvents(); 262 288 } 263 289 264 290 public string GetClassName(double classValue) { 265 return classValueClassNameMapping[classValue]; 291 if (!ClassValues.Contains(classValue)) throw new ArgumentException(); 292 int index = ClassValues.IndexOf(classValue); 293 return ClassNames[index]; 266 294 } 267 295 public double GetClassValue(string className) { 268 return classNameClassValueMapping[className]; 296 if (!ClassNames.Contains(className)) throw new ArgumentException(); 297 int index = ClassNames.IndexOf(className); 298 return ClassValues[index]; 269 299 } 270 300 public void SetClassName(double classValue, string className) { 271 301 if (!classValues.Contains(classValue)) throw new ArgumentException(); 272 if (classValueClassNameMapping[classValue] != className) { 273 classValueClassNameMapping[classValue] = className; 274 classNameClassValueMapping = classValueClassNameMapping.ToDictionary(x => x.Value, x => x.Key); 275 } 302 int index = ClassValues.IndexOf(classValue); 303 ClassNames[index] = className; 304 ClassNamesParameter.Value[index, 0] = className; 276 305 } 277 306 … … 281 310 public double GetClassificationPenalty(double correctClassValue, double estimatedClassValue) { 282 311 var key = Tuple.Create(correctClassValue, estimatedClassValue); 283 return misclassificationMatrix[key]; 312 if (!classificationPenaltiesCache.ContainsKey(key)) { 313 int correctClassIndex = ClassValues.IndexOf(correctClassValue); 314 int estimatedClassIndex = ClassValues.IndexOf(estimatedClassValue); 315 classificationPenaltiesCache[key] = ClassificationPenaltiesParameter.Value[correctClassIndex, estimatedClassIndex]; 316 } 317 return classificationPenaltiesCache[key]; 284 318 } 285 319 public void SetClassificationPenalty(string correctClassName, string estimatedClassName, double penalty) { … … 288 322 public void SetClassificationPenalty(double correctClassValue, double estimatedClassValue, double penalty) { 289 323 var key = Tuple.Create(correctClassValue, estimatedClassValue); 290 if (!misclassificationMatrix.ContainsKey(key) || misclassificationMatrix[key] != penalty) { 291 misclassificationMatrix[key] = penalty; 292 OnClassificationPenaltyChanged(); 293 } 294 } 295 296 public event EventHandler ClassNamesChanged; 297 protected virtual void OnClassNamesChanged() { 298 var handler = ClassNamesChanged; 299 if (handler != null) handler(this, EventArgs.Empty); 300 } 301 public event EventHandler ClassificationPenaltyChanged; 302 protected virtual void OnClassificationPenaltyChanged() { 303 var handler = ClassificationPenaltyChanged; 304 if (handler != null) handler(this, EventArgs.Empty); 305 } 324 int correctClassIndex = ClassValues.IndexOf(correctClassValue); 325 int estimatedClassIndex = ClassValues.IndexOf(estimatedClassValue); 326 327 ClassificationPenaltiesParameter.Value[correctClassIndex, estimatedClassIndex] = penalty; 328 } 329 330 #region events 331 private void RegisterParameterEvents() { 332 TargetVariableParameter.ValueChanged += new EventHandler(TargetVariableParameter_ValueChanged); 333 ClassNamesParameter.Value.Reset += new EventHandler(Parameter_ValueChanged); 334 ClassNamesParameter.Value.ItemChanged += new EventHandler<EventArgs<int, int>>(MatrixParameter_ItemChanged); 335 ClassificationPenaltiesParameter.Value.Reset += new EventHandler(Parameter_ValueChanged); 336 ClassificationPenaltiesParameter.Value.ItemChanged += new EventHandler<EventArgs<int, int>>(MatrixParameter_ItemChanged); 337 } 338 private void DergisterParameterEvents() { 339 TargetVariableParameter.ValueChanged -= new EventHandler(TargetVariableParameter_ValueChanged); 340 ClassNamesParameter.Value.Reset -= new EventHandler(Parameter_ValueChanged); 341 ClassNamesParameter.Value.ItemChanged -= new EventHandler<EventArgs<int, int>>(MatrixParameter_ItemChanged); 342 ClassificationPenaltiesParameter.Value.Reset -= new EventHandler(Parameter_ValueChanged); 343 ClassificationPenaltiesParameter.Value.ItemChanged -= new EventHandler<EventArgs<int, int>>(MatrixParameter_ItemChanged); 344 } 345 346 private void TargetVariableParameter_ValueChanged(object sender, EventArgs e) { 347 classValues = null; 348 ResetTargetVariableDependentMembers(); 349 OnChanged(); 350 } 351 private void Parameter_ValueChanged(object sender, EventArgs e) { 352 OnChanged(); 353 } 354 private void MatrixParameter_ItemChanged(object sender, EventArgs<int, int> e) { 355 OnChanged(); 356 } 357 #endregion 358 359 #region Import from file 360 public static ClassificationProblemData ImportFromFile(string fileName) { 361 TableFileParser csvFileParser = new TableFileParser(); 362 csvFileParser.Parse(fileName); 363 364 Dataset dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values); 365 dataset.Name = Path.GetFileName(fileName); 366 367 ClassificationProblemData problemData = new ClassificationProblemData(dataset, dataset.VariableNames.Skip(1), dataset.VariableNames.First()); 368 problemData.Name = "Data imported from " + Path.GetFileName(fileName); 369 return problemData; 370 } 371 #endregion 306 372 } 307 373 } -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis/3.4/DataAnalysisProblem.cs
r5578 r5601 33 33 where T : class, IDataAnalysisProblemData { 34 34 private const string ProblemDataParameterName = "ProblemData"; 35 private const string ProblemDataParameterDescription = " ";35 private const string ProblemDataParameterDescription = "The data set, target variable and input variables of the data analysis problem."; 36 36 #region parameter properties 37 37 IParameter IDataAnalysisProblem.ProblemDataParameter { -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis/3.4/DataAnalysisProblemData.cs
r5586 r5601 41 41 42 42 #region parameter properites 43 public I ValueParameter<Dataset> DatasetParameter {44 get { return (I ValueParameter<Dataset>)Parameters[DatasetParameterName]; }43 public IFixedValueParameter<Dataset> DatasetParameter { 44 get { return (IFixedValueParameter<Dataset>)Parameters[DatasetParameterName]; } 45 45 } 46 46 public IFixedValueParameter<ICheckedItemCollection<StringValue>> InputVariablesParameter { … … 64 64 public Dataset Dataset { 65 65 get { return DatasetParameter.Value; } 66 set { DatasetParameter.Value = value; }67 66 } 68 67 public ICheckedItemCollection<StringValue> InputVariables { … … 120 119 int testPartitionEnd = dataset.Rows; 121 120 122 Parameters.Add(new ValueParameter<Dataset>(DatasetParameterName, "", dataset));121 Parameters.Add(new FixedValueParameter<Dataset>(DatasetParameterName, "", dataset)); 123 122 Parameters.Add(new FixedValueParameter<ICheckedItemCollection<StringValue>>(InputVariablesParameterName, "", inputVariables.AsReadOnly())); 124 123 Parameters.Add(new FixedValueParameter<IntValue>(TrainingPartitionStartParameterName, "", new IntValue(trainingPartitionStart))); … … 127 126 Parameters.Add(new FixedValueParameter<IntValue>(TestPartitionEndParameterName, "", new IntValue(testPartitionEnd))); 128 127 128 ((ValueParameter<Dataset>)DatasetParameter).ReactOnValueToStringChangedAndValueItemImageChanged = false; 129 129 RegisterEventHandlers(); 130 130 } -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Classification/IClassificationProblemData.cs
r5559 r5601 20 20 #endregion 21 21 22 using System;23 22 using System.Collections.Generic; 24 23 namespace HeuristicLab.Problems.DataAnalysis { 25 24 public interface IClassificationProblemData : IDataAnalysisProblemData { 26 string TargetVariable { get; set; } 25 string TargetVariable { get; } 26 27 27 IEnumerable<string> ClassNames { get; } 28 28 IEnumerable<double> ClassValues { get; } … … 37 37 void SetClassificationPenalty(string correctClassName, string estimatedClassName, double penalty); 38 38 void SetClassificationPenalty(double correctClassValue, double estimatedClassValue, double penalty); 39 40 event EventHandler ClassNamesChanged;41 event EventHandler ClassificationPenaltyChanged;42 39 } 43 40 } -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataAnalysisProblemData.cs
r5586 r5601 27 27 namespace HeuristicLab.Problems.DataAnalysis { 28 28 public interface IDataAnalysisProblemData : IParameterizedNamedItem { 29 Dataset Dataset { get; set;}29 Dataset Dataset { get; } 30 30 ICheckedItemCollection<StringValue> InputVariables { get; } 31 31 IEnumerable<string> AllowedInputVariables { get; } -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Regression/IRegressionProblemData.cs
r5586 r5601 20 20 #endregion 21 21 22 using HeuristicLab.Data;23 22 namespace HeuristicLab.Problems.DataAnalysis { 24 23 public interface IRegressionProblemData : IDataAnalysisProblemData { 25 StringValueTargetVariable { get; }24 string TargetVariable { get; } 26 25 } 27 26 } -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis/3.4/RegressionProblemData.cs
r5586 r5601 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.IO; … … 31 32 namespace HeuristicLab.Problems.DataAnalysis { 32 33 [StorableClass] 34 [Item("RegressionProblemData", "Represents an item containing all data defining a regression problem.")] 33 35 public sealed class RegressionProblemData : DataAnalysisProblemData, IRegressionProblemData { 34 36 private const string TargetVariableParameterName = "TargetVariable"; … … 78 80 get { return (IValueParameter<StringValue>)Parameters[TargetVariableParameterName]; } 79 81 } 80 public StringValue TargetVariable { 81 get { return TargetVariableParameter.Value; } 82 public string TargetVariable { 83 get { return TargetVariableParameter.Value.Value; } 84 } 85 86 [StorableConstructor] 87 private RegressionProblemData(bool deserializing) : base(deserializing) { } 88 [StorableHook(HookType.AfterDeserialization)] 89 private void AfterDeserialization() { 90 RegisterParameterEvents(); 82 91 } 83 92 84 93 85 [StorableConstructor] 86 private RegressionProblemData(bool deserializing) : base(deserializing) { } 87 private RegressionProblemData(RegressionProblemData original, Cloner cloner) : base(original, cloner) { } 94 private RegressionProblemData(RegressionProblemData original, Cloner cloner) 95 : base(original, cloner) { 96 RegisterParameterEvents(); 97 } 88 98 public override IDeepCloneable Clone(Cloner cloner) { return new RegressionProblemData(this, cloner); } 89 99 … … 94 104 public RegressionProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable) 95 105 : base(dataset, allowedInputVariables) { 96 Parameters.Add(new ConstrainedValueParameter<StringValue>("TargetVariable", new ItemSet<StringValue>(InputVariables), InputVariables.Where(x => x.Value == targetVariable).First())); 106 var variables = InputVariables.Select(x => x.AsReadOnly()).ToList(); 107 Parameters.Add(new ConstrainedValueParameter<StringValue>(TargetVariableParameterName, new ItemSet<StringValue>(variables), variables.Where(x => x.Value == targetVariable).First())); 97 108 } 98 109 110 private void RegisterParameterEvents() { 111 TargetVariableParameter.ValueChanged += new EventHandler(TargetVariableParameter_ValueChanged); 112 } 113 private void TargetVariableParameter_ValueChanged(object sender, EventArgs e) { 114 OnChanged(); 115 } 116 117 #region Import from file 99 118 public static RegressionProblemData ImportFromFile(string fileName) { 100 119 TableFileParser csvFileParser = new TableFileParser(); … … 108 127 return problemData; 109 128 } 129 #endregion 110 130 } 111 131 } -
branches/DataAnalysis Refactoring/HeuristicLab/3.3/Files.txt
r5573 r5601 62 62 HeuristicLab.Problems.DataAnalysis.Classification.Views\3.3:HeuristicLab.Problems.DataAnalysis.Classification.Views-3.3.dll 63 63 HeuristicLab.Problems.DataAnalysis.Regression\3.3:HeuristicLab.Problems.DataAnalysis.Regression-3.3.dll 64 HeuristicLab.Problems.DataAnalysis.Regression\3.4:HeuristicLab.Problems.DataAnalysis.Regression-3.4.dll65 64 HeuristicLab.Problems.DataAnalysis.Symbolic\3.4:HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.dll 66 65 HeuristicLab.Problems.DataAnalysis.Symbolic.Classification\3.4:HeuristicLab.Problems.DataAnalysis.Symbolic.Classification-3.4.dll 67 66 HeuristicLab.Problems.DataAnalysis.Symbolic.Regression\3.4:HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.dll 68 67 HeuristicLab.Problems.DataAnalysis.Views\3.3:HeuristicLab.Problems.DataAnalysis.Views-3.3.dll 68 HeuristicLab.Problems.DataAnalysis.Views\3.4:HeuristicLab.Problems.DataAnalysis.Views-3.4.dll 69 69 HeuristicLab.Problems.ExternalEvaluation\3.3:HeuristicLab.Problems.ExternalEvaluation-3.3.dll 70 70 HeuristicLab.Problems.ExternalEvaluation.Views\3.3:HeuristicLab.Problems.ExternalEvaluation.Views-3.3.dll
Note: See TracChangeset
for help on using the changeset viewer.