Components
amltk.pipeline.components
#
The provided subclasses of a Node
that can be used can be assembled into a pipeline.
Choice
dataclass
#
Choice(
*nodes: Node | NodeLike,
name: str | None = None,
item: Item | Callable[[Item], Item] | None = None,
config: Config | None = None,
space: Space | None = None,
fidelities: Mapping[str, Any] | None = None,
config_transform: (
Callable[[Config, Any], Config] | None
) = None,
meta: Mapping[str, Any] | None = None
)
A Choice
between different subcomponents.
This indicates that a choice should be made between the different children in
.nodes
, usually done when you
configure()
with some config
from
a search_space()
.
from amltk.pipeline import Choice, Component
from sklearn.ensemble import RandomForestClassifier
from sklearn.neural_network import MLPClassifier
rf = Component(RandomForestClassifier, space={"n_estimators": (10, 100)})
mlp = Component(MLPClassifier, space={"activation": ["logistic", "relu", "tanh"]})
estimator_choice = Choice(rf, mlp, name="estimator")
╭─ Choice(estimator) ──────────────────────────────────────────────────────────╮
│ ╭─ Component(MLPClassifier) ─────╮ ╭─ Component(RandomForestClassifier)─╮ │
│ │ item class MLPClassifier(...) │ │ item class │ │
│ │ space { │ │ RandomForestClassifier(...) │ │
│ │ 'activation': [ │ │ space {'n_estimators': (10, 100)} │ │
│ │ 'logistic', │ ╰────────────────────────────────────╯ │
│ │ 'relu', │ │
│ │ 'tanh' │ │
│ │ ] │ │
│ │ } │ │
│ ╰────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────╯
Order of nodes
The given nodes of a choice are always ordered according
to their name, so indexing choice.nodes
may not be reliable
if modifying the choice dynamically.
Please use choice["name"]
to access the nodes instead.
See Also
PARAMETER | DESCRIPTION |
---|---|
nodes |
The nodes that should be chosen between for this node.
TYPE:
|
item |
The item attached to this node (if any). |
name |
The name of the node. If not specified, the name will be randomly generated.
TYPE:
|
config |
The configuration for this node.
TYPE:
|
space |
The search space for this node. This will be used when
TYPE:
|
fidelities |
The fidelities for this node. |
config_transform |
A function that transforms the |
meta |
Any meta information about this node. |
Source code in src/amltk/pipeline/components.py
config
class-attribute
instance-attribute
#
The configuration for this node
config_transform
class-attribute
instance-attribute
#
A function that transforms the configuration of this node
fidelities
class-attribute
instance-attribute
#
The fidelities for this node
item
class-attribute
instance-attribute
#
The item attached to this node
meta
class-attribute
instance-attribute
#
Any meta information about this node
nodes
instance-attribute
#
The choice of possible nodes that this choice could take.
space
class-attribute
instance-attribute
#
The search space for this node
__getitem__
#
Get the first from .nodes
with key
.
Source code in src/amltk/pipeline/node.py
build
#
build(
builder: (
Callable[Concatenate[Node, P], BuilderOutput]
| Literal["sklearn"]
),
*builder_args: args,
**builder_kwargs: kwargs
) -> BuilderOutput | Pipeline
Build a concrete object out of this node.
PARAMETER | DESCRIPTION |
---|---|
builder |
The builder to use. This can be a function that takes in the node and returns the object or a string that is one of:
TYPE:
|
builder_args |
The positional arguments to pass to the builder
TYPE:
|
builder_kwargs |
The keyword arguments to pass to the builder
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
BuilderOutput | Pipeline
|
The built object |
Source code in src/amltk/pipeline/node.py
chosen
#
chosen() -> Node
The chosen branch.
RETURNS | DESCRIPTION |
---|---|
Node
|
The chosen branch |
Source code in src/amltk/pipeline/components.py
configure
#
configure(
config: Config,
*,
prefixed_name: bool | None = None,
transform_context: Any | None = None,
params: Mapping[str, Any] | None = None
) -> Self
Configure this node and anything following it with the given config.
Configuring a choice
For a Choice, if the config has a __choice__
key, then only the node
chosen will be configured. The others will not be configured at all and
their config will be discarded.
PARAMETER | DESCRIPTION |
---|---|
config |
The configuration to apply
TYPE:
|
prefixed_name |
Whether items in the config are prefixed by the names
of the nodes.
* If
TYPE:
|
transform_context |
Any context to give to
TYPE:
|
params |
The params to match any requests when configuring this node. These will match against any ParamRequests in the config and will be used to fill in any missing values. |
RETURNS | DESCRIPTION |
---|---|
Self
|
The configured node |
Source code in src/amltk/pipeline/components.py
625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 |
|
copy
#
display
#
display(*, full: bool = False) -> RenderableType
Display this node.
PARAMETER | DESCRIPTION |
---|---|
full |
Whether to display the full node or just a summary
TYPE:
|
Source code in src/amltk/pipeline/node.py
factorize
#
factorize(
*,
min_depth: int = 0,
max_depth: int | None = None,
current_depth: int = 0,
factor_by: Callable[[Node], bool] | None = None,
assign_child: Callable[[Node, Node], Node] | None = None
) -> Iterator[Self]
Please see factorize()
.
Source code in src/amltk/pipeline/node.py
fidelity_space
#
Get the fidelities for this node and any connected nodes.
find
#
Find a node in that's nested deeper from this node.
PARAMETER | DESCRIPTION |
---|---|
key |
The key to search for or a function that returns True if the node is the desired node |
default |
The value to return if the node is not found. Defaults to None
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Node | T | None
|
The node if found, otherwise the default value. Defaults to None |
Source code in src/amltk/pipeline/node.py
iter
#
Iterate the the nodes, including this node.
YIELDS | DESCRIPTION |
---|---|
Node
|
The nodes connected to this node |
linearized_fidelity
#
Get the liniearized fidelities for this node and any connected nodes.
PARAMETER | DESCRIPTION |
---|---|
value |
The value to linearize. Must be between [0, 1]
TYPE:
|
Return
dictionary from key to it's linearized fidelity.
Source code in src/amltk/pipeline/node.py
mutate
#
mutate(**kwargs: Any) -> Self
Mutate the node with the given keyword arguments.
PARAMETER | DESCRIPTION |
---|---|
**kwargs |
The keyword arguments to mutate
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
Self The mutated node |
Source code in src/amltk/pipeline/node.py
path_to
#
Find a path to the given node.
PARAMETER | DESCRIPTION |
---|---|
key |
The key to search for or a function that returns True if the node is the desired node |
RETURNS | DESCRIPTION |
---|---|
list[Node] | None
|
The path to the node if found, else None |
Source code in src/amltk/pipeline/node.py
search_space
#
search_space(
parser: (
Callable[Concatenate[Node, P], ParserOutput]
| Literal["configspace", "optuna"]
),
*parser_args: args,
**parser_kwargs: kwargs
) -> ParserOutput | ConfigurationSpace | OptunaSearchSpace
Get the search space for this node.
PARAMETER | DESCRIPTION |
---|---|
parser |
The parser to use. This can be a function that takes in the node and returns the search space or a string that is one of:
TYPE:
|
parser_args |
The positional arguments to pass to the parser
TYPE:
|
parser_kwargs |
The keyword arguments to pass to the parser
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ParserOutput | ConfigurationSpace | OptunaSearchSpace
|
The search space |
Source code in src/amltk/pipeline/node.py
walk
#
Walk the nodes in this chain.
PARAMETER | DESCRIPTION |
---|---|
path |
The current path to this node |
YIELDS | DESCRIPTION |
---|---|
list[Node]
|
The parents of the node and the node itself |
Source code in src/amltk/pipeline/node.py
Component
dataclass
#
Component(
item: Callable[..., Item],
*,
name: str | None = None,
config: Config | None = None,
space: Space | None = None,
fidelities: Mapping[str, Any] | None = None,
config_transform: (
Callable[[Config, Any], Config] | None
) = None,
meta: Mapping[str, Any] | None = None
)
A Component
of the pipeline with
a possible item and no children.
This is the basic building block of most pipelines, it accepts
as it's item=
some function that will be
called with build_item()
to
build that one part of the pipeline.
When build_item()
is called, whatever
the config of the component is at that time, will be used to construct the item.
A common pattern is to use a Component
to
wrap a constructor, specifying the space=
and config=
to be used when building the
item.
from amltk.pipeline import Component
from sklearn.ensemble import RandomForestClassifier
rf = Component(
RandomForestClassifier,
config={"max_depth": 3},
space={"n_estimators": (10, 100)}
)
config = {"n_estimators": 50} # Sample from some space or something
configured_rf = rf.configure(config)
estimator = configured_rf.build_item()
╭─ Component(RandomForestClassifier) ──────╮
│ item class RandomForestClassifier(...) │
│ config {'max_depth': 3} │
│ space {'n_estimators': (10, 100)} │
╰──────────────────────────────────────────╯
RandomForestClassifier(max_depth=3, n_estimators=50)In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
RandomForestClassifier(max_depth=3, n_estimators=50)
See Also
PARAMETER | DESCRIPTION |
---|---|
item |
The item attached to this node. |
name |
The name of the node. If not specified, the name will be generated from the item.
TYPE:
|
config |
The configuration for this node.
TYPE:
|
space |
The search space for this node. This will be used when
TYPE:
|
fidelities |
The fidelities for this node. |
config_transform |
A function that transforms the |
meta |
Any meta information about this node. |
Source code in src/amltk/pipeline/components.py
config
class-attribute
instance-attribute
#
The configuration for this node
config_transform
class-attribute
instance-attribute
#
A function that transforms the configuration of this node
fidelities
class-attribute
instance-attribute
#
The fidelities for this node
item
instance-attribute
#
A node which constructs an item in the pipeline.
meta
class-attribute
instance-attribute
#
Any meta information about this node
space
class-attribute
instance-attribute
#
The search space for this node
__getitem__
#
Get the first from .nodes
with key
.
Source code in src/amltk/pipeline/node.py
build
#
build(
builder: (
Callable[Concatenate[Node, P], BuilderOutput]
| Literal["sklearn"]
),
*builder_args: args,
**builder_kwargs: kwargs
) -> BuilderOutput | Pipeline
Build a concrete object out of this node.
PARAMETER | DESCRIPTION |
---|---|
builder |
The builder to use. This can be a function that takes in the node and returns the object or a string that is one of:
TYPE:
|
builder_args |
The positional arguments to pass to the builder
TYPE:
|
builder_kwargs |
The keyword arguments to pass to the builder
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
BuilderOutput | Pipeline
|
The built object |
Source code in src/amltk/pipeline/node.py
build_item
#
Build the item attached to this component.
PARAMETER | DESCRIPTION |
---|---|
**kwargs |
Any additional arguments to pass to the item
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Item
|
Item The built item |
Source code in src/amltk/pipeline/components.py
configure
#
configure(
config: Config,
*,
prefixed_name: bool | None = None,
transform_context: Any | None = None,
params: Mapping[str, Any] | None = None
) -> Self
Configure this node and anything following it with the given config.
PARAMETER | DESCRIPTION |
---|---|
config |
The configuration to apply
TYPE:
|
prefixed_name |
Whether items in the config are prefixed by the names
of the nodes.
* If
TYPE:
|
transform_context |
Any context to give to
TYPE:
|
params |
The params to match any requests when configuring this node. These will match against any ParamRequests in the config and will be used to fill in any missing values. |
RETURNS | DESCRIPTION |
---|---|
Self
|
The configured node |
Source code in src/amltk/pipeline/node.py
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 |
|
copy
#
display
#
display(*, full: bool = False) -> RenderableType
Display this node.
PARAMETER | DESCRIPTION |
---|---|
full |
Whether to display the full node or just a summary
TYPE:
|
Source code in src/amltk/pipeline/node.py
factorize
#
factorize(
*,
min_depth: int = 0,
max_depth: int | None = None,
current_depth: int = 0,
factor_by: Callable[[Node], bool] | None = None,
assign_child: Callable[[Node, Node], Node] | None = None
) -> Iterator[Self]
Please see factorize()
.
Source code in src/amltk/pipeline/node.py
fidelity_space
#
Get the fidelities for this node and any connected nodes.
find
#
Find a node in that's nested deeper from this node.
PARAMETER | DESCRIPTION |
---|---|
key |
The key to search for or a function that returns True if the node is the desired node |
default |
The value to return if the node is not found. Defaults to None
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Node | T | None
|
The node if found, otherwise the default value. Defaults to None |
Source code in src/amltk/pipeline/node.py
iter
#
Iterate the the nodes, including this node.
YIELDS | DESCRIPTION |
---|---|
Node
|
The nodes connected to this node |
linearized_fidelity
#
Get the liniearized fidelities for this node and any connected nodes.
PARAMETER | DESCRIPTION |
---|---|
value |
The value to linearize. Must be between [0, 1]
TYPE:
|
Return
dictionary from key to it's linearized fidelity.
Source code in src/amltk/pipeline/node.py
mutate
#
mutate(**kwargs: Any) -> Self
Mutate the node with the given keyword arguments.
PARAMETER | DESCRIPTION |
---|---|
**kwargs |
The keyword arguments to mutate
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
Self The mutated node |
Source code in src/amltk/pipeline/node.py
path_to
#
Find a path to the given node.
PARAMETER | DESCRIPTION |
---|---|
key |
The key to search for or a function that returns True if the node is the desired node |
RETURNS | DESCRIPTION |
---|---|
list[Node] | None
|
The path to the node if found, else None |
Source code in src/amltk/pipeline/node.py
search_space
#
search_space(
parser: (
Callable[Concatenate[Node, P], ParserOutput]
| Literal["configspace", "optuna"]
),
*parser_args: args,
**parser_kwargs: kwargs
) -> ParserOutput | ConfigurationSpace | OptunaSearchSpace
Get the search space for this node.
PARAMETER | DESCRIPTION |
---|---|
parser |
The parser to use. This can be a function that takes in the node and returns the search space or a string that is one of:
TYPE:
|
parser_args |
The positional arguments to pass to the parser
TYPE:
|
parser_kwargs |
The keyword arguments to pass to the parser
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ParserOutput | ConfigurationSpace | OptunaSearchSpace
|
The search space |
Source code in src/amltk/pipeline/node.py
walk
#
Walk the nodes in this chain.
PARAMETER | DESCRIPTION |
---|---|
path |
The current path to this node |
YIELDS | DESCRIPTION |
---|---|
list[Node]
|
The parents of the node and the node itself |
Source code in src/amltk/pipeline/node.py
Fixed
dataclass
#
Fixed(
item: Item,
*,
name: str | None = None,
config: None = None,
space: None = None,
fidelities: None = None,
config_transform: None = None,
meta: Mapping[str, Any] | None = None
)
A Fixed
part of the pipeline that
represents something that can not be configured and used directly as is.
It consists of an .item
that is fixed,
non-configurable and non-searchable. It also has no children.
This is useful for representing parts of the pipeline that are fixed, for example
if you have a pipeline that is a Sequential
of nodes, but you want to
fix the first component to be a PCA
with n_components=3
, you can use a Fixed
to represent that.
from amltk.pipeline import Component, Fixed, Sequential
from sklearn.ensemble import RandomForestClassifier
from sklearn.decomposition import PCA
rf = Component(RandomForestClassifier, space={"n_estimators": (10, 100)})
pca = Fixed(PCA(n_components=3))
pipeline = Sequential(pca, rf, name="my_pipeline")
╭─ Sequential(my_pipeline) ───────────────────╮
│ ╭─ Fixed(PCA) ─────────────╮ │
│ │ item PCA(n_components=3) │ │
│ ╰──────────────────────────╯ │
│ ↓ │
│ ╭─ Component(RandomForestClassifier) ─────╮ │
│ │ item class RandomForestClassifier(...) │ │
│ │ space {'n_estimators': (10, 100)} │ │
│ ╰─────────────────────────────────────────╯ │
╰─────────────────────────────────────────────╯
See Also
PARAMETER | DESCRIPTION |
---|---|
item |
The item attached to this node. Will be fixed and can not be configured.
TYPE:
|
name |
The name of the node. If not specified, the name will be generated from the item.
TYPE:
|
meta |
Any meta information about this node. |
Source code in src/amltk/pipeline/components.py
config_transform
class-attribute
instance-attribute
#
A fixed node has no config so no transform.
fidelities
class-attribute
instance-attribute
#
A fixed node has no search space.
meta
class-attribute
instance-attribute
#
Any meta information about this node
__getitem__
#
Get the first from .nodes
with key
.
Source code in src/amltk/pipeline/node.py
build
#
build(
builder: (
Callable[Concatenate[Node, P], BuilderOutput]
| Literal["sklearn"]
),
*builder_args: args,
**builder_kwargs: kwargs
) -> BuilderOutput | Pipeline
Build a concrete object out of this node.
PARAMETER | DESCRIPTION |
---|---|
builder |
The builder to use. This can be a function that takes in the node and returns the object or a string that is one of:
TYPE:
|
builder_args |
The positional arguments to pass to the builder
TYPE:
|
builder_kwargs |
The keyword arguments to pass to the builder
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
BuilderOutput | Pipeline
|
The built object |
Source code in src/amltk/pipeline/node.py
configure
#
configure(
config: Config,
*,
prefixed_name: bool | None = None,
transform_context: Any | None = None,
params: Mapping[str, Any] | None = None
) -> Self
Configure this node and anything following it with the given config.
PARAMETER | DESCRIPTION |
---|---|
config |
The configuration to apply
TYPE:
|
prefixed_name |
Whether items in the config are prefixed by the names
of the nodes.
* If
TYPE:
|
transform_context |
Any context to give to
TYPE:
|
params |
The params to match any requests when configuring this node. These will match against any ParamRequests in the config and will be used to fill in any missing values. |
RETURNS | DESCRIPTION |
---|---|
Self
|
The configured node |
Source code in src/amltk/pipeline/node.py
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 |
|
copy
#
display
#
display(*, full: bool = False) -> RenderableType
Display this node.
PARAMETER | DESCRIPTION |
---|---|
full |
Whether to display the full node or just a summary
TYPE:
|
Source code in src/amltk/pipeline/node.py
factorize
#
factorize(
*,
min_depth: int = 0,
max_depth: int | None = None,
current_depth: int = 0,
factor_by: Callable[[Node], bool] | None = None,
assign_child: Callable[[Node, Node], Node] | None = None
) -> Iterator[Self]
Please see factorize()
.
Source code in src/amltk/pipeline/node.py
fidelity_space
#
Get the fidelities for this node and any connected nodes.
find
#
Find a node in that's nested deeper from this node.
PARAMETER | DESCRIPTION |
---|---|
key |
The key to search for or a function that returns True if the node is the desired node |
default |
The value to return if the node is not found. Defaults to None
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Node | T | None
|
The node if found, otherwise the default value. Defaults to None |
Source code in src/amltk/pipeline/node.py
iter
#
Iterate the the nodes, including this node.
YIELDS | DESCRIPTION |
---|---|
Node
|
The nodes connected to this node |
linearized_fidelity
#
Get the liniearized fidelities for this node and any connected nodes.
PARAMETER | DESCRIPTION |
---|---|
value |
The value to linearize. Must be between [0, 1]
TYPE:
|
Return
dictionary from key to it's linearized fidelity.
Source code in src/amltk/pipeline/node.py
mutate
#
mutate(**kwargs: Any) -> Self
Mutate the node with the given keyword arguments.
PARAMETER | DESCRIPTION |
---|---|
**kwargs |
The keyword arguments to mutate
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
Self The mutated node |
Source code in src/amltk/pipeline/node.py
path_to
#
Find a path to the given node.
PARAMETER | DESCRIPTION |
---|---|
key |
The key to search for or a function that returns True if the node is the desired node |
RETURNS | DESCRIPTION |
---|---|
list[Node] | None
|
The path to the node if found, else None |
Source code in src/amltk/pipeline/node.py
search_space
#
search_space(
parser: (
Callable[Concatenate[Node, P], ParserOutput]
| Literal["configspace", "optuna"]
),
*parser_args: args,
**parser_kwargs: kwargs
) -> ParserOutput | ConfigurationSpace | OptunaSearchSpace
Get the search space for this node.
PARAMETER | DESCRIPTION |
---|---|
parser |
The parser to use. This can be a function that takes in the node and returns the search space or a string that is one of:
TYPE:
|
parser_args |
The positional arguments to pass to the parser
TYPE:
|
parser_kwargs |
The keyword arguments to pass to the parser
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ParserOutput | ConfigurationSpace | OptunaSearchSpace
|
The search space |
Source code in src/amltk/pipeline/node.py
walk
#
Walk the nodes in this chain.
PARAMETER | DESCRIPTION |
---|---|
path |
The current path to this node |
YIELDS | DESCRIPTION |
---|---|
list[Node]
|
The parents of the node and the node itself |
Source code in src/amltk/pipeline/node.py
Join
dataclass
#
Join(
*nodes: Node | NodeLike,
name: str | None = None,
item: Item | Callable[[Item], Item] | None = None,
config: Config | None = None,
space: Space | None = None,
fidelities: Mapping[str, Any] | None = None,
config_transform: (
Callable[[Config, Any], Config] | None
) = None,
meta: Mapping[str, Any] | None = None
)
Join
together different parts of the pipeline.
This indicates the different children in
.nodes
should act in tandem with one
another, for example, concatenating the outputs of the various members of the
Join
.
from amltk.pipeline import Join, Component
from sklearn.decomposition import PCA
from sklearn.feature_selection import SelectKBest
pca = Component(PCA, space={"n_components": (1, 3)})
kbest = Component(SelectKBest, space={"k": (1, 3)})
join = Join(pca, kbest, name="my_feature_union")
╭─ Join(my_feature_union) ────────────────────────────────────────────╮
│ ╭─ Component(PCA) ───────────────╮ ╭─ Component(SelectKBest) ─────╮ │
│ │ item class PCA(...) │ │ item class SelectKBest(...) │ │
│ │ space {'n_components': (1, 3)} │ │ space {'k': (1, 3)} │ │
│ ╰────────────────────────────────╯ ╰──────────────────────────────╯ │
╰─────────────────────────────────────────────────────────────────────╯
See Also
PARAMETER | DESCRIPTION |
---|---|
nodes |
The nodes that should be joined together in parallel.
TYPE:
|
item |
The item attached to this node (if any). |
name |
The name of the node. If not specified, the name will be randomly generated.
TYPE:
|
config |
The configuration for this node.
TYPE:
|
space |
The search space for this node. This will be used when
TYPE:
|
fidelities |
The fidelities for this node. |
config_transform |
A function that transforms the |
meta |
Any meta information about this node. |
Source code in src/amltk/pipeline/components.py
config
class-attribute
instance-attribute
#
The configuration for this node
config_transform
class-attribute
instance-attribute
#
A function that transforms the configuration of this node
fidelities
class-attribute
instance-attribute
#
The fidelities for this node
item
class-attribute
instance-attribute
#
The item attached to this node
meta
class-attribute
instance-attribute
#
Any meta information about this node
nodes
instance-attribute
#
The nodes that should be joined together in parallel.
space
class-attribute
instance-attribute
#
The search space for this node
__getitem__
#
Get the first from .nodes
with key
.
Source code in src/amltk/pipeline/node.py
build
#
build(
builder: (
Callable[Concatenate[Node, P], BuilderOutput]
| Literal["sklearn"]
),
*builder_args: args,
**builder_kwargs: kwargs
) -> BuilderOutput | Pipeline
Build a concrete object out of this node.
PARAMETER | DESCRIPTION |
---|---|
builder |
The builder to use. This can be a function that takes in the node and returns the object or a string that is one of:
TYPE:
|
builder_args |
The positional arguments to pass to the builder
TYPE:
|
builder_kwargs |
The keyword arguments to pass to the builder
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
BuilderOutput | Pipeline
|
The built object |
Source code in src/amltk/pipeline/node.py
configure
#
configure(
config: Config,
*,
prefixed_name: bool | None = None,
transform_context: Any | None = None,
params: Mapping[str, Any] | None = None
) -> Self
Configure this node and anything following it with the given config.
PARAMETER | DESCRIPTION |
---|---|
config |
The configuration to apply
TYPE:
|
prefixed_name |
Whether items in the config are prefixed by the names
of the nodes.
* If
TYPE:
|
transform_context |
Any context to give to
TYPE:
|
params |
The params to match any requests when configuring this node. These will match against any ParamRequests in the config and will be used to fill in any missing values. |
RETURNS | DESCRIPTION |
---|---|
Self
|
The configured node |
Source code in src/amltk/pipeline/node.py
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 |
|
copy
#
display
#
display(*, full: bool = False) -> RenderableType
Display this node.
PARAMETER | DESCRIPTION |
---|---|
full |
Whether to display the full node or just a summary
TYPE:
|
Source code in src/amltk/pipeline/node.py
factorize
#
factorize(
*,
min_depth: int = 0,
max_depth: int | None = None,
current_depth: int = 0,
factor_by: Callable[[Node], bool] | None = None,
assign_child: Callable[[Node, Node], Node] | None = None
) -> Iterator[Self]
Please see factorize()
.
Source code in src/amltk/pipeline/node.py
fidelity_space
#
Get the fidelities for this node and any connected nodes.
find
#
Find a node in that's nested deeper from this node.
PARAMETER | DESCRIPTION |
---|---|
key |
The key to search for or a function that returns True if the node is the desired node |
default |
The value to return if the node is not found. Defaults to None
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Node | T | None
|
The node if found, otherwise the default value. Defaults to None |
Source code in src/amltk/pipeline/node.py
iter
#
Iterate the the nodes, including this node.
YIELDS | DESCRIPTION |
---|---|
Node
|
The nodes connected to this node |
linearized_fidelity
#
Get the liniearized fidelities for this node and any connected nodes.
PARAMETER | DESCRIPTION |
---|---|
value |
The value to linearize. Must be between [0, 1]
TYPE:
|
Return
dictionary from key to it's linearized fidelity.
Source code in src/amltk/pipeline/node.py
mutate
#
mutate(**kwargs: Any) -> Self
Mutate the node with the given keyword arguments.
PARAMETER | DESCRIPTION |
---|---|
**kwargs |
The keyword arguments to mutate
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
Self The mutated node |
Source code in src/amltk/pipeline/node.py
path_to
#
Find a path to the given node.
PARAMETER | DESCRIPTION |
---|---|
key |
The key to search for or a function that returns True if the node is the desired node |
RETURNS | DESCRIPTION |
---|---|
list[Node] | None
|
The path to the node if found, else None |
Source code in src/amltk/pipeline/node.py
search_space
#
search_space(
parser: (
Callable[Concatenate[Node, P], ParserOutput]
| Literal["configspace", "optuna"]
),
*parser_args: args,
**parser_kwargs: kwargs
) -> ParserOutput | ConfigurationSpace | OptunaSearchSpace
Get the search space for this node.
PARAMETER | DESCRIPTION |
---|---|
parser |
The parser to use. This can be a function that takes in the node and returns the search space or a string that is one of:
TYPE:
|
parser_args |
The positional arguments to pass to the parser
TYPE:
|
parser_kwargs |
The keyword arguments to pass to the parser
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ParserOutput | ConfigurationSpace | OptunaSearchSpace
|
The search space |
Source code in src/amltk/pipeline/node.py
walk
#
Walk the nodes in this chain.
PARAMETER | DESCRIPTION |
---|---|
path |
The current path to this node |
YIELDS | DESCRIPTION |
---|---|
list[Node]
|
The parents of the node and the node itself |
Source code in src/amltk/pipeline/node.py
Searchable
dataclass
#
Searchable(
space: Space | None = None,
*,
name: str | None = None,
config: Config | None = None,
fidelities: Mapping[str, Any] | None = None,
config_transform: (
Callable[[Config, Any], Config] | None
) = None,
meta: Mapping[str, Any] | None = None
)
A Searchable
node of the pipeline which just represents a search space, no item attached.
While not usually applicable to pipelines you want to build, this node
is useful for creating a search space, especially if the real pipeline you
want to optimize can not be built directly. For example, if you are optimize
a script, you may wish to use a Searchable
to represent the search space
of that script.
from amltk.pipeline import Searchable
script_space = Searchable({"mode": ["orange", "blue", "red"], "n": (10, 100)})
╭─ Searchable(Searchable-JMC3PIeV) ─────────────────────────╮
│ space {'mode': ['orange', 'blue', 'red'], 'n': (10, 100)} │
╰───────────────────────────────────────────────────────────╯
See Also
PARAMETER | DESCRIPTION |
---|---|
space |
The search space for this node. This will be used when
TYPE:
|
name |
The name of the node. If not specified, a random one will be generated.
TYPE:
|
config |
The configuration for this node. Useful for setting some default values.
TYPE:
|
fidelities |
The fidelities for this node. |
config_transform |
A function that transforms the |
meta |
Any meta information about this node. |
Source code in src/amltk/pipeline/components.py
config
class-attribute
instance-attribute
#
The configuration for this node
config_transform
class-attribute
instance-attribute
#
A function that transforms the configuration of this node
fidelities
class-attribute
instance-attribute
#
The fidelities for this node
meta
class-attribute
instance-attribute
#
Any meta information about this node
space
class-attribute
instance-attribute
#
The search space for this node
__getitem__
#
Get the first from .nodes
with key
.
Source code in src/amltk/pipeline/node.py
build
#
build(
builder: (
Callable[Concatenate[Node, P], BuilderOutput]
| Literal["sklearn"]
),
*builder_args: args,
**builder_kwargs: kwargs
) -> BuilderOutput | Pipeline
Build a concrete object out of this node.
PARAMETER | DESCRIPTION |
---|---|
builder |
The builder to use. This can be a function that takes in the node and returns the object or a string that is one of:
TYPE:
|
builder_args |
The positional arguments to pass to the builder
TYPE:
|
builder_kwargs |
The keyword arguments to pass to the builder
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
BuilderOutput | Pipeline
|
The built object |
Source code in src/amltk/pipeline/node.py
configure
#
configure(
config: Config,
*,
prefixed_name: bool | None = None,
transform_context: Any | None = None,
params: Mapping[str, Any] | None = None
) -> Self
Configure this node and anything following it with the given config.
PARAMETER | DESCRIPTION |
---|---|
config |
The configuration to apply
TYPE:
|
prefixed_name |
Whether items in the config are prefixed by the names
of the nodes.
* If
TYPE:
|
transform_context |
Any context to give to
TYPE:
|
params |
The params to match any requests when configuring this node. These will match against any ParamRequests in the config and will be used to fill in any missing values. |
RETURNS | DESCRIPTION |
---|---|
Self
|
The configured node |
Source code in src/amltk/pipeline/node.py
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 |
|
copy
#
display
#
display(*, full: bool = False) -> RenderableType
Display this node.
PARAMETER | DESCRIPTION |
---|---|
full |
Whether to display the full node or just a summary
TYPE:
|
Source code in src/amltk/pipeline/node.py
factorize
#
factorize(
*,
min_depth: int = 0,
max_depth: int | None = None,
current_depth: int = 0,
factor_by: Callable[[Node], bool] | None = None,
assign_child: Callable[[Node, Node], Node] | None = None
) -> Iterator[Self]
Please see factorize()
.
Source code in src/amltk/pipeline/node.py
fidelity_space
#
Get the fidelities for this node and any connected nodes.
find
#
Find a node in that's nested deeper from this node.
PARAMETER | DESCRIPTION |
---|---|
key |
The key to search for or a function that returns True if the node is the desired node |
default |
The value to return if the node is not found. Defaults to None
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Node | T | None
|
The node if found, otherwise the default value. Defaults to None |
Source code in src/amltk/pipeline/node.py
iter
#
Iterate the the nodes, including this node.
YIELDS | DESCRIPTION |
---|---|
Node
|
The nodes connected to this node |
linearized_fidelity
#
Get the liniearized fidelities for this node and any connected nodes.
PARAMETER | DESCRIPTION |
---|---|
value |
The value to linearize. Must be between [0, 1]
TYPE:
|
Return
dictionary from key to it's linearized fidelity.
Source code in src/amltk/pipeline/node.py
mutate
#
mutate(**kwargs: Any) -> Self
Mutate the node with the given keyword arguments.
PARAMETER | DESCRIPTION |
---|---|
**kwargs |
The keyword arguments to mutate
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
Self The mutated node |
Source code in src/amltk/pipeline/node.py
path_to
#
Find a path to the given node.
PARAMETER | DESCRIPTION |
---|---|
key |
The key to search for or a function that returns True if the node is the desired node |
RETURNS | DESCRIPTION |
---|---|
list[Node] | None
|
The path to the node if found, else None |
Source code in src/amltk/pipeline/node.py
search_space
#
search_space(
parser: (
Callable[Concatenate[Node, P], ParserOutput]
| Literal["configspace", "optuna"]
),
*parser_args: args,
**parser_kwargs: kwargs
) -> ParserOutput | ConfigurationSpace | OptunaSearchSpace
Get the search space for this node.
PARAMETER | DESCRIPTION |
---|---|
parser |
The parser to use. This can be a function that takes in the node and returns the search space or a string that is one of:
TYPE:
|
parser_args |
The positional arguments to pass to the parser
TYPE:
|
parser_kwargs |
The keyword arguments to pass to the parser
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ParserOutput | ConfigurationSpace | OptunaSearchSpace
|
The search space |
Source code in src/amltk/pipeline/node.py
walk
#
Walk the nodes in this chain.
PARAMETER | DESCRIPTION |
---|---|
path |
The current path to this node |
YIELDS | DESCRIPTION |
---|---|
list[Node]
|
The parents of the node and the node itself |
Source code in src/amltk/pipeline/node.py
Sequential
dataclass
#
Sequential(
*nodes: Node | NodeLike,
name: str | None = None,
item: Item | Callable[[Item], Item] | None = None,
config: Config | None = None,
space: Space | None = None,
fidelities: Mapping[str, Any] | None = None,
config_transform: (
Callable[[Config, Any], Config] | None
) = None,
meta: Mapping[str, Any] | None = None
)
A Sequential
set of operations in a pipeline.
This indicates the different children in
.nodes
should act one after
another, feeding the output of one into the next.
from amltk.pipeline import Component, Sequential
from sklearn.decomposition import PCA
from sklearn.ensemble import RandomForestClassifier
pipeline = Sequential(
PCA(n_components=3),
Component(RandomForestClassifier, space={"n_estimators": (10, 100)}),
name="my_pipeline"
)
╭─ Sequential(my_pipeline) ───────────────────╮
│ ╭─ Fixed(PCA) ─────────────╮ │
│ │ item PCA(n_components=3) │ │
│ ╰──────────────────────────╯ │
│ ↓ │
│ ╭─ Component(RandomForestClassifier) ─────╮ │
│ │ item class RandomForestClassifier(...) │ │
│ │ space {'n_estimators': (10, 100)} │ │
│ ╰─────────────────────────────────────────╯ │
╰─────────────────────────────────────────────╯
See Also
PARAMETER | DESCRIPTION |
---|---|
nodes |
The nodes that this node leads to. In the case of a
TYPE:
|
item |
The item attached to this node (if any). |
name |
The name of the node. If not specified, the name will be randomly generated.
TYPE:
|
config |
The configuration for this node.
TYPE:
|
space |
The search space for this node. This will be used when
TYPE:
|
fidelities |
The fidelities for this node. |
config_transform |
A function that transforms the |
meta |
Any meta information about this node. |
Source code in src/amltk/pipeline/components.py
config
class-attribute
instance-attribute
#
The configuration for this node
config_transform
class-attribute
instance-attribute
#
A function that transforms the configuration of this node
fidelities
class-attribute
instance-attribute
#
The fidelities for this node
item
class-attribute
instance-attribute
#
The item attached to this node
meta
class-attribute
instance-attribute
#
Any meta information about this node
space
class-attribute
instance-attribute
#
The search space for this node
__getitem__
#
Get the first from .nodes
with key
.
Source code in src/amltk/pipeline/node.py
build
#
build(
builder: (
Callable[Concatenate[Node, P], BuilderOutput]
| Literal["sklearn"]
),
*builder_args: args,
**builder_kwargs: kwargs
) -> BuilderOutput | Pipeline
Build a concrete object out of this node.
PARAMETER | DESCRIPTION |
---|---|
builder |
The builder to use. This can be a function that takes in the node and returns the object or a string that is one of:
TYPE:
|
builder_args |
The positional arguments to pass to the builder
TYPE:
|
builder_kwargs |
The keyword arguments to pass to the builder
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
BuilderOutput | Pipeline
|
The built object |
Source code in src/amltk/pipeline/node.py
configure
#
configure(
config: Config,
*,
prefixed_name: bool | None = None,
transform_context: Any | None = None,
params: Mapping[str, Any] | None = None
) -> Self
Configure this node and anything following it with the given config.
PARAMETER | DESCRIPTION |
---|---|
config |
The configuration to apply
TYPE:
|
prefixed_name |
Whether items in the config are prefixed by the names
of the nodes.
* If
TYPE:
|
transform_context |
Any context to give to
TYPE:
|
params |
The params to match any requests when configuring this node. These will match against any ParamRequests in the config and will be used to fill in any missing values. |
RETURNS | DESCRIPTION |
---|---|
Self
|
The configured node |
Source code in src/amltk/pipeline/node.py
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 |
|
copy
#
display
#
display(*, full: bool = False) -> RenderableType
Display this node.
PARAMETER | DESCRIPTION |
---|---|
full |
Whether to display the full node or just a summary
TYPE:
|
Source code in src/amltk/pipeline/node.py
factorize
#
factorize(
*,
min_depth: int = 0,
max_depth: int | None = None,
current_depth: int = 0,
factor_by: Callable[[Node], bool] | None = None,
assign_child: Callable[[Node, Node], Node] | None = None
) -> Iterator[Self]
Please see factorize()
.
Source code in src/amltk/pipeline/node.py
fidelity_space
#
Get the fidelities for this node and any connected nodes.
find
#
Find a node in that's nested deeper from this node.
PARAMETER | DESCRIPTION |
---|---|
key |
The key to search for or a function that returns True if the node is the desired node |
default |
The value to return if the node is not found. Defaults to None
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Node | T | None
|
The node if found, otherwise the default value. Defaults to None |
Source code in src/amltk/pipeline/node.py
iter
#
Iterate the the nodes, including this node.
YIELDS | DESCRIPTION |
---|---|
Node
|
The nodes connected to this node |
linearized_fidelity
#
Get the liniearized fidelities for this node and any connected nodes.
PARAMETER | DESCRIPTION |
---|---|
value |
The value to linearize. Must be between [0, 1]
TYPE:
|
Return
dictionary from key to it's linearized fidelity.
Source code in src/amltk/pipeline/node.py
mutate
#
mutate(**kwargs: Any) -> Self
Mutate the node with the given keyword arguments.
PARAMETER | DESCRIPTION |
---|---|
**kwargs |
The keyword arguments to mutate
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
Self The mutated node |
Source code in src/amltk/pipeline/node.py
path_to
#
Find a path to the given node.
PARAMETER | DESCRIPTION |
---|---|
key |
The key to search for or a function that returns True if the node is the desired node |
RETURNS | DESCRIPTION |
---|---|
list[Node] | None
|
The path to the node if found, else None |
Source code in src/amltk/pipeline/node.py
search_space
#
search_space(
parser: (
Callable[Concatenate[Node, P], ParserOutput]
| Literal["configspace", "optuna"]
),
*parser_args: args,
**parser_kwargs: kwargs
) -> ParserOutput | ConfigurationSpace | OptunaSearchSpace
Get the search space for this node.
PARAMETER | DESCRIPTION |
---|---|
parser |
The parser to use. This can be a function that takes in the node and returns the search space or a string that is one of:
TYPE:
|
parser_args |
The positional arguments to pass to the parser
TYPE:
|
parser_kwargs |
The keyword arguments to pass to the parser
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ParserOutput | ConfigurationSpace | OptunaSearchSpace
|
The search space |
Source code in src/amltk/pipeline/node.py
walk
#
Walk the nodes in this chain.
PARAMETER | DESCRIPTION |
---|---|
path |
The current path to this node |
YIELDS | DESCRIPTION |
---|---|
list[Node]
|
The parents of the node and the node itself |
Source code in src/amltk/pipeline/components.py
Split
dataclass
#
Split(
*nodes: Node | NodeLike | dict[str, Node | NodeLike],
name: str | None = None,
item: Item | Callable[[Item], Item] | None = None,
config: Config | None = None,
space: Space | None = None,
fidelities: Mapping[str, Any] | None = None,
config_transform: (
Callable[[Config, Any], Config] | None
) = None,
meta: Mapping[str, Any] | None = None
)
A Split
of data in a pipeline.
This indicates the different children in
.nodes
should
act in parallel but on different subsets of data.
from amltk.pipeline import Component, Split
from sklearn.impute import SimpleImputer
from sklearn.preprocessing import OneHotEncoder
from sklearn.compose import make_column_selector
categorical_pipeline = [
SimpleImputer(strategy="constant", fill_value="missing"),
OneHotEncoder(drop="first"),
]
numerical_pipeline = Component(SimpleImputer, space={"strategy": ["mean", "median"]})
preprocessor = Split(
{
"categories": categorical_pipeline,
"numerical": numerical_pipeline,
},
config={
"categories": make_column_selector(dtype_include="category"),
"numerical": make_column_selector(dtype_exclude="category"),
},
name="my_split"
)
╭─ Split(my_split) ────────────────────────────────────────────────────────────╮
│ config { │
│ 'categories': │
│ <sklearn.compose._column_transformer.make_column_selector object at │
│ 0x7f95fa3631f0>, │
│ 'numerical': │
│ <sklearn.compose._column_transformer.make_column_selector object at │
│ 0x7f95fa360730> │
│ } │
│ ╭─ Sequential(categories) ──────────╮ ╭─ Sequential(numerical) ────────────╮ │
│ │ ╭─ Fixed(SimpleImputer) ────────╮ │ │ ╭─ Component(SimpleImputer) ─────╮ │ │
│ │ │ item SimpleImputer(fill_valu… │ │ │ │ item class SimpleImputer(...) │ │ │
│ │ │ strategy='constant') │ │ │ │ space { │ │ │
│ │ ╰───────────────────────────────╯ │ │ │ 'strategy': [ │ │ │
│ │ ↓ │ │ │ 'mean', │ │ │
│ │ ╭─ Fixed(OneHotEncoder) ────────╮ │ │ │ 'median' │ │ │
│ │ │ item OneHotEncoder(drop='fir… │ │ │ │ ] │ │ │
│ │ ╰───────────────────────────────╯ │ │ │ } │ │ │
│ ╰───────────────────────────────────╯ │ ╰────────────────────────────────╯ │ │
│ ╰────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────╯
See Also
PARAMETER | DESCRIPTION |
---|---|
nodes |
The nodes that this node leads to. You may also provide a dictionary where the keys are the names of the nodes and the values are the nodes or list of nodes themselves.
TYPE:
|
item |
The item attached to this node. The object created by |
name |
The name of the node. If not specified, the name will be generated from the item.
TYPE:
|
config |
The configuration for this split.
TYPE:
|
space |
The search space for this node. This will be used when
TYPE:
|
fidelities |
The fidelities for this node. |
config_transform |
A function that transforms the |
meta |
Any meta information about this node. |
Source code in src/amltk/pipeline/components.py
config
class-attribute
instance-attribute
#
The configuration for this node
config_transform
class-attribute
instance-attribute
#
A function that transforms the configuration of this node
fidelities
class-attribute
instance-attribute
#
The fidelities for this node
item
class-attribute
instance-attribute
#
The item attached to this node
meta
class-attribute
instance-attribute
#
Any meta information about this node
nodes
class-attribute
instance-attribute
#
The nodes that this node leads to.
space
class-attribute
instance-attribute
#
The search space for this node
__getitem__
#
Get the first from .nodes
with key
.
Source code in src/amltk/pipeline/node.py
build
#
build(
builder: (
Callable[Concatenate[Node, P], BuilderOutput]
| Literal["sklearn"]
),
*builder_args: args,
**builder_kwargs: kwargs
) -> BuilderOutput | Pipeline
Build a concrete object out of this node.
PARAMETER | DESCRIPTION |
---|---|
builder |
The builder to use. This can be a function that takes in the node and returns the object or a string that is one of:
TYPE:
|
builder_args |
The positional arguments to pass to the builder
TYPE:
|
builder_kwargs |
The keyword arguments to pass to the builder
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
BuilderOutput | Pipeline
|
The built object |
Source code in src/amltk/pipeline/node.py
configure
#
configure(
config: Config,
*,
prefixed_name: bool | None = None,
transform_context: Any | None = None,
params: Mapping[str, Any] | None = None
) -> Self
Configure this node and anything following it with the given config.
PARAMETER | DESCRIPTION |
---|---|
config |
The configuration to apply
TYPE:
|
prefixed_name |
Whether items in the config are prefixed by the names
of the nodes.
* If
TYPE:
|
transform_context |
Any context to give to
TYPE:
|
params |
The params to match any requests when configuring this node. These will match against any ParamRequests in the config and will be used to fill in any missing values. |
RETURNS | DESCRIPTION |
---|---|
Self
|
The configured node |
Source code in src/amltk/pipeline/node.py
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 |
|
copy
#
display
#
display(*, full: bool = False) -> RenderableType
Display this node.
PARAMETER | DESCRIPTION |
---|---|
full |
Whether to display the full node or just a summary
TYPE:
|
Source code in src/amltk/pipeline/node.py
factorize
#
factorize(
*,
min_depth: int = 0,
max_depth: int | None = None,
current_depth: int = 0,
factor_by: Callable[[Node], bool] | None = None,
assign_child: Callable[[Node, Node], Node] | None = None
) -> Iterator[Self]
Please see factorize()
.
Source code in src/amltk/pipeline/node.py
fidelity_space
#
Get the fidelities for this node and any connected nodes.
find
#
Find a node in that's nested deeper from this node.
PARAMETER | DESCRIPTION |
---|---|
key |
The key to search for or a function that returns True if the node is the desired node |
default |
The value to return if the node is not found. Defaults to None
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Node | T | None
|
The node if found, otherwise the default value. Defaults to None |
Source code in src/amltk/pipeline/node.py
iter
#
Iterate the the nodes, including this node.
YIELDS | DESCRIPTION |
---|---|
Node
|
The nodes connected to this node |
linearized_fidelity
#
Get the liniearized fidelities for this node and any connected nodes.
PARAMETER | DESCRIPTION |
---|---|
value |
The value to linearize. Must be between [0, 1]
TYPE:
|
Return
dictionary from key to it's linearized fidelity.
Source code in src/amltk/pipeline/node.py
mutate
#
mutate(**kwargs: Any) -> Self
Mutate the node with the given keyword arguments.
PARAMETER | DESCRIPTION |
---|---|
**kwargs |
The keyword arguments to mutate
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
Self The mutated node |
Source code in src/amltk/pipeline/node.py
path_to
#
Find a path to the given node.
PARAMETER | DESCRIPTION |
---|---|
key |
The key to search for or a function that returns True if the node is the desired node |
RETURNS | DESCRIPTION |
---|---|
list[Node] | None
|
The path to the node if found, else None |
Source code in src/amltk/pipeline/node.py
search_space
#
search_space(
parser: (
Callable[Concatenate[Node, P], ParserOutput]
| Literal["configspace", "optuna"]
),
*parser_args: args,
**parser_kwargs: kwargs
) -> ParserOutput | ConfigurationSpace | OptunaSearchSpace
Get the search space for this node.
PARAMETER | DESCRIPTION |
---|---|
parser |
The parser to use. This can be a function that takes in the node and returns the search space or a string that is one of:
TYPE:
|
parser_args |
The positional arguments to pass to the parser
TYPE:
|
parser_kwargs |
The keyword arguments to pass to the parser
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ParserOutput | ConfigurationSpace | OptunaSearchSpace
|
The search space |
Source code in src/amltk/pipeline/node.py
walk
#
Walk the nodes in this chain.
PARAMETER | DESCRIPTION |
---|---|
path |
The current path to this node |
YIELDS | DESCRIPTION |
---|---|
list[Node]
|
The parents of the node and the node itself |
Source code in src/amltk/pipeline/node.py
as_node
#
as_node(
thing: Node | NodeLike[Item], name: str | None = None
) -> Node | Choice | Join | Sequential | Fixed[Item]
Convert a node, pipeline, set or tuple into a component, copying anything in the process and removing all linking to other nodes.
PARAMETER | DESCRIPTION |
---|---|
thing |
The thing to convert |
name |
The name of the node. If it already a node, it will be renamed to that one.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Node | Choice | Join | Sequential | Fixed[Item]
|
The component |