Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/28/18 22:21:11 (5 years ago)
Author:
gkronber
Message:

#2915: merged r16241:16309 (current HEAD) from HL trunk to branch

Location:
branches/2915-AbsoluteSymbol
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2915-AbsoluteSymbol

  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis

  • branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationProblemData.cs

    r15583 r16332  
    467467    }
    468468    #endregion
    469 
    470     protected override bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage) {
    471       if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
    472       IClassificationProblemData classificationProblemData = problemData as IClassificationProblemData;
    473       if (classificationProblemData == null)
    474         throw new ArgumentException("The problem data is no classification problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");
    475 
    476       var returnValue = base.IsProblemDataCompatible(classificationProblemData, out errorMessage);
    477       //check targetVariable
    478       if (classificationProblemData.InputVariables.All(var => var.Value != TargetVariable)) {
    479         errorMessage = string.Format("The target variable {0} is not present in the new problem data.", TargetVariable)
    480                        + Environment.NewLine + errorMessage;
    481         return false;
    482       }
    483 
    484       var newClassValues = classificationProblemData.Dataset.GetDoubleValues(TargetVariable).Distinct().OrderBy(x => x);
    485       if (!newClassValues.SequenceEqual(ClassValues)) {
    486         errorMessage = errorMessage + string.Format("The class values differ in the provided classification problem data.");
    487         returnValue = false;
    488       }
    489 
    490       var newPositivieClassName = classificationProblemData.PositiveClass;
    491       if (newPositivieClassName != PositiveClass) {
    492         errorMessage = errorMessage + string.Format("The positive class differs in the provided classification problem data.");
    493         returnValue = false;
    494       }
    495 
    496       return returnValue;
    497     }
    498 
    499     public override void AdjustProblemDataProperties(IDataAnalysisProblemData problemData) {
    500       if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
    501       ClassificationProblemData classificationProblemData = problemData as ClassificationProblemData;
    502       if (classificationProblemData == null)
    503         throw new ArgumentException("The problem data is not a classification problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");
    504 
    505       base.AdjustProblemDataProperties(problemData);
    506       TargetVariable = classificationProblemData.TargetVariable;
    507       for (int i = 0; i < classificationProblemData.ClassNames.Count(); i++)
    508         ClassNamesParameter.Value[i, 0] = classificationProblemData.ClassNames.ElementAt(i);
    509 
    510       PositiveClass = classificationProblemData.PositiveClass;
    511 
    512       for (int i = 0; i < Classes; i++) {
    513         for (int j = 0; j < Classes; j++) {
    514           ClassificationPenaltiesParameter.Value[i, j] = classificationProblemData.GetClassificationPenalty(ClassValuesCache[i], ClassValuesCache[j]);
    515         }
    516       }
    517     }
    518469  }
    519470}
Note: See TracChangeset for help on using the changeset viewer.