Skip to content
This repository has been archived by the owner on Jun 22, 2023. It is now read-only.

digiLab-ai/twinLab-api-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python twinLab API

This is how one can use the twinLab API via Python.

The api.py file wraps the twinLab API in functions, which you can use in your own code. The snippets in the examples directory demonstrate how these might be used.

Note: Because of the way that Python handles imports an api.py symbolic link is placed in the examples directory.

First, you need to set up the environment variables in the top-level .env file. You can copy the .env.example file as a template:

cp .env.example .env
open .env

If you are running locally, you need to set the TWINLAB_USERNAME and TWINLAB_SECRET variables. If you are running through RapidAPI then you need to set the TWINLAB_KEY and TWINLAB_HOST variables.

Quick Start

poetry install

Examples

You can then run the example examples in the examples directory:

poetry run python examples/<event_name>.py ...

Get user information

poetry run python examples/get_user.py

Get version information

poetry run python examples/get_versions.py

List datasets

poetry run python examples/list_datasets.py

Upload dataset

poetry run python examples/upload_dataset.py <path/to/dataset.csv> <dataset_id>
poetry run python examples/upload_dataset.py resources/datasets/biscuits.csv biscuits

View dataset

poetry run python examples/view_dataset.py <dataset_id>
poetry run python examples/view_dataset.py biscuits

Summarise a dataset

poetry run python examples/summarise_dataset.py <dataset_id>
poetry run python examples/summarise_dataset.py biscuits

List models

poetry run python examples/list_models.py

Train model

poetry run python examples/train_model.py <path/to/parameters.json> <model_id> <processor>
poetry run python examples/train_model.py resources/campaigns/biscuits/parameters.json biscuits-model cpu

Get the model status

Summarise model

poetry run python examples/summarise_model.py <model_id>
poetry run python examples/summarise_model.py biscuits-model

Predict using a trained model

poetry run python examples/use_model.py <path/to/inputs.csv> <model_id> <method> <processor>
poetry run python examples/use_model.py resources/campaigns/biscuits/eval.csv biscuits-model predict cpu

Delete model

poetry run python examples/delete_model.py <model_id>
poetry run python examples/delete_model.py biscuits-model

Delete dataset

poetry run python examples/delete_dataset.py <dataset_id>
poetry run python examples/delete_dataset.py biscuits

Releases

No releases published

Packages

No packages published

Languages