check_estimator¶
- check_estimator(estimator: BaseAeonEstimator | type[BaseAeonEstimator], raise_exceptions: bool = False, use_first_parameter_set: bool = False, checks_to_run: str | list[str] | None = None, checks_to_exclude: str | list[str] | None = None, full_checks_to_run: str | list[str] | None = None, full_checks_to_exclude: str | list[str] | None = None, verbose: bool = False)[source]¶
Check if estimator adheres to aeon conventions.
This function will run an extensive test-suite to make sure that the estimator complies with aeon conventions. The checks run will differ based on the estimator input. There is a set of general checks for all estimators, and module-specific tests for classifiers, anomaly detectors, transformer, etc. Some checks may be skipped if the estimator has certain tags i.e. non_deterministic.
- Parameters:
- estimatoraeon BaseAeonEstimator instance or class
Estimator to run checks on. If estimator is a class, an instance will be created using BaseAeonEstimator._create_test_instance().
- raise_exceptionsbool, optional, default=False
- Whether to return exceptions/failures in the results dict, or raise them
if False: returns exceptions in returned results dict if True: raises exceptions as they occur
- use_first_parameter_setbool, default=False
If True, only the first parameter set from _get_test_params will be used if a class is passed.
- checks_to_runstr or list of str, default=None
Name(s) of checks to run. This should include the function name of the check to run without parameterization, i.e. “check_clone” or “check_fit_updates_state”.
Checks not passed will be excluded from testing. If None, all checks are run (unless excluded elsewhere).
- checks_to_excludestr or list of str, default=None
Name(s) of checks to exclude. This should include the function name of the check to exclude without parameterization, i.e. “check_clone” or “check_fit_updates_state”.
If None, no checks are excluded (unless excluded elsewhere).
- full_checks_to_runstr or list of str, default=None
Full check name string(s) of checks to run. This should include the function name of the check to run with parameterization, i.e. “check_clone(estimator=MockClassifier())” or “check_fit_updates_state(estimator=MockClassifier())”.
Checks not passed will be excluded from testing. If None, all checks are run (unless excluded elsewhere).
- full_checks_to_excludestr or list of str, default=None
Full check name string(s) of checks to exclude. This should include the function name of the check to exclude with parameterization, i.e. “check_clone(estimator=MockClassifier())” or “check_fit_updates_state(estimator=MockClassifier())”.
If None, no checks are excluded (unless excluded elsewhere).
- verbosestr, optional, default=False.
Whether to print out informative summary of tests run.
- Returns:
- resultsdict of test results
The test results. Keys are parameterized check strings. The id of each check is set to be the name of the check with its keyword arguments, including a pprint version of the estimator.
Entries are the string “PASSED” if the test passed, the exception raised if the test did not pass, or the reason for skipping the test.
If raise_exceptions is True, this is only returned if all tests pass.
See also
parametrize_with_checksPytest specific decorator for parametrizing estimator checks.
Examples
>>> from aeon.testing.mock_estimators import MockClassifier >>> from aeon.testing.estimator_checking import check_estimator
Running all tests for MockClassifier class >>> results = check_estimator(MockClassifier)
Running all tests for a MockClassifier instance >>> results = check_estimator(MockClassifier())
Running specific check for MockClassifier >>> check_estimator(MockClassifier, checks_to_run=”check_get_params”) {‘check_get_params(estimator=MockClassifier())’: ‘PASSED’}