twinlab.Emulator.predict#

Emulator.predict(df, params=<twinlab.params.PredictParams object>, wait=True, verbose=False)[source]#

Make predictions using a trained emulator that exists on the twinLab cloud.

This method makes predictions from a trained emulator on new data. This method is the workhorse of the twinLab suite, allowing users to make predictions based on their training data. The emulator can make predictions on data that are far away from the training data, and can interpolate reliably between the training data points. The emulator returns both a predicted mean and standard deviation for each output dimension. This allows a user to not only make predictions, but also to quantify the uncertainty on those predictions. For a Gaussian Process, the standard deviation is a measure of the uncertainty in the prediction, while the mean is the prediction itself. The emulator is 95% confident that the true value lies within two standard deviations of the mean.

Parameters:
  • df (pandas.DataFrame) – The X values for which to make predictions.

  • params (PredictParams) – A parameter-configuration that contains optional parameters for making predictions.

  • wait (bool, optional) – If True wait for the job to complete, otherwise return the process ID and exit.

  • verbose (bool, optional) – Display detailed information about the operation while running.

Returns:

By default a tuple containing the mean and standard deviation of the emulator prediction. Instead, if wait=False, the process ID is returned. The results can then be retrieved later using Emulator.get_process(<process_id>). Process IDs associated with an emulator can be found using Emulator.list_processes().

Return type:

Tuple[pandas.DataFrame, pandas.DataFrame], str

Example

emulator = tl.Emulator("quickstart")
df = pd.DataFrame({'x': [0.1, 0.2, 0.3, 0.4]})
df_mean, df_std = emulator.predict(df)
          y
0  0.845942
1  0.922921
2  0.846308
3  0.570473

          y
0  0.404200
1  0.180853
2  0.146619
3  0.147886