Pick and rank the algorithms an AutoML run should try.
A wall-clock budget is spent one candidate at a time, so the order matters more than the list: whatever is tried first is what a short run gets to keep. This module queries the registry for every algorithm that fits the task, drops the ones that cannot run here, and returns them cheap-and-strong first -- linear and tree baselines, then kernel and instance methods, then ensembles, then boosting, then deep models.
python
>>> from tuiml.automl.portfolio import build_portfolio
>>> names = [c.name for c in build_portfolio("classification")]
>>> "LogisticRegression" in names
True
>>> names.index("LogisticRegression") < names.index("XGBoostClassifier")
True
Classes
One algorithm an AutoML run may try.
Parameters
name
str
Registry name, e.g.
"RandomForestClassifier".
cls
type
The algorithm class itself.
tier
int
Cost tier index (lower is cheaper); see
_TIERS.
tags
tuple of str
The registry tags the algorithm was registered with.
Functions
build_portfolio(task: str, *, candidates: Optional[Iterable[Any]]=None, exclude: Optional[Iterable[str]]=None, exclude_tags: Optional[Iterable[str]]=None, include_wrappers: bool=False, max_candidates: Optional[int]=None) -> List[Candidate]
Return the ranked candidate algorithms for a task.
Overview
- Ask the registry for every component of the task's type.
-
Drop namespaced wrapper keys (
sklearn.SVC,weka.J48) unless
include_wrappers=True: they duplicate native algorithms and need an extra installed.
-
Drop anything tagged with
DEFAULT_EXCLUDED_TAGS, and anything
-
Sort by
(tier, preference, name)-- a total order with no ties, so
Parameters
task
{"classification", "regression"}
Which kind of algorithm to collect.
candidates
iterable of str or type
An explicit list that overrides discovery entirely. Names are resolved through the registry; classes are used as given. The order is kept as written, since an explicit list is already a statement of preference.
exclude
iterable of str
Registry names to leave out.
exclude_tags
iterable of str
Tags to leave out, replacing
DEFAULT_EXCLUDED_TAGS.
include_wrappers
bool
= False
Keep namespaced wrapper entries such as
"sklearn.SVC".
max_candidates
int
Truncate the ranked list to this many entries.
Returns
portfolio
list of Candidate
Ranked candidates, cheapest and most reliable first.
Raises
ValueError
If
task is not a known task name.
python
>>> from tuiml.automl.portfolio import build_portfolio
>>> portfolio = build_portfolio("regression", max_candidates=3)
>>> [c.name for c in portfolio]
['LinearRegression', 'BayesianLinearRegressor', 'SGDRegressor']
An explicit list is used verbatim:
json
>>> [c.name for c in build_portfolio(
... "classification", candidates=["SVC", "NaiveBayesClassifier"])]
['SVC', 'NaiveBayesClassifier']
describe_portfolio(portfolio: Sequence[Candidate]) -> List[Dict[str, Any]]
Render a portfolio as plain dicts, for logging or display.
Parameters
portfolio
sequence of Candidate
The candidates to describe.
Returns
rows
list of dict
One
{"rank", "name", "tier", "tags"} dict per candidate.
python
>>> from tuiml.automl.portfolio import build_portfolio, describe_portfolio
>>> describe_portfolio(build_portfolio("regression", max_candidates=1))
[{'rank': 1, 'name': 'LinearRegression', 'tier': 0, 'tags': ['linear', 'regression', 'interpretable']}]