twinlab.predict_campaign#

twinlab.predict_campaign(filepath_or_df, campaign_id, sync=False, ping_time=5.0, processor='cpu', verbose=False, debug=False)[source]#

Predict campaign

Make predictions from a pre-trained model that exists on the twinLab cloud.

Parameters:
  • filepath_or_df (str) – Location of .csv file dataset on local machine

  • campaign_id (str`.) – Name of pre-trained campaign to use for predictions.

  • verbose (bool, optional) – Optional. Determining level of information returned to the user.

  • campaign_id

Returns:

containing df_mean: df_std:

Return type:

tuple

Examples

Using a local file:

import pandas as pd
import twinlab as tl

df = pd.DataFrame({'X': [1, 2, 3, 4], 'y': [1, 4, 9, 16]})
tl.upload_dataset(df, "my_dataset")
params = {
    "dataset_id": "my_dataset",
    "inputs": ["X"],
    "outputs": ["y"],
}
tl.train_campaign(params, "my_campaign")
filepath = "path/to/data.csv" # Local
campaign_id = 'my_campaign" # Pre-trained
df_mean, df_std = tl.predict_campaign(filepath, campaign_id)
print(df_mean)
print(df_std)

Using a pandas.DataFrame:

import pandas as pd
import twinlab as tl

df = pd.DataFrame({'X': [1, 2, 3, 4], 'y': [1, 4, 9, 16]})
tl.upload_dataset(df, "my_dataset")
params = {
    "dataset_id": "my_dataset",
    "inputs": ["X"],
    "outputs": ["y"],
}
tl.train_campaign(params, "my_campaign")
df = pd.DataFrame({'X': [1.5, 2.5, 3.5]})
tl.predict_campaign(df, "my_campaign")

Deprecated since version 2.5.0: The twinLab Python client version v1 will be deprecated imminently. Please upgrade to the latest version of the twinLab Python client. Avaible at https://pypi.org/project/twinlab/.