Skip to main content

Export trained ML models to ML-Dash

Project description

mldash

Export trained ML models from notebooks to ML-Dash.

Install

pip install mldash

Quick Start

import mldash

# One-time login (saved to ~/.config/mldash/credentials)
mldash.login()

# Set active project for this notebook
mldash.init(project="churn-analysis")

# Train your model
from sklearn.ensemble import RandomForestClassifier
model = RandomForestClassifier()
model.fit(X_train, y_train)

# Export — just model + name, everything else is resolved
mldash.export(model=model, name="Churn Predictor")

Authentication

mldash.login() — One-time setup

Run once per machine. You'll be prompted for your ML-Dash URL and API key:

>>> mldash.login()
ML-Dash URL: http://localhost:8000
Get your API key from: http://localhost:8000/developers/keys
API Key: ········
Authenticated with http://localhost:8000
Credentials saved to ~/.config/mldash/credentials

Credentials are stored locally at ~/.config/mldash/credentials (chmod 600) and reused automatically.

You can also pass values directly (useful for CI or scripting):

mldash.login(url="http://localhost:8000", api_key="mlda_xxx")

mldash.logout()

mldash.logout()  # removes stored credentials

mldash.whoami()

mldash.whoami()
# URL:     http://localhost:8000
# API Key: mlda_abcde...
# Project: churn-analysis

Alternative auth methods

These work without calling login():

Environment variables:

export MLDASH_URL=http://localhost:8000
export MLDASH_API_KEY=mlda_your_key_here

Google Colab Secrets:

Add MLDASH_URL and MLDASH_API_KEY to your Colab Secrets (key icon in sidebar).

Project Association

mldash.init() — Set active project

mldash.init(project="churn-analysis")

# All exports now go to "churn-analysis"
mldash.export(model=model1, name="Logistic v1")
mldash.export(model=model2, name="XGBoost v1")

The project is saved to credentials, so it persists across sessions. Override per-export with project_id=:

mldash.export(model=model, name="Experiment", project_id="other-project")

Usage

Export with artifacts

mldash.export(
    model=model,
    name="Sales Predictor",
    scaler=scaler,              # StandardScaler, MinMaxScaler, etc.
    encoder=encoder,            # OneHotEncoder, LabelEncoder, etc.
    label_map={"0": "no", "1": "yes"},
    features={"age": "numeric", "dept": "categorical", "review": "text"},
    target={"churn": "categorical"},
)

Save to local ZIP (offline)

mldash.save(
    model=model,
    name="My Model",
    path="./my_model.zip",
)
# Upload the ZIP manually via the ML-Dash web UI

Auto-detection

The package auto-detects:

  • task_type — classification or regression (from sklearn mixins)
  • framework — sklearn, xgboost, lightgbm, etc. (from module path)
  • hyperparameters — via model.get_params()
  • model_class — e.g., RandomForestClassifier
  • n_features — from model.n_features_in_
  • class_labels — from model.classes_

Typical Notebook Workflow

# Cell 1: Setup (run once)
import mldash
mldash.login()
mldash.init(project="mas-648-final")

# Cell 2-N: Train models...
model = RandomForestClassifier(n_estimators=100)
model.fit(X_train, y_train)

# Cell N+1: Export
mldash.export(model=model, name="RF 100 trees")

Errors

from mldash import MLDashValidationError, MLDashAuthError, MLDashUploadError

try:
    mldash.export(model=model, name="Test")
except MLDashValidationError as e:
    print(f"Invalid input: {e}")
except MLDashAuthError as e:
    print(f"Auth failed: {e}")
except MLDashUploadError as e:
    print(f"Upload failed: {e}")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mldash_sdk-0.1.0.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mldash_sdk-0.1.0-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file mldash_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: mldash_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for mldash_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f7c094b044622bd02c23558e50e7c33b90fc692fb0e8f3b13e20df5294f5f386
MD5 57ab1ceba6fbcfe4128e56d4711b49b9
BLAKE2b-256 683ec8b3437e2a42d9bde848ff5ff56b2362de527d0645a3f57d25c09dd1167a

See more details on using hashes here.

File details

Details for the file mldash_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mldash_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for mldash_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a48b48b7ee07a48e0098e6ae9ab9e30968603c0e679c0e7a4008b8bd0c7921a3
MD5 3b6f94e111839426c30ed97e4c22cac9
BLAKE2b-256 2f487d38123b40c1497faa0b9094469e4a5a5d50a9b16db077bdeed477220f06

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page