twinlab.train_campaign#

twinlab.train_campaign(filepath_or_params, campaign_id, ping_time=5.0, processor='cpu', verbose=False, debug=False)[source]#

Train a campaign in the twinLab cloud.

Parameters:
  • filepath_or_params (str) – dict. Union. Filepath to local json or parameters dictionary for training.

  • campaign_id (str) – Name for the final trained campaign.

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

  • dataset_id (str) – Dataset ID of the dataset as stored in the Cloud.

  • inputs (list) – A list of strings referring to the columns in the

  • outputs (list) – A list of strings referring to the columns in the

  • estimator (str, optional) – Optional. The type of estimator used in the pipeline. This can be either

  • estimator_kwargs (dict, optional) – Optional. Keywords passed to the underlying estimator.

  • decompose_input (bool, optional) – Optional. Specifies whether the input parameters

  • input_explained_variance (float, optional) – Optional. Specifies how much of the

  • decompose_output (bool, optional) – Optional. Specifies whether the output parameters

  • output_explained_variance (float, optional) – Optional. Specifies how much of the

  • train_test_ratio (float, optional) – Optional. Specifies the ratio of training samples in

  • model_selection (bool, optional) – Optional. Whether to run model selection.

  • model_selection_kwargs (dict, optional) – Optional. Keywords passed to the model

  • seed (int, optional) – Optional. Specifies the seed for the random number generator.

Return type:

None

Examples

Train using a local .json parameters file:

import twinlab as tl

tl.train_campaign("path/to/params.json", "my_campaign")

Train via a python dictionary:

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")

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/.