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/DataAnalysisModel.cs

    r15584 r17054  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using HeuristicLab.Common;
     
    3839
    3940    public abstract IEnumerable<string> VariablesUsedForPrediction { get; }
     41
     42    public virtual bool IsDatasetCompatible(IDataset dataset, out string errorMessage) {
     43      if (dataset == null) throw new ArgumentNullException("dataset", "The provided dataset is null.");
     44      return IsDatasetCompatible(this, dataset, out errorMessage);
     45    }
     46
     47    public abstract bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage);
     48
     49    public static bool IsDatasetCompatible(IDataAnalysisModel model, IDataset dataset, out string errorMessage) {
     50      if(model == null) throw new ArgumentNullException("model", "The provided model is null.");
     51      if (dataset == null) throw new ArgumentNullException("dataset", "The provided dataset is null.");
     52      errorMessage = string.Empty;
     53
     54      foreach (var variable in model.VariablesUsedForPrediction) {
     55        if (!dataset.ContainsVariable(variable)) {
     56          if (string.IsNullOrEmpty(errorMessage)) {
     57            errorMessage = "The following variables must be present in the dataset for model evaluation:";
     58          }
     59          errorMessage += System.Environment.NewLine + " " + variable;
     60        }
     61      }
     62
     63      return string.IsNullOrEmpty(errorMessage);
     64    }
    4065  }
    4166}
Note: See TracChangeset for help on using the changeset viewer.