Generation of database
- class pyagrum.BNDatabaseGenerator(bn)
BNDatabaseGenerator is used to easily generate databases from a
pyagrum.BayesNet.- Parameters:
bn (
pyagrum.BayesNet) – the Bayesian network used to generate data.
Scientific notes
BNDatabaseGenerator draws independent samples of a Bayesian network by probabilistic logic sampling
[1]: the variables are drawn in a topological order, each from its CPT given the values
already drawn for its parents (see pyagrum.MonteCarloSampling). With evidence, a sample that contradicts it is
rejected, so that the database is a sample of the posterior; drawSamples then counts the accepted rows, and stops
with an error after sampling.maxConsecutiveRejections consecutive rejections. The value returned is the
log-likelihood (base 2) of the database in the network. The value written for a discretized variable is, by default,
drawn uniformly in the interval of its label (or its middle, or the label itself).
Methods
Get the Bayesian network used to generate the samples |
|
Generate and stock a database generated by sampling the Bayesian network. |
|
Get the log2likelihood of the generated database |
|
Get the value of the database in (row,col) |
|
Get the label of the database in (row,col) |
|
return the number of columns in the samples |
|
return the number of rows in the samples |
|
Select an anti-topological order for the variables in the database. |
|
Set the discretized label mode to INTERVAL : sampling a |
|
Set the discretized label mode to MEDIAN : sampling a |
|
Set the discretized label mode to RANDOM (default mode) : sampling a |
|
Select an random order for the variables in the database. |
|
Select a topological order for the variables in the database. |
|
Set a specific order with a list of names |
|
Set the same order than in a csv file |
|
generates csv representing the generated database. |
|
export the samples as a pandas.DataFrame. |
|
The current order of the variables (as a tuple of node ids). |
|
The current order of the variables (as a tuple of names). |