Skip to main content

Monitaur Client Library

Project description

Monitaur Client Library

Tested with:

  1. Python 3.7.6
  2. Python 3.6.10

Install

$ pip install monitaur

Example

from monitaur import Monitaur
from monitaur.utils import hash_file


# create monitaur instance
monitaur = Monitaur(
    auth_key="changme",
    base_url="http://localhost:8008",
)

# train model
dataset = loadtxt("./_example/data.csv", delimiter=",")
seed = 7
test_size = 0.1
model_data = train_model(dataset, seed, test_size)
trained_model = model_data["trained_model"]
training_data = model_data["training_data"]
dump(trained_model, open(f"./_example/data.joblib", "wb"))


# add model to api
model_data = {
    "name": "Diabetes Classifier",
    "type": "Gradient Boosting",
    "model_type": "tabular",
    "library": "xgboost",
    "trained_model_hash": hash_file("./_example/data.joblib"),  # trained model
    "production_file_hash": hash_file("./_example/prediction.py"),  # production file used for running inputs through the trained model
    "feature_number": 8,
    "owner": "Anthony Habayeb",
    "developer": "Andrew Clark",
}
model_id = monitaur.add_model(**model_data)

# get aws credentials
credentials = monitaur.get_credentials(model_id)

# record training
record_training_data = {
    "credentials": credentials,
    "model_id": model_id,
    "trained_model": trained_model,
    "training_data": training_data,
    "feature_names": [
        "Pregnancies",
        "Glucose",
        "BloodPressure",
        "SkinThickness",
        "Insulin",
        "BMI",
        "DiabetesPedigreeF",
        "Age",
    ],
    # "re_train": True
}
monitaur.record_training(**record_training_data)

# record transaction
prediction = get_prediction([2, 84, 68, 27, 0, 26.7, 0.341, 32])
transaction_data = {
    "credentials": credentials,
    "model_id": model_id,
    "trained_model_hash": hash_file("./_example/data.joblib"),
    "production_file_hash": hash_file("./_example/prediction.py"),
    "prediction": prediction,
    "features": {
        "Pregnancies": 2,
        "Glucose": 84,
        "BloodPressure": 68,
        "SkinThickness": 27,
        "Insulin": 0,
        "BMI": 26.7,
        "DiabetesPedigreeF": 0.341,
        "Age": 32,
    },
}
response = monitaur.record_transaction(**transaction_data)
print(response)

History

0.1.8 (2020-01-30)

  • Rename model_type to model_class.
  • Add AnchorTabular class from alibi.

0.1.7 (2020-01-27)

  • Constrain model and library type.

0.1.6 (2020-01-22)

  • First release on PyPI.

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

monitaur-0.1.8.tar.gz (20.0 kB view details)

Uploaded Source

Built Distribution

monitaur-0.1.8-py3-none-any.whl (19.7 kB view details)

Uploaded Python 3

File details

Details for the file monitaur-0.1.8.tar.gz.

File metadata

  • Download URL: monitaur-0.1.8.tar.gz
  • Upload date:
  • Size: 20.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.6

File hashes

Hashes for monitaur-0.1.8.tar.gz
Algorithm Hash digest
SHA256 7a1150c35d5b75637a7b72916e5d83e01d0eaf3186a657fe378af7870c6eedb0
MD5 700e8f9f98565dc50012948a9e7e2229
BLAKE2b-256 29b5797894fb8eed718395eb4531af73627b3c3221ff373ba0f09d3787870763

See more details on using hashes here.

File details

Details for the file monitaur-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: monitaur-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 19.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.6

File hashes

Hashes for monitaur-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 46033b2e272b8db8a6f67541c39beb7e5fb5ec5c46d26455e262ce6ed332d6ae
MD5 db5f221752007a90f027030310e58d41
BLAKE2b-256 190904f12fb0cbf9298b9445d7b6a687666fbc0bad1737661f874753d40aa073

See more details on using hashes here.

Supported by

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