EDAspy.optimization.custom.probabilistic_models package

Submodules

EDAspy.optimization.custom.probabilistic_models.gaussian_bayesian_network module

class EDAspy.optimization.custom.probabilistic_models.gaussian_bayesian_network.GBN(variables: list)[source]

Bases: ProbabilisticModel

This probabilistic model is Gaussian Bayesian Network. All the relationships between the variables in the model are defined to be linearly Gaussian, and the variables distributions are assumed to be Gaussian. This is a very common approach when facing to continuous data as it is relatively easy and fast to learn a Gaussian distributions between variables. This implementation uses Pybnesian library [1].

References

[1]: Atienza, D., Bielza, C., & Larrañaga, P. (2022). PyBNesian: an extensible Python package for Bayesian networks. Neurocomputing, 504, 204-209.

learn(dataset: array)[source]

Learn a Gaussian Bayesian network from the dataset passed as argument.

Parameters

dataset – dataset from which learn the GBN.

print_structure() list[source]

Prints the arcs between the nodes that represent the variables in the dataset. This function must be used after the learning process.

Returns

list of arcs between variables

Return type

list

sample(size: int) array[source]

Samples the Gaussian Bayesian network several times defined by the user. The dataset is returned as a numpy matrix. The sampling process is implemented using probabilistic logic sampling.

Parameters

size – number of samplings of the Gaussian Bayesian network.

Returns

array with the dataset sampled.

Return type

np.array

EDAspy.optimization.custom.probabilistic_models.multivariate_gaussian module

class EDAspy.optimization.custom.probabilistic_models.multivariate_gaussian.MultiGauss(variables: list, lower_bound: float, upper_bound: float)[source]

Bases: ProbabilisticModel

This class implements all the code needed to learn and sample multivariate Gaussian distributions defined by a vector of means and a covariance matrix among the variables. This is a simpler approach compared to Gaussian Bayesian networks, as multivariate Gaussian distributions do not identify conditional dependeces between the variables.

learn(dataset: array)[source]

Estimates a multivariate Gaussian distribution from the dataset.

Parameters

dataset – dataset from which learn the multivariate Gaussian distribution.

sample(size: int) array[source]

Samples the multivariate Gaussian distribution several times defined by the user. The dataset is returned as a numpy matrix.

Parameters

size – number of samplings of the Gaussian Bayesian network.

Returns

array with the dataset sampled.

Return type

np.array

EDAspy.optimization.custom.probabilistic_models.univariate_binary module

class EDAspy.optimization.custom.probabilistic_models.univariate_binary.UniBin(variables: list, upper_bound: float, lower_bound: float)[source]

Bases: ProbabilisticModel

This is the simplest probabilistic model implemented in this package. This is used for binary EDAs where all the solutions are binary. The implementation involves a vector of independent probabilities [0, 1]. When sampling, a random float is sampled [0, 1]. If the float is below the probability, then the sampling is a 1. Thus, the probabilities show probabilities of a sampling being 1.

learn(dataset: array)[source]

Estimates the independent probability of each variable of being 1.

Parameters

dataset – dataset from which learn the probabilistic model.

sample(size: int) array[source]

Samples new solutions from the probabilistic model. In each solution, each variable is sampled from its respective binary probability.

Parameters

size – number of samplings of the probabilistic model.

Returns

array with the dataset sampled.

Return type

np.array

EDAspy.optimization.custom.probabilistic_models.univariate_gaussian module

class EDAspy.optimization.custom.probabilistic_models.univariate_gaussian.UniGauss(variables: list, lower_bound: float)[source]

Bases: ProbabilisticModel

This class implements the univariate Gaussians. With this implementation we are updating N univariate Gaussians in each iteration. When a dataset is given, each column is updated independently. The implementation involves a matrix with two rows, in which the first row are the means and the second one, are the standard deviations.

learn(dataset: array)[source]

Estimates the independent Gaussian for each variable.

Parameters

dataset – dataset from which learn the probabilistic model.

sample(size: int) array[source]

Samples new solutions from the probabilistic model. In each solution, each variable is sampled from its respective normal distribution.

Parameters

size – number of samplings of the probabilistic model.

Returns

array with the dataset sampled

Return type

np.array

Module contents