跳转至

ML Reference

Machine learning, model registry, and feature selection utilities.

Back to API Reference

ML public facade.

CausalSelector dataclass

Select candidate causal features from a single dataset.

fit

fit(data: DataFrame) -> CausalSelector

Fit selector scores and selected feature names.

get_params

get_params() -> dict[str, Any]

Expose definition metadata without fitting or graph discovery.

to_dict

to_dict() -> dict[str, Any]

Return completed selection evidence, retaining graph uncertainty.

plot

plot(filename: str | None = None) -> str

Render the fitted causal graph as a PNG image.

Requires method='pc' or method='fci' and must be called after :meth:fit. Uses causallearn.utils.GraphUtils.to_pydot to convert the discovered graph structure into a PNG file, mirroring the 1.x Graph.fit_causal() API.

to_mermaid

to_mermaid() -> str

Render actual discovery endpoints; adjacency is not causal-effect proof.

to_section

to_section(title: str = 'Causal Diagram') -> dict[str, str]

Return a report section dictionary containing the causal diagram.

select

select(data: DataFrame) -> list[str]

Return selected feature names after fitting.

transform

transform(data: DataFrame) -> pd.DataFrame

Return a DataFrame containing only selected features.

fit_transform

fit_transform(data: DataFrame) -> pd.DataFrame

Fit selector and return selected feature columns.

ModelLoader

Protocol for user-defined model registries.

load

load(reference: str) -> Any

Load a model object from a user-facing reference.

ModelRegistry dataclass

Small MLflow Model Registry facade.

load

load(reference: str) -> Any

Load a pyfunc model from MLflow Model Registry.

load_bundle

load_bundle(
    path: str | Path, *, trusted: bool = False
) -> dict[str, Any]

Check integrity/versions, then explicitly load trusted executable state.

Hash integrity is not authenticity. Only set trusted=True for a producer and code you trust. This does not register, publish, deploy or fit anything.

predict_bundle

predict_bundle(bundle: dict[str, Any], bars)

Apply the same fitted local bundle to a research or strategy window.

load_bundle(..., trusted=True) remains the explicit executable-state trust boundary. This function never loads, fits, fetches or caches scores. An empty valid window returns no scores, never a previous prediction.

save_bundle

save_bundle(
    bundle: dict[str, Any],
    path: str | Path,
    *,
    code_paths: dict[str, str | Path] | None = None,
    dependencies: tuple[str, ...] = (),
) -> dict[str, Any]

Write fitted components plus schema/label/version manifest locally.

The directory must be empty. Definitions must be serializable and their Python modules available at load time; no code/data/secret discovery occurs.

model_uri

model_uri(reference: str) -> str

Return a MLflow models:/ URI from a user-facing model reference.