Client interface for twinLab machine-learning in the cloud.
Project description
twinLab Client
Headless interface to the twinLab
library.
Installation for macOS
Requirements.
- Python 3.9 to 3.11.9 version installed and running for your current environment.
We recommend managing your Python packages with Python virtual environments. See more here.
Installation
1. Open a terminal.
2. Define the folder/directory where you want to install twinlab. Then, set that folder/directory as your current one.
mkdir my_project
cd my_project
3. In your newly created directory, install twinlab on the terminal using pip3 install twinlab.
pip3 install twinlab
4. In order to import and use twinlab
. There are two environment variables that must be set:
TWINLAB_API_KEY
: This is a unique key that you need to authenticate with our servers.TWINLAB_URL
: This is the link to our server that you are authenticating with.
Currently, the way to set these variables is to create a .env
file containing these variables. To do this, in the folder/directory that you have selected, create an .env file with your given API key. To do this use the following command on the terminal.
echo -e "TWINLAB_URL=https://twinlab.digilab.co.uk\nTWINLAB_API_KEY=[your_api_key]"> .env
Replace [your_api_key] with the API key given as a part of the license acquisition. (For information on licensing, please contact us here.). Be aware of any blank spaces in the words between the quotation marks!
To make sure you have created the document in your directory you can use the ls -a
command on your terminal.
ls -a
As an output, you should see the .env file among your files.
. .env
Import and use
Now you are ready to import and start using twinlab. Open your favourite notebook or code editor, and select the folder/directory where you have installed twinlab and created the .env file.
Option A: using jupyter notebook through anaconda. Launch jupyter notebook inside the file/directory where you have installed twinlab and created the .env file.
Import twinlab and run the following example.
# Import pandas as well
import twinlab as tl
import pandas as pd
# Create a dataset and upload to twinLab cloud
df = pd.DataFrame({"X": [1, 2, 3, 4], "y": [1, 4, 9, 16]})
tl.upload_dataset(df, "test-data")
# Train a machine-learning model for the data
params = {
"dataset_id": "test-data",
"inputs": ["X"],
"outputs": ["y"],
}
tl.train_campaign(params, campaign_id="test-model")
# Evaluate the model on some unseen data
df = pd.DataFrame({"X": [1.5, 2.5, 3.5]})
df_mean, df_std = tl.predict_campaign(df, campaign_id="test-model")
# Explore the results
print(df_mean)
print(df_std)
You should see the following results
>>> print(df_mean)
y
0 2.173827
1 6.284010
2 12.788779
>>> print(df_std)
y
0 2.483727
1 2.460696
2 2.483727
Option B: Using python through the terminal. Using the folder where we have installed twinlab and created the .env file, open python and import twinlab.
python
>>> import twinlab as tl
You should get a similar output with your credentials. For example:
{'username': 'yourname', 'credits': 0}
=== TwinLab Client Initialisation ===
Version : 1.4.0
User : yourname
Server : https://twinlab.digilab.co.uk
Key : your_api_key
Just to test twinlab, run the following example:
# Import pandas as well
import pandas as pd
# Create a dataset and upload to twinLab cloud
df = pd.DataFrame({"X": [1, 2, 3, 4], "y": [1, 4, 9, 16]})
tl.upload_dataset(df, "test-data")
# Train a machine-learning model for the data
params = {
"dataset_id": "test-data",
"inputs": ["X"],
"outputs": ["y"],
}
tl.train_campaign(params, campaign_id="test-model")
# Evaluate the model on some unseen data
df = pd.DataFrame({"X": [1.5, 2.5, 3.5]})
df_mean, df_std = tl.predict_campaign(df, campaign_id="test-model")
# Explore the results
print(df_mean)
print(df_std)
You should see the following results:
>>> print(df_mean)
y
0 2.173827
1 6.284010
2 12.788779
>>> print(df_std)
y
0 2.483727
1 2.460696
2 2.483727
Installation for Windows
Requirements
- Python 3.9 to 3.11.9 version installed and running for your current environment. (To download python visit https://www.python.org/downloads/)
- Microsoft Visual C++ 14 or higher versions installed.
We recommend managing your Python packages with Python virtual environments. See more here.
Installation
1. Open a terminal.
2. Define the folder/directory where you want to install twinlab. Then, set that folder/directory as your current one.
mkdir my_project
cd my_project
3. In your newly created directory, install twinlab on the terminal using pip3 install twinlab.
pip3 install twinlab
4. Still in the folder/directory that you have selected, create an .env file with your given API key. To do this use the following command on the terminal.
echo TWINLAB_URL=https://twinlab.digilab.co.uk > .env && echo TWINLAB_API_KEY=[your_api_key]>> .env && echo TWINLAB_SERVER=https://twinlab.digilab.co.uk >> .env && echo TWINLAB_KEY=[your_api_key]>> .env
Replace [your_api_key] with the API key given as a part of the license acquisition. Notice that you have to replace it twice! (For information on licensing, please contact us here.)
Be aware of any blank spaces in the words between the quotation marks!
To make sure you have created the document in your directory you can use the dir /a
command on your terminal.
dir /a
As an output, you should see the .env file among your files.
. .env
Import and use
Now you are ready to import and start using twinlab. Open your favourite notebook or code, editor and select the folder/directory where you have installed twinlab and created the .env file.
Option A: using jupyter notebook through anaconda. Launch jupyter notebook inside the file/directory where you have installed twinlab and created the .env file.
Import twinlab and run the following example:
# Import pandas as well
import twinlab as tl
import pandas as pd
# Create a dataset and upload to twinLab cloud
df = pd.DataFrame({"X": [1, 2, 3, 4], "y": [1, 4, 9, 16]})
tl.upload_dataset(df, "test-data")
# Train a machine-learning model for the data
params = {
"dataset_id": "test-data",
"inputs": ["X"],
"outputs": ["y"],
}
tl.train_campaign(params, campaign_id="test-model")
# Evaluate the model on some unseen data
df = pd.DataFrame({"X": [1.5, 2.5, 3.5]})
df_mean, df_std = tl.predict_campaign(df, campaign_id="test-model")
# Explore the results
print(df_mean)
print(df_std)
You should see the following results.
>>> print(df_mean)
y
0 2.173827
1 6.284010
2 12.788779
>>> print(df_std)
y
0 2.483727
1 2.460696
2 2.483727
Option B: Using python through the terminal. Using the folder where we have installed twinlab and created the .env file, open python and import twinlab.
python
>>> import twinlab as tl
You should get a similar output with your credentials. For example:
{'username': 'yourname', 'credits': 0}
=== TwinLab Client Initialisation ===
Version : 1.4.0
User : yourname
Server : https://twinlab.digilab.co.uk
Key : your_api_key
Just to test twinlab, run the following example:
# Import pandas as well
import pandas as pd
# Create a dataset and upload to twinLab cloud
df = pd.DataFrame({"X": [1, 2, 3, 4], "y": [1, 4, 9, 16]})
tl.upload_dataset(df, "test-data")
# Train a machine-learning model for the data
params = {
"dataset_id": "test-data",
"inputs": ["X"],
"outputs": ["y"],
}
tl.train_campaign(params, campaign_id="test-model")
# Evaluate the model on some unseen data
df = pd.DataFrame({"X": [1.5, 2.5, 3.5]})
df_mean, df_std = tl.predict_campaign(df, campaign_id="test-model")
# Explore the results
print(df_mean)
print(df_std)
You should see the following results:
>>> print(df_mean)
y
0 2.173827
1 6.284010
2 12.788779
>>> print(df_std)
y
0 2.483727
1 2.460696
2 2.483727
Having Problems?
If you have any questions or concerns you can email us at twinlab@digilab.co.uk or find out more at digilab.co.uk/products/twinlab.
Documentation
See the live documentation at https://digilab-ai.github.io/twinLab-client/. Or build a copy locally:
cd docs
yarn install && yarn start
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file twinlab-1.5.0.tar.gz
.
File metadata
- Download URL: twinlab-1.5.0.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.11.6 Darwin/22.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1004e96577256b5fb891dd495c60937f54f17306272689052edb3b55e8f3b839 |
|
MD5 | 0bda76d2d693a8da179e31520d13f467 |
|
BLAKE2b-256 | 702447153f7f075538eff8469a2d91366a5f6d3bc5824281479124308bf2371a |
File details
Details for the file twinlab-1.5.0-py3-none-any.whl
.
File metadata
- Download URL: twinlab-1.5.0-py3-none-any.whl
- Upload date:
- Size: 14.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.11.6 Darwin/22.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01e42562b7bd9ef7109022d611e049c6aa81896b4580c3505112bf6e65a8d2e5 |
|
MD5 | 2fd917c2565e042f6b33123f83ec2d0e |
|
BLAKE2b-256 | 2072b9917d1ab3230c623327425920c0c8fe141c43ee368b4871f263239cca79 |