- Timestamp:
- 02/25/21 15:20:42 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationProblemData.cs
r17835 r17845 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; … … 314 315 315 316 public ClassificationProblemData(IClassificationProblemData classificationProblemData) 316 : this(classificationProblemData.Dataset, classificationProblemData.AllowedInputVariables, classificationProblemData.TargetVariable, classificationProblemData.ClassNames, classificationProblemData.PositiveClass) { 317 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 318 330 TrainingPartition.Start = classificationProblemData.TrainingPartition.Start; 319 331 TrainingPartition.End = classificationProblemData.TrainingPartition.End; 320 332 TestPartition.Start = classificationProblemData.TestPartition.Start; 321 333 TestPartition.End = classificationProblemData.TestPartition.End; 322 334 323 335 for (int i = 0; i < Classes; i++) { 324 336 for (int j = 0; j < Classes; j++) { … … 328 340 } 329 341 330 public ClassificationProblemData(IDataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable, IEnumerable<ITransformation> transformations = null)331 : this(dataset, allowedInputVariables, targetVariable, Enumerable.Empty<string>(), null, transformations) { }332 333 342 public ClassificationProblemData(IDataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable, 334 IEnumerable<string> classNames ,343 IEnumerable<string> classNames = null, 335 344 string positiveClass = null, // can be null in which case it's set as the first class name 336 345 IEnumerable<ITransformation> transformations = null) … … 348 357 349 358 // set the class names 350 if (classNames .Any()) {359 if (classNames != null && classNames.Any()) { 351 360 // better to allocate lists because we use these multiple times below 352 361 var names = classNames.ToList(); 353 var values = ClassValues .ToList();362 var values = ClassValuesCache; 354 363 355 364 if (names.Count != values.Count) {
Note: See TracChangeset
for help on using the changeset viewer.