Skip to main content

agentic-ml

Docs

An agentic framework that tackles a data scientist's machine learning problems with LLM agents. Instead of a fixed AutoML search space, an agent writes and runs real training code in an experimentation loop, keeps an auditable record of every trial, and exports a lightweight, production-ready model.

Status: early prototype. The first (and currently only) supported task is tabular regression. Agent-written trials may only use numpy, pandas and scikit-learn as ML dependencies — this keeps the evaluation environment predictable, but also means no deep learning / gradient-boosting libraries (e.g. XGBoost, LightGBM, PyTorch) are available yet. The sandbox that runs agent-written code is intentionally naive: see Security note for exactly what it does and does not protect against.

Table of Contents

Installation

uv add jcaste05-agentic-ml              # base install: the light production model only
uv add "jcaste05-agentic-ml[research]"  # adds Strands, the agent runtime that drives research

jcaste05-agentic-ml[research] installs strands-agents itself but not a specific LLM provider. Strands ships each provider as its own extra, so add whichever one matches your setup, e.g.:

uv add "strands-agents[gemini]"   # Google Gemini
uv add "strands-agents[openai]"   # OpenAI-compatible endpoints

See the Strands Agents docs for the full list of supported model providers and how to configure each one.

If you only need AgenticModel to serve an already-exported model in production, skip [research] entirely: it depends solely on numpy, pandas, scikit-learn and joblib.

How it works

The full workflow is demonstrated end-to-end in docs/quick_example.ipynb (tabular regression on the scikit-learn diabetes dataset) — run it for a more detailed, runnable walkthrough than the snippets below.

There are three objects worth knowing about:

  • Researcher (heavy, needs an LLM): a generic orchestrator that runs research(...), driving a Strands agent that proposes, writes and evaluates trials. Each trial is a folder trial_N/ containing the agent-written model.py (+ optional helpers.py). A fixed, task-owned evaluation scheme scores every trial across data partitions and checks a save/load roundtrip. All metrics are appended to a leaderboard.csv inside the research directory — that directory is the audit trail.
  • Task (the extension seam): an abstract strategy that encapsulates everything problem-specific — the agent prompt sections, the metrics and their direction, and how data partitions are built. Researcher itself is task-agnostic; it is adapted to a concrete ML problem simply by handing it a Task subclass. Adding a new kind of problem (classification, forecasting, ...) means subclassing Task; nothing else in core or research needs to change.
  • AgenticModel (light, no LLM dependency): the exported production model with fit, predict, save and load. It is bound to the code of a chosen trial (the best one by default).

Tabular regression, the only task implemented so far, is a thin example of this seam: see TabularRegressionTask / TabularRegressionResearcher — a Task subclass plus a Researcher preset that binds it, with no other custom logic.

import pandas as pd
from strands.models.openai import OpenAIModel

from agentic_ml.data import DatasetSchema
from agentic_ml.estimators.regression import TabularRegressionResearcher

data = pd.read_csv("houses.csv")
schema = DatasetSchema(
    variables={
        "area": "House area in square meters",
        "rooms": "Number of rooms",
        "price": "Sale price in euros (target)",
    },
    target="price",
)

llm = OpenAIModel(model_id="gpt-4o", client_args={"api_key": "..."})
researcher = TabularRegressionResearcher(model=llm)
researcher.research(data, schema, metrics=["rmse", "mae", "r2"], iterations=10)

model = researcher.export_model()  # best trial by default
model.fit(data.drop(columns=["price"]), data["price"])
model.save("artifacts/price_model")

Later, in production (no [research] extra required):

from agentic_ml import AgenticModel

model = AgenticModel.load("artifacts/price_model")
predictions = model.predict(new_data)

Public API

Researcher (agentic_ml.research.researcher.Researcher)

The generic research orchestrator; TabularRegressionResearcher etc. are thin presets built on top of it.

  • Constructor: Researcher(task: Task, model: object | None = None)
    • task: the Task strategy driving prompts, metrics and evaluation.
    • model: a Strands model instance (any OpenAI-compatible or provider-specific model), required before calling research(...).
  • Attributes: task, model, agent (the underlying Strands Agent, created on the first research(...) call).
  • context (property) → ResearchContext: the state of the last research run (raises RuntimeError if research(...) hasn't been called yet). Notable fields: workspace, task, x_data, y_data, schema, config, leaderboard, profile_text.
  • research(data, schema, *, metrics=None, partitions=None, n_splits=5, seed=0, tolerance=1e-6, timeout=120.0, iterations=10, ideas=None, research_dir=None, sleep=0.0, new_session=True) -> ResearchContext: drives the experimentation loop.
    • data / schema: the dataset and its DatasetSchema description.
    • metrics / partitions / n_splits / seed / tolerance / timeout: evaluation knobs, defaulting to the task's own scheme.
    • iterations: soft budget of experiment iterations offered to the agent.
    • ideas: natural-language guidance the user wants the agent to try.
    • research_dir: where trials and the leaderboard are stored; defaults to a timestamped directory under ./agentic_ml_runs.
    • sleep: delay between iterations, useful to avoid provider rate limits.
    • new_session: start a fresh agent conversation, or resume the one saved in research_dir (snapshot.json).
  • export_model(trial: str | None = None) -> AgenticModel: exports a trial (the best by primary metric, by default) as a production-ready AgenticModel.

AgenticModel (agentic_ml.core.model.AgenticModel)

  • AgenticModel.from_trial(trial_dir) -> AgenticModel: build an unfitted model bound to a trial's code.
  • AgenticModel.load(path) -> AgenticModel: restore a fitted model previously written by save(...).
  • is_fitted (property): whether fit(...) has been called.
  • fit(X, y) -> AgenticModel, predict(X), save(path): standard fit/predict/persist lifecycle, delegating to the bound trial's Model class.
  • Raises NotFittedError if predict(...) or save(...) is called before fit(...).

Task (agentic_ml.core.task.Task)

Abstract base for new ML problem types. Subclasses implement role_description(), guidance(), default_metrics() and primary_metric(); partitioning (K-Fold by default), evaluation and Strands tool wiring are inherited and generally don't need overriding.

Task presets (agentic_ml.estimators.*)

Each supported task ships a Task subclass plus a matching Researcher preset with no extra API surface. Currently: TabularRegressionTask / TabularRegressionResearcher (agentic_ml.estimators.regression.tabular) for supervised regression on tabular data.

Security note

Research and AgenticModel.load execute Python code produced by the agent (or previously saved by it). Every trial is run out-of-process by a naive sandbox (core/sandbox.py), which only provides:

  • A hard timeout on the subprocess (timeout in research(...)), so a hung trial doesn't stall the whole run.
  • Environment variable filtering: any variable whose name contains KEY, TOKEN, SECRET, PASSWORD, PASSWD or CREDENTIAL is stripped before launching the subprocess, to reduce accidental secret leakage into agent-written code.
  • A prompt-level (not enforced) instruction telling the agent to only use numpy, pandas and scikit-learn.

It does not provide process isolation, filesystem or network sandboxing, or CPU/memory limits — the subprocess runs as the same user, with the same filesystem and network access as your own process. Treat agent-written code and saved artifacts with the same trust level as a pickle: only run/load artifacts you produced or trust.

Development

uv sync --all-extras
uv run ruff check .
uv run ruff format . --check --diff
uv run pytest

To preview the documentation locally:

uv run mkdocs serve

License

Apache-2.0.

Metadata

Release files for jcaste05-agentic-ml 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jcaste05-agentic-ml 0.1.0
File Size Uploaded Provenance
jcaste05_agentic_ml-0.1.0.tar.gz 120.5 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for jcaste05-agentic-ml 0.1.0
File Interpreter ABI Platform
jcaste05_agentic_ml-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 159.7 kB

Release files / jcaste05_agentic_ml-0.1.0.tar.gz

Download URL jcaste05_agentic_ml-0.1.0.tar.gz
Size 120.5 kB
Tags Source
SHA-256 checksum
How to use checksums
eeca654759f182c014ef4c6aca39388bb5394470847c14ede3f0b7425921c4cb
BLAKE2b-256 checksum
How to use checksums
9b8046536b38596eb5abc0f0ad1ba386ecf9ba4562f05a19b161ef9b334daab2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 13, 2026.

Transparency log

Release files / jcaste05_agentic_ml-0.1.0-py3-none-any.whl

Download URL jcaste05_agentic_ml-0.1.0-py3-none-any.whl
Size 39.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0d20b377aa70914d943e02cedd489ffecac4a60d86779cdaf4068a5a838ca6bc
BLAKE2b-256 checksum
How to use checksums
e35ba14b94d11425e415dca90e29e3056ce3cd6e9f221b765e06087ec5d5720b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 13, 2026.

Transparency log

Security for jcaste05-agentic-ml 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for jcaste05_agentic_ml-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 13, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page