- Timestamp:
- 03/11/21 15:45:17 (4 years ago)
- Location:
- branches/3073_IA_constraint_splitting/HeuristicLab.Problems.DataAnalysis
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3073_IA_constraint_splitting/HeuristicLab.Problems.DataAnalysis
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis merged: 17835,17845
- Property svn:mergeinfo changed
-
branches/3073_IA_constraint_splitting/HeuristicLab.Problems.DataAnalysis/3.4
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis/3.4 (added) merged: 17835,17845
- Property svn:mergeinfo changed
-
branches/3073_IA_constraint_splitting/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationEnsembleProblemData.cs
r17180 r17874 73 73 74 74 public ClassificationEnsembleProblemData() : base() { } 75 75 76 public ClassificationEnsembleProblemData(IClassificationProblemData classificationProblemData) 76 : base(classificationProblemData.Dataset, classificationProblemData.AllowedInputVariables, classificationProblemData.TargetVariable) { 77 this.TrainingPartition.Start = classificationProblemData.TrainingPartition.Start; 78 this.TrainingPartition.End = classificationProblemData.TrainingPartition.End; 79 this.TestPartition.Start = classificationProblemData.TestPartition.Start; 80 this.TestPartition.End = classificationProblemData.TestPartition.End; 81 this.PositiveClass = classificationProblemData.PositiveClass; 77 : base(classificationProblemData) { 82 78 } 83 79 … … 85 81 : base(dataset, allowedInputVariables, targetVariable) { 86 82 } 83 84 public ClassificationEnsembleProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable, IEnumerable<string> classNames, string positiveClass = null) 85 : base(dataset, allowedInputVariables, targetVariable, classNames, positiveClass) { 86 } 87 87 } 88 88 } -
branches/3073_IA_constraint_splitting/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationEnsembleSolution.cs
r17180 r17874 260 260 evaluationCache.Clear(); 261 261 262 IClassificationProblemData problemData = new ClassificationProblemData(ProblemData.Dataset, 263 ProblemData.AllowedInputVariables, 264 ProblemData.TargetVariable); 265 problemData.TrainingPartition.Start = ProblemData.TrainingPartition.Start; 266 problemData.TrainingPartition.End = ProblemData.TrainingPartition.End; 267 problemData.TestPartition.Start = ProblemData.TestPartition.Start; 268 problemData.TestPartition.End = ProblemData.TestPartition.End; 262 IClassificationProblemData problemData = new ClassificationProblemData(ProblemData); 269 263 270 264 foreach (var solution in ClassificationSolutions) { -
branches/3073_IA_constraint_splitting/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationProblemData.cs
r17180 r17874 306 306 classNamesCache.Add(ClassNamesParameter.Value[i, 0]); 307 307 } 308 308 309 public override IDeepCloneable Clone(Cloner cloner) { 309 310 if (this == emptyProblemData) return emptyProblemData; … … 311 312 } 312 313 313 public ClassificationProblemData() : this(defaultDataset, defaultAllowedInputVariables, defaultTargetVariable ) { }314 public ClassificationProblemData() : this(defaultDataset, defaultAllowedInputVariables, defaultTargetVariable, Enumerable.Empty<string>()) { } 314 315 315 316 public ClassificationProblemData(IClassificationProblemData classificationProblemData) 316 : this(classificationProblemData.Dataset, classificationProblemData.AllowedInputVariables, classificationProblemData.TargetVariable) { 317 : this(classificationProblemData, classificationProblemData.Dataset) { 318 } 319 320 /// <summary> 321 /// This method satisfies a common use case: making a copy of the problem but providing a different dataset. 322 /// One must be careful here that the dataset passed is not modified, as that would invalidate the problem data internals. 323 /// Passing a ModifiableDataset to this constructor is therefore discouraged. 324 /// </summary> 325 /// <param name="classificationProblemData">The original instance of classification problem data.</param> 326 /// <param name="dataset">The new dataset.</param> 327 public ClassificationProblemData(IClassificationProblemData classificationProblemData, IDataset dataset) 328 : this(classificationProblemData.Dataset, classificationProblemData.AllowedInputVariables, classificationProblemData.TargetVariable, classificationProblemData.ClassNames, classificationProblemData.PositiveClass) { 329 317 330 TrainingPartition.Start = classificationProblemData.TrainingPartition.Start; 318 331 TrainingPartition.End = classificationProblemData.TrainingPartition.End; … … 320 333 TestPartition.End = classificationProblemData.TestPartition.End; 321 334 322 for (int i = 0; i < classificationProblemData.ClassNames.Count(); i++)323 ClassNamesParameter.Value[i, 0] = classificationProblemData.ClassNames.ElementAt(i);324 325 //mkommend: The positive class depends on the class names and as a result must only be set after the classe names parameter.326 PositiveClass = classificationProblemData.PositiveClass;327 328 335 for (int i = 0; i < Classes; i++) { 329 336 for (int j = 0; j < Classes; j++) { … … 333 340 } 334 341 335 public ClassificationProblemData(IDataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable, IEnumerable<ITransformation> transformations = null) 342 public ClassificationProblemData(IDataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable, 343 IEnumerable<string> classNames = null, 344 string positiveClass = null, // can be null in which case it's set as the first class name 345 IEnumerable<ITransformation> transformations = null) 336 346 : base(dataset, allowedInputVariables, transformations ?? Enumerable.Empty<ITransformation>()) { 337 347 var validTargetVariableValues = CheckVariablesForPossibleTargetVariables(dataset).Select(x => new StringValue(x).AsReadOnly()).ToList(); … … 339 349 340 350 Parameters.Add(new ConstrainedValueParameter<StringValue>(TargetVariableParameterName, new ItemSet<StringValue>(validTargetVariableValues), target)); 341 Parameters.Add(new FixedValueParameter<StringMatrix>(ClassNamesParameterName, "" ));351 Parameters.Add(new FixedValueParameter<StringMatrix>(ClassNamesParameterName, "", new StringMatrix())); 342 352 Parameters.Add(new ConstrainedValueParameter<StringValue>(PositiveClassParameterName, "The positive class which is used for quality measure calculation (e.g., specifity, sensitivity,...)")); 343 353 Parameters.Add(new FixedValueParameter<DoubleMatrix>(ClassificationPenaltiesParameterName, "")); 344 354 345 355 RegisterParameterEvents(); 346 ResetTargetVariableDependentMembers(); 356 ResetTargetVariableDependentMembers(); // correctly set the values of the parameters added above 357 358 // set the class names 359 if (classNames != null && classNames.Any()) { 360 // better to allocate lists because we use these multiple times below 361 var names = classNames.ToList(); 362 var values = ClassValuesCache; 363 364 if (names.Count != values.Count) { 365 throw new ArgumentException(); 366 } 367 368 ((IStringConvertibleMatrix)ClassNamesParameter.Value).Columns = 1; 369 ((IStringConvertibleMatrix)ClassNamesParameter.Value).Rows = names.Count; 370 371 for (int i = 0; i < names.Count; ++i) { 372 SetClassName(values[i], names[i]); 373 } 374 } 375 376 // set the positive class value 377 if (positiveClass != null) { 378 PositiveClass = positiveClass; 379 } 347 380 } 348 381
Note: See TracChangeset
for help on using the changeset viewer.