deephyper.stopper.lce.BayesianLearningCurveRegressor#

class deephyper.stopper.lce.BayesianLearningCurveRegressor(*args: Any, **kwargs: Any)[source]#

Bases: BaseEstimator, RegressorMixin

Probabilistic model for learning curve regression.

Parameters:
  • f_model (callable, optional) – The model function to use. Defaults to f_power3 for a Power-Law with 3 parameters.

  • f_model_nparams (int, optional) – The number of parameters of the model. Defaults to 3.

  • max_trials_ls_fit (int, optional) – The number of least-square fits that should be tried. Defaults to 10.

  • mcmc_kernel (str, optional) – The MCMC kernel to use. It should be a string in the following list: [“NUTS”, “BarkerMH”]. Defaults to “NUTS”.

  • mcmc_num_warmup (int, optional) – The number of warmup steps in MCMC. Defaults to 200.

  • mcmc_num_samples (int, optional) – The number of samples in MCMC. Defaults to 1_000.

  • random_state (int, optional) – A random state. Defaults to None.

  • verbose (int, optional) – Wether or not to use the verbose mode. Defaults to 0 to deactive it.

  • batch_size (int, optional) – The expected maximum length of the X, y arrays (used in the fit (X, y) method) in order to preallocate memory and compile the code only once. Defaults to 100.

  • min_max_scaling (bool, optional) – Wether or not to use min-max scaling in [0,1] for y values. Defaults to False.

Methods

fit

Fit the model.

get_parametrics_model_func

Return the function of the learning curve model given its name.

predict

Predict the mean and standard deviation of the model.

predict_posterior_samples

Predict the posterior samples of the model.

prob

Compute the approximate probability of P(cond(m(X_i), y_i)).

__call__(*args: Any, **kwargs: Any) Any#

Call self as a function.

fit(X, y, update_prior=True)[source]#

Fit the model.

Parameters:
  • X (np.ndarray) – A 1-D array of inputs.

  • y (_type_) – A 1-D array of targets.

  • update_prior (bool, optional) – A boolean indicating if the prior distribution should be updated using least-squares before running the Bayesian inference. Defaults to True.

Raises:

ValueError – if input arguments are invalid.

static get_parametrics_model_func(name)[source]#

Return the function of the learning curve model given its name.

Should be one of `` [“lin2”, “pow3”, “mmf4”, “vapor3”, “logloglin2”, “hill3”, “logpow3”, “pow4”, “exp4”, “janoschek4”, “weibull4”, “ilog2”, “arctan3”]`` where the integer suffix indicates the number of parameters of the model.

Parameters:

name (str) – The name of the learning curve model.

Returns:

A function with signature f(x, rho) of the learning curve model where x is a possible input of the model and rho is a 1-D array for the parameters of the model with length equal to the number of parameters of the model (e.g., it is of length 3 for "pow3").

Return type:

callable

predict(X, return_std=True)[source]#

Predict the mean and standard deviation of the model.

Parameters:
  • X (np.ndarray) – A 1-D array of inputs.

  • return_std (bool, optional) – A boolean indicating if the standard-deviation representing uncertainty in the prediction should be returned. Defaults to True.

Returns:

The mean prediction with shape (len(X),) and the standard deviation with shape (len(X),) if return_std is True.

Return type:

Tuple[np.ndarray, np.ndarray]

predict_posterior_samples(X)[source]#

Predict the posterior samples of the model.

Parameters:

X (np.ndarray) – a 1-D array of inputs.

Returns:

A 2-D array of shape (n_samples, len(X)) where n_samples is the number of samples and len(X) is the length of the input array.

Return type:

np.ndarray

prob(X, condition)[source]#

Compute the approximate probability of P(cond(m(X_i), y_i)).

Where m is the current fitted model and cond a condition.

Parameters:
  • X (np.array) – An array of inputs.

  • condition (callable) – A function defining the condition to test.

Returns:

an array of shape X.

Return type:

array