twinlab.Emulator.predict#
- Emulator.predict(df, params=<twinlab.params.PredictParams object>, wait=True, verbose=True)[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 an uncertainty for each output dimension. This allows a user to not only make predictions, but also to quantify the uncertainty on those predictions:
For a regression model the uncertainty is the Gaussian standard deviation, which is a measure of the uncertainty in the prediction. The emulator is 95% confident that the true value lies within two standard deviations of the mean.
For a classification model the uncertainty is the probability of the predicted class, which is a measure of the confidence in the prediction.
If you are using an emulator trained on data from sources with different fidelity levels (a multi-fidelity emulator), the predictions will assume the highest fidelity level (fidelity = 1) for the output(s).
See the documentation for
PredictParams()
for more information on additional parameters that can be passed to predict.- 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 usingEmulator.get_process(<process_id>)
. Process IDs associated with an emulator can be found usingEmulator.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