skbase.lookup.all_objects#
- skbase.lookup.all_objects(object_types=None, filter_tags=None, exclude_objects=None, exclude_estimators=None, return_names=True, as_dataframe=False, return_tags=None, suppress_import_stdout=True, package_name='skbase', path: str | None = None, modules_to_ignore=None, ignore_modules=None, class_lookup=None)[source]#
Get a list of all objects in a package with name package_name.
This function crawls the package/module to retreive all classes that are descendents of BaseObject. By default it does this for the skbase package, but users can specify package_name or path to another project and all_objects will crawl and retrieve BaseObjects found in that project.
- Parameters:
- object_types: class or list of classes, default=None
If class_lookup is provided, can also be str or list of str which kind of objects should be returned.
If None, no filter is applied and all estimators are returned.
If class or list of class, estimators are filtered to inherit from one of these.
If str or list of str, classes can be aliased by strings, as long as class_lookup parameter is passed a lookup dict.
- return_names: bool, default=True
If True, estimator class name is included in the all_estimators() return in the order: name, estimator class, optional tags, either as a tuple or as pandas.DataFrame columns.
If False, estimator class name is removed from the all_estimators() return.
- filter_tags: str, list[str] or dict[str, Any], default=None
Filter used to determine if klass has tag or expected tag values.
If a str or list of strings is provided, the return will be filtered to keep classes that have all the tag(s) specified by the strings.
If a dict is provided, the return will be filtered to keep classes that have all dict keys as tags. Tag values are also checked such that:
If a dict key maps to a single value only classes with tag values equal to the value are returned.
If a dict key maps to multiple values (e.g., list) only classes with tag values in these values are returned.
- exclude_objects: str or list[str], default=None
Names of estimators to exclude.
- as_dataframe: bool, default=False
If False, all_objects will return a list (either a list of skbase objects or a list of tuples, see Returns).
- If True, all_objects will return a pandas.DataFrame with named
columns for all of the attributes being returned. this requires soft dependency pandas to be installed.
- return_tags: str or list of str, default=None
Names of tags to fetch and return each object’s value of. The tag values named in return_tags will be fetched for each object and will be appended as either columns or tuple entries.
- package_namestr, default=”skbase”.
Should be set to default to package or module name that objects will be retrieved from. Objects will be searched inside package_name, including in sub-modules (e.g., in package_name, package_name.module1, package.module2, and package.module1.module3).
- pathstr, default=None
If provided, this should be the path that should be used as root to find package_name and start the search for any submodules/packages. This can be left at the default value (None) if searching in an installed package.
- modules_to_ignorestr or list[str], default=None
The modules that should be ignored when searching across the modules to gather objects. If passed, all_objects ignores modules or submodules of a module whose name is in the provided string(s). E.g., if modules_to_ignore contains the string “foo”, then “bar.foo”, “foo”, “foo.bar”, “bar.foo.bar” are ignored.
- class_lookupdict[str, class], default=None
Dictionary of string aliases for classes used in object_types. If provided, object_types can accept str values or a list of string values.
- Returns:
- all_estimators will return one of the following:
- a pandas.DataFrame if as_dataframe=True, with columns:
“names” with the returned class names if return_name=True
“objects” with returned classes.
optional columns named based on tags passed in return_tags if return_tags is not None.
- a list if as_dataframe=False, where list elements are:
classes (that inherit from BaseObject) in alphabetic order by class name if return_names=False and `return_tags=None.
(name, class) tuples in alphabetic order by name if return_names=True and return_tags=None.
(name, class, tag-value1, …, tag-valueN) tuples in alphabetic order by name if return_names=True and return_tags is not None.
(class, tag-value1, …, tag-valueN) tuples in alphabetic order by class name if return_names=False and return_tags is not None.
- Other Parameters:
- suppress_import_stdoutbool, default=True
Whether to suppress stdout printout upon import.
References
Modified version of scikit-learn’s and sktime’s all_estimators() to allow users to find BaseObjects in skbase and other packages.