Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/04/19 13:00:24 (5 years ago)
Author:
mkommend
Message:

#2955: Merged r16241, r16243, r16244, r16763 into stable.

Location:
stable
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Problems.DataAnalysis

  • stable/HeuristicLab.Problems.DataAnalysis/3.4

  • stable/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationModel.cs

    r15584 r17054  
    6666    public abstract IClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData);
    6767
     68    public virtual bool IsProblemDataCompatible(IClassificationProblemData problemData, out string errorMessage) {
     69      return IsProblemDataCompatible(this, problemData, out errorMessage);
     70    }
     71
     72    public override bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage) {
     73      if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
     74      var classificationProblemData = problemData as IClassificationProblemData;
     75      if (classificationProblemData == null)
     76        throw new ArgumentException("The problem data is not compatible with this classification model. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");
     77      return IsProblemDataCompatible(classificationProblemData, out errorMessage);
     78    }
     79
     80    public static bool IsProblemDataCompatible(IClassificationModel model, IClassificationProblemData problemData, out string errorMessage) {
     81      if (model == null) throw new ArgumentNullException("model", "The provided model is null.");
     82      if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");
     83      errorMessage = string.Empty;
     84
     85      if (model.TargetVariable != problemData.TargetVariable)
     86        errorMessage = string.Format("The target variable of the model {0} does not match the target variable of the problemData {1}.", model.TargetVariable, problemData.TargetVariable);
     87
     88      var evaluationErrorMessage = string.Empty;
     89      var datasetCompatible = model.IsDatasetCompatible(problemData.Dataset, out evaluationErrorMessage);
     90      if (!datasetCompatible)
     91        errorMessage += evaluationErrorMessage;
     92
     93      return string.IsNullOrEmpty(errorMessage);
     94    }
     95
    6896    #region events
    6997    public event EventHandler TargetVariableChanged;
Note: See TracChangeset for help on using the changeset viewer.