profit.al
Submodules
Package Contents
Classes
Active learning base class. |
|
Simple active learning algorithm based on a surrogate model and an acquisition function to find next candidates. |
|
Markov-chain Monte-Carlo active learning algorithm. |
- class profit.al.ActiveLearning(runner, variables, ntrain, nwarmup=defaults['nwarmup'], batch_size=defaults['batch_size'], convergence_criterion=defaults['convergence_criterion'], nsearch=defaults['nsearch'], make_plot=defaults['make_plot'])[source]
Bases:
profit.util.base_class.CustomABC
Active learning base class.
- Parameters:
runner (profit.run.Runner) – Runner to dynamically start runs.
variables (profit.util.variable.VariableGroup) – Variables.
ntrain (int) – Total number of training points.
nwarmup (int) – Number of warmup (random) initialization points.
batch_size (int) – Number of training samples learned in parallel.
convergence_criterion (float) – AL is stopped when the loss of the acquisition function is lower than this criterion. Not implemented yet.
nsearch (int) – Number of possible candidate points in each dimension.
make_plot (bool) – Flat indicating if the AL progress is plotted.
- krun
Current training cycle.
- Type:
int
- labels
- abstract warmup(save_intermediate=defaults['save_intermediate'])[source]
Warmup cycle before the actual learning starts.
- abstract learn(resume_from=defaults['resume_from'], save_intermediate=defaults['save_intermediate'])[source]
Main loop for active learning.
- update_run(candidates)[source]
Run a batch of simulations with the new candidates.
- Parameters:
candidates (np.array) – Input points to run the simulation on.
- abstract save(path)[source]
Save the AL model.
- Parameters:
path (str) – Path where the model is saved.
- classmethod from_config(runner, variables, config, base_config)[source]
Instantiates an ActiveLearning object from the configuration parameters.
- Parameters:
runner (profit.run.runner.Runner) – Runner instance.
variables (profit.util.variable.VariableGroup) – Variables.
config (dict) – Only the ‘active_learning’ part of the base_config.
base_config (dict) – The whole configuration parameters.
- Returns:
AL instance.
- Return type:
- class profit.al.SimpleAL(runner, variables, surrogate, ntrain, nwarmup=base_defaults['nwarmup'], batch_size=base_defaults['batch_size'], acquisition_function=defaults['acquisition_function'], convergence_criterion=base_defaults['convergence_criterion'], nsearch=base_defaults['nsearch'], make_plot=base_defaults['make_plot'], searchtype=defaults['searchtype'])[source]
Bases:
profit.al.ActiveLearning
Simple active learning algorithm based on a surrogate model and an acquisition function to find next candidates.
- Parameters:
surrogate (profit.sur.Surrogate) – Surrogate used for fitting.
acquisition_function (str/profit.al.acquisition_functions.AcquisitionFunction) – Acquisition function used for selecting the next candidates.
- search_space
np.linspace for each AL input variable.
- Type:
dict[str, np.array]
- Xpred
Matrix of the candidate points built with np.meshgrid.
- Type:
np.array
- labels
- warmup(save_intermediate=base_defaults['save_intermediate'])[source]
To get data for active learning, sample initial points randomly.
- learn(resume_from=base_defaults['resume_from'], save_intermediate=base_defaults['save_intermediate'])[source]
Main loop for active learning.
- find_next_candidates()[source]
Find the next candidates using the acquisition function’s method find_next_candidates.
- Returns:
Next training points.
- Return type:
np.array
- update_run(candidates)[source]
Run a batch of simulations with the new candidates.
- Parameters:
candidates (np.array) – Input points to run the simulation on.
- classmethod from_config(runner, variables, config, base_config)[source]
Instantiates an ActiveLearning object from the configuration parameters.
- Parameters:
runner (profit.run.runner.Runner) – Runner instance.
variables (profit.util.variable.VariableGroup) – Variables.
config (dict) – Only the ‘active_learning’ part of the base_config.
base_config (dict) – The whole configuration parameters.
- Returns:
AL instance.
- Return type:
- class profit.al.McmcAL(runner, variables, reference_data, ntrain, warmup_cycles=defaults['warmup_cycles'], nwarmup=base_defaults['nwarmup'], batch_size=base_defaults['batch_size'], target_acceptance_rate=defaults['target_acceptance_rate'], convergence_criterion=base_defaults['convergence_criterion'], nsearch=base_defaults['nsearch'], sigma_n=defaults['sigma_n'], make_plot=base_defaults['make_plot'], initial_points=defaults['initial_points'], save=defaults['save'], last_percent=defaults['last_percent'], delayed_acceptance=defaults['delayed_acceptance'])[source]
Bases:
profit.al.ActiveLearning
Markov-chain Monte-Carlo active learning algorithm.
- Parameters:
reference_data (np.ndarray) – Observed experimental data points. This is not the simulated model data!
warmup_cycles (int) – Number of warmup cycles with nwarmup iterations each.
target_acceptance_rate (float) – Target rate with which probability new points are accepted.
sigma_n (float) – Estimated standard deviation of the experimental data.
initial_points (list of float) – Starting points for the MCMC.
delayed_acceptancd (bool) – Whether to use delayed acceptance with a surrogate model for the likelihood.
- Xpred
Matrix of the candidate points built with np.meshgrid.
- Type:
np.ndarray
- dx
Distance between iterations in parameter space.
- Type:
np.ndarray
- ndim
Dimension of input parameters.
- Type:
int
- Xtrain
Array of sampled MCMC points.
- Type:
np.ndarray
- log_likelihood
Array of the log likelihood during training.
- Type:
np.ndarray
- accepted
Boolean array of accepted/rejected sample MCMC points.
- Type:
np.ndarray[bool]
- labels
- learn(resume_from=base_defaults['resume_from'], save_intermediate=base_defaults['save_intermediate'])[source]
Main loop for active learning.
- update_run(candidates)[source]
Run a batch of simulations with the new candidates.
- Parameters:
candidates (np.array) – Input points to run the simulation on.
- classmethod from_config(runner, variables, config, base_config)[source]
Instantiates an ActiveLearning object from the configuration parameters.
- Parameters:
runner (profit.run.runner.Runner) – Runner instance.
variables (profit.util.variable.VariableGroup) – Variables.
config (dict) – Only the ‘active_learning’ part of the base_config.
base_config (dict) – The whole configuration parameters.
- Returns:
AL instance.
- Return type: