コード例 #1
0
ファイル: data_checks.py プロジェクト: yutiansut/evalml
 def _validate_data_checks(data_check_classes, params):
     """Inits a DataChecks instance from a list of DataCheck classes and corresponding params."""
     if not isinstance(data_check_classes, list):
         raise ValueError(
             f"Parameter data_checks must be a list. Received {type(data_check_classes).__name__}."
         )
     if not all(
             inspect.isclass(check) and issubclass(check, DataCheck)
             for check in data_check_classes):
         raise ValueError(
             "All elements of parameter data_checks must be an instance of DataCheck "
             "or a DataCheck class with any desired parameters specified in the "
             "data_check_params dictionary.")
     params = params or dict()
     if not isinstance(params, dict):
         raise ValueError(f"Params must be a dictionary. Received {params}")
     in_params = set(params.keys())
     in_classes = set([c.name for c in data_check_classes])
     name_to_class = {c.name: c for c in data_check_classes}
     extraneous = in_params.difference(in_classes)
     missing = in_classes.difference(in_params)
     for extraneous_class in extraneous:
         raise DataCheckInitError(
             f"Class {extraneous_class} was provided in params dictionary but it does not match any name "
             "in the data_check_classes list. Make sure every key of the params dictionary matches the name"
             "attribute of a corresponding DataCheck class.")
     for missing_class_name in missing:
         if not _has_defaults_for_all_args(
                 name_to_class[missing_class_name]):
             raise DataCheckInitError(
                 f"Class {missing_class_name} was provided in the data_checks_classes list but it does not have "
                 "an entry in the parameters dictionary.")
コード例 #2
0
ファイル: data_checks.py プロジェクト: yutiansut/evalml
 def _init_data_checks(data_check_classes, params):
     data_check_instances = []
     for data_check_class in data_check_classes:
         class_params = params.get(data_check_class.name, {})
         if not isinstance(class_params, dict):
             raise DataCheckInitError(
                 f"Parameters for {data_check_class.name} were not in a dictionary. Received {class_params}."
             )
         try:
             data_check_instances.append(data_check_class(**class_params))
         except TypeError as e:
             raise DataCheckInitError(
                 f"Encountered the following error while initializing {data_check_class.name}: {e}"
             )
     return data_check_instances