Skip to main content

Python SDK for MathExec — call published model endpoints

Project description

mathexec

Python SDK for MathExec — call your published model endpoints from code.

pip install mathexec

Quick start

from mathexec import Model

model = Model.load("your-model-id")
result = model.predict({"age": 25, "income": 50000})
print(result["predictions"])     # [1]
print(result["probabilities"])   # [0.92]

Get an API key

  1. Sign in at mathexec.com
  2. Open Settings → API keys
  3. Create a key — it starts with mx_live_…. Copy it now; the full value is only shown once.
  4. Pass it as api_key=, or set the MATHEXEC_API_KEY env var and read it yourself.

Public models don't need a key. Private models, rate-limited usage, and list_models() do.

Usage

Predict on one sample

from mathexec import Model

model = Model.load("project/experiment-3", api_key="mx_live_…")

# Named features
model.predict({"age": 25, "income": 50000})

# Positional features
model.predict([25, 50000])

Predict in batch

results = model.predict_batch([
    {"age": 25, "income": 50000},
    {"age": 45, "income": 80000},
])
results["predictions"]    # [1, 0]
results["probabilities"]  # [0.92, 0.31]

sklearn-style convenience

model.predict_label({"age": 25, "income": 50000})   # 'yes'
model.predict_proba({"age": 25, "income": 50000})   # 0.92

Model metadata

model.info["name"]            # "Churn classifier"
model.info["metrics"]         # {"accuracy": 0.92, "roc_auc": 0.94, ...}
model.task_type               # 'classification'
model.class_labels            # ['no', 'yes']
model.positive_class          # 'yes'

List your models

from mathexec import list_models

models = list_models(api_key="mx_live_…")
for m in models:
    print(m["model_id"], m["name"])

Self-hosted server

Model.load("id", base_url="http://localhost:8001", api_key="mx_live_…")

Errors

from mathexec import Model, MathExecError

try:
    model = Model.load("does-not-exist")
except MathExecError as e:
    print(e)   # "Model 'does-not-exist' not found."

MathExecError is raised for:

  • 404 — model not found / not accessible
  • 429 — rate limited
  • 400 — bad input (e.g. wrong feature names or types)

For 5xx the underlying requests.HTTPError propagates.

License

MIT

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

mathexec-0.1.0.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

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

mathexec-0.1.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for mathexec-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c68e956ed2c7d7053b385d8618f8b14a2767d329138145993ac772f7e9d6d013
MD5 28d9dd0c2ac83c4c11fdfd60ed89485d
BLAKE2b-256 f6beaebda39209f8c819737ceb3d609f0074775d75f8bf5cc57360a0f6cf9862

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for mathexec-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0d6c3b688359765cae1da2e9f6b662221517f9b698289a3fb765abea4af513b5
MD5 9175a30660c6c34cba5d33e3c13397e6
BLAKE2b-256 b021787dc5b6e5af591b9535bec3083c7ef3f6e7fcb52ef0d0e32009a04e1d23

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