skbase.lookup.all_objects#
- skbase.lookup.all_objects(object_types=None, filter_tags=None, exclude_objects=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, class_lookup=None)[source]#
Get a list of all objects in a package, optionally filtered by type and tags.
This function crawls the package/module to retrieve all classes that are descendents of
BaseObject, or another specified class, from a module and all submodules, specified bypackage_nameoand``path``.The retrieved objects can be filtered by type, tags, and excluded by name.
all_objectswill crawl and return references to the retrieved classes.- Parameters:
- object_types: class or tuple, 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_objectsreturn in the order: name, estimator class, optional tags, either as a tuple or aspandas.DataFramecolumns.If False, estimator class name is removed from the
all_objectsreturn.
- filter_tags: str, list[str] or dict[str, Any], default=None
Filter used to determine if
klasshas 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 exactly the classes where tags satisfy all the filter conditions specified by
filter_tags. Filter conditions are as follows, fortag_name: search_valuepairs in thefilter_tagsdict.If
klassdoes not have a tag with nametag_name, it is excluded. Otherwise, lettag_valuebe the value of the tag with nametag_name.If
search_valueis a string, andtag_valueis a string, the filter condition is thatsearch_valuemust match the tag value.If
search_valueis a string, andtag_valueis a list, the filter condition is thatsearch_valueis contained intag_value.If
search_valueis are.Pattern, andtag_valueis a string, the filter condition is thatsearch_value.fullmatch(tag_value)is true, i.e., the regex matches the tag value.If
search_valueis are.Pattern, andtag_valueis a list, the filter condition is that at least one element oftag_valuematches the regex.If
search_valueis iterable, then the filter condition is that at least one element ofsearch_valuesatisfies the above conditions, applied totag_value.
- 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., inpackage_name,package_name.module1,package.module2, andpackage.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_objectsignores modules or submodules of a module whose name is in the provided string(s). E.g., ifmodules_to_ignorecontains 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_typescan accept str values or a list of string values.- suppress_import_stdoutbool, default=True
Whether to suppress stdout printout upon import. If True,
all_objectswill suppress any stdout printout internally. If False,all_objectswill not suppress any stdout printout arising from crawling the package.
- Returns:
all_objectswill 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_tagsifreturn_tags is not None.
- a pandas.DataFrame if
- a list if
as_dataframe=False, where list elements are: classes (that inherit from
BaseObject) in alphabetic order by class name ifreturn_names=Falseandreturn_tags=None.(name, class) tuples in alphabetic order by name if
return_names=Trueandreturn_tags=None.(name, class, tag-value1, …, tag-valueN) tuples in alphabetic order by name if
return_names=Trueandreturn_tags is not None.(class, tag-value1, …, tag-valueN) tuples in alphabetic order by class name if
return_names=Falseandreturn_tags is not None.
- a list if
References
Modified version of
scikit-learn’s and sktime’sall_estimatorsto allow users to findBaseObjectdescendants inskbaseand other packages.