Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/19/18 13:27:06 (6 years ago)
Author:
mkommend
Message:

#2955: Added IsProblemDataCompatible and IsDatasetCompatible to all DataAnalysisModels.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionModel.cs

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