partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
NoUTurnSamplerDA.generate_sample
Returns a generator type object whose each iteration yields a sample Parameters ---------- initial_pos: A 1d array like object Vector representing values of parameter position, the starting state in markov chain. num_adapt: int The number of interati...
pgmpy/sampling/NUTS.py
def generate_sample(self, initial_pos, num_adapt, num_samples, stepsize=None): """ Returns a generator type object whose each iteration yields a sample Parameters ---------- initial_pos: A 1d array like object Vector representing values of parameter position, the sta...
def generate_sample(self, initial_pos, num_adapt, num_samples, stepsize=None): """ Returns a generator type object whose each iteration yields a sample Parameters ---------- initial_pos: A 1d array like object Vector representing values of parameter position, the sta...
[ "Returns", "a", "generator", "type", "object", "whose", "each", "iteration", "yields", "a", "sample" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/sampling/NUTS.py#L555-L634
[ "def", "generate_sample", "(", "self", ",", "initial_pos", ",", "num_adapt", ",", "num_samples", ",", "stepsize", "=", "None", ")", ":", "initial_pos", "=", "_check_1d_array_object", "(", "initial_pos", ",", "'initial_pos'", ")", "_check_length_equal", "(", "initi...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
ContinuousFactor.discretize
Discretizes the continuous distribution into discrete probability masses using various methods. Parameters ---------- method : A Discretizer Class from pgmpy.discretize *args, **kwargs: The parameters to be given to the Discretizer Class. Returns --...
pgmpy/factors/continuous/ContinuousFactor.py
def discretize(self, method, *args, **kwargs): """ Discretizes the continuous distribution into discrete probability masses using various methods. Parameters ---------- method : A Discretizer Class from pgmpy.discretize *args, **kwargs: The parameter...
def discretize(self, method, *args, **kwargs): """ Discretizes the continuous distribution into discrete probability masses using various methods. Parameters ---------- method : A Discretizer Class from pgmpy.discretize *args, **kwargs: The parameter...
[ "Discretizes", "the", "continuous", "distribution", "into", "discrete", "probability", "masses", "using", "various", "methods", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/continuous/ContinuousFactor.py#L151-L180
[ "def", "discretize", "(", "self", ",", "method", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "method", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ".", "get_discrete_values", "(", ")" ]
9381a66aba3c3871d3ccd00672b148d17d63239e
train
ContinuousFactor.reduce
Reduces the factor to the context of the given variable values. Parameters ---------- values: list, array-like A list of tuples of the form (variable_name, variable_value). inplace: boolean If inplace=True it will modify the factor itself, else would return ...
pgmpy/factors/continuous/ContinuousFactor.py
def reduce(self, values, inplace=True): """ Reduces the factor to the context of the given variable values. Parameters ---------- values: list, array-like A list of tuples of the form (variable_name, variable_value). inplace: boolean If inplace=T...
def reduce(self, values, inplace=True): """ Reduces the factor to the context of the given variable values. Parameters ---------- values: list, array-like A list of tuples of the form (variable_name, variable_value). inplace: boolean If inplace=T...
[ "Reduces", "the", "factor", "to", "the", "context", "of", "the", "given", "variable", "values", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/continuous/ContinuousFactor.py#L182-L223
[ "def", "reduce", "(", "self", ",", "values", ",", "inplace", "=", "True", ")", ":", "phi", "=", "self", "if", "inplace", "else", "self", ".", "copy", "(", ")", "phi", ".", "distribution", "=", "phi", ".", "distribution", ".", "reduce", "(", "values",...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
ContinuousFactor.marginalize
Marginalize the factor with respect to the given variables. Parameters ---------- variables: list, array-like List of variables with respect to which factor is to be maximized. inplace: boolean If inplace=True it will modify the factor itself, else would return ...
pgmpy/factors/continuous/ContinuousFactor.py
def marginalize(self, variables, inplace=True): """ Marginalize the factor with respect to the given variables. Parameters ---------- variables: list, array-like List of variables with respect to which factor is to be maximized. inplace: boolean ...
def marginalize(self, variables, inplace=True): """ Marginalize the factor with respect to the given variables. Parameters ---------- variables: list, array-like List of variables with respect to which factor is to be maximized. inplace: boolean ...
[ "Marginalize", "the", "factor", "with", "respect", "to", "the", "given", "variables", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/continuous/ContinuousFactor.py#L225-L263
[ "def", "marginalize", "(", "self", ",", "variables", ",", "inplace", "=", "True", ")", ":", "phi", "=", "self", "if", "inplace", "else", "self", ".", "copy", "(", ")", "phi", ".", "distribution", "=", "phi", ".", "distribution", ".", "marginalize", "("...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
ContinuousFactor.normalize
Normalizes the pdf of the continuous factor so that it integrates to 1 over all the variables. Parameters ---------- inplace: boolean If inplace=True it will modify the factor itself, else would return a new factor. Returns ------- Contin...
pgmpy/factors/continuous/ContinuousFactor.py
def normalize(self, inplace=True): """ Normalizes the pdf of the continuous factor so that it integrates to 1 over all the variables. Parameters ---------- inplace: boolean If inplace=True it will modify the factor itself, else would return a new ...
def normalize(self, inplace=True): """ Normalizes the pdf of the continuous factor so that it integrates to 1 over all the variables. Parameters ---------- inplace: boolean If inplace=True it will modify the factor itself, else would return a new ...
[ "Normalizes", "the", "pdf", "of", "the", "continuous", "factor", "so", "that", "it", "integrates", "to", "1", "over", "all", "the", "variables", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/continuous/ContinuousFactor.py#L265-L299
[ "def", "normalize", "(", "self", ",", "inplace", "=", "True", ")", ":", "phi", "=", "self", "if", "inplace", "else", "self", ".", "copy", "(", ")", "phi", ".", "distriution", "=", "phi", ".", "distribution", ".", "normalize", "(", "inplace", "=", "Fa...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
ContinuousFactor._operate
Gives the ContinuousFactor operation (product or divide) with the other factor. Parameters ---------- other: ContinuousFactor The ContinuousFactor to be multiplied. operation: String 'product' for multiplication operation and 'divide' for div...
pgmpy/factors/continuous/ContinuousFactor.py
def _operate(self, other, operation, inplace=True): """ Gives the ContinuousFactor operation (product or divide) with the other factor. Parameters ---------- other: ContinuousFactor The ContinuousFactor to be multiplied. operation: String ...
def _operate(self, other, operation, inplace=True): """ Gives the ContinuousFactor operation (product or divide) with the other factor. Parameters ---------- other: ContinuousFactor The ContinuousFactor to be multiplied. operation: String ...
[ "Gives", "the", "ContinuousFactor", "operation", "(", "product", "or", "divide", ")", "with", "the", "other", "factor", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/continuous/ContinuousFactor.py#L304-L340
[ "def", "_operate", "(", "self", ",", "other", ",", "operation", ",", "inplace", "=", "True", ")", ":", "if", "not", "isinstance", "(", "other", ",", "ContinuousFactor", ")", ":", "raise", "TypeError", "(", "\"ContinuousFactor objects can only be multiplied \"", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
ContinuousFactor.divide
Gives the ContinuousFactor divide with the other factor. Parameters ---------- other: ContinuousFactor The ContinuousFactor to be divided. Returns ------- ContinuousFactor or None: if inplace=True (default) returns None ...
pgmpy/factors/continuous/ContinuousFactor.py
def divide(self, other, inplace=True): """ Gives the ContinuousFactor divide with the other factor. Parameters ---------- other: ContinuousFactor The ContinuousFactor to be divided. Returns ------- ContinuousFactor or None: ...
def divide(self, other, inplace=True): """ Gives the ContinuousFactor divide with the other factor. Parameters ---------- other: ContinuousFactor The ContinuousFactor to be divided. Returns ------- ContinuousFactor or None: ...
[ "Gives", "the", "ContinuousFactor", "divide", "with", "the", "other", "factor", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/continuous/ContinuousFactor.py#L376-L411
[ "def", "divide", "(", "self", ",", "other", ",", "inplace", "=", "True", ")", ":", "if", "set", "(", "other", ".", "scope", "(", ")", ")", "-", "set", "(", "self", ".", "scope", "(", ")", ")", ":", "raise", "ValueError", "(", "\"Scope of divisor sh...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
factor_product
Returns factor product over `args`. Parameters ---------- args: `BaseFactor` instances. factors to be multiplied Returns ------- BaseFactor: `BaseFactor` representing factor product over all the `BaseFactor` instances in args. Examples -------- >>> from pgmpy.factors.discr...
pgmpy/factors/base.py
def factor_product(*args): """ Returns factor product over `args`. Parameters ---------- args: `BaseFactor` instances. factors to be multiplied Returns ------- BaseFactor: `BaseFactor` representing factor product over all the `BaseFactor` instances in args. Examples --...
def factor_product(*args): """ Returns factor product over `args`. Parameters ---------- args: `BaseFactor` instances. factors to be multiplied Returns ------- BaseFactor: `BaseFactor` representing factor product over all the `BaseFactor` instances in args. Examples --...
[ "Returns", "factor", "product", "over", "args", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/base.py#L18-L69
[ "def", "factor_product", "(", "*", "args", ")", ":", "if", "not", "all", "(", "isinstance", "(", "phi", ",", "BaseFactor", ")", "for", "phi", "in", "args", ")", ":", "raise", "TypeError", "(", "\"Arguments must be factors\"", ")", "# Check if all of the argume...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
factor_divide
Returns `DiscreteFactor` representing `phi1 / phi2`. Parameters ---------- phi1: Factor The Dividend. phi2: Factor The Divisor. Returns ------- DiscreteFactor: `DiscreteFactor` representing factor division `phi1 / phi2`. Examples -------- >>> from pgmpy.factor...
pgmpy/factors/base.py
def factor_divide(phi1, phi2): """ Returns `DiscreteFactor` representing `phi1 / phi2`. Parameters ---------- phi1: Factor The Dividend. phi2: Factor The Divisor. Returns ------- DiscreteFactor: `DiscreteFactor` representing factor division `phi1 / phi2`. Exam...
def factor_divide(phi1, phi2): """ Returns `DiscreteFactor` representing `phi1 / phi2`. Parameters ---------- phi1: Factor The Dividend. phi2: Factor The Divisor. Returns ------- DiscreteFactor: `DiscreteFactor` representing factor division `phi1 / phi2`. Exam...
[ "Returns", "DiscreteFactor", "representing", "phi1", "/", "phi2", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/base.py#L72-L116
[ "def", "factor_divide", "(", "phi1", ",", "phi2", ")", ":", "if", "not", "isinstance", "(", "phi1", ",", "BaseFactor", ")", "or", "not", "isinstance", "(", "phi2", ",", "BaseFactor", ")", ":", "raise", "TypeError", "(", "\"phi1 and phi2 should be factors insta...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BayesianEstimator.get_parameters
Method to estimate the model parameters (CPDs). Parameters ---------- prior_type: 'dirichlet', 'BDeu', or 'K2' string indicting which type of prior to use for the model parameters. - If 'prior_type' is 'dirichlet', the following must be provided: 'pseudo_...
pgmpy/estimators/BayesianEstimator.py
def get_parameters(self, prior_type='BDeu', equivalent_sample_size=5, pseudo_counts=None): """ Method to estimate the model parameters (CPDs). Parameters ---------- prior_type: 'dirichlet', 'BDeu', or 'K2' string indicting which type of prior to use for the model par...
def get_parameters(self, prior_type='BDeu', equivalent_sample_size=5, pseudo_counts=None): """ Method to estimate the model parameters (CPDs). Parameters ---------- prior_type: 'dirichlet', 'BDeu', or 'K2' string indicting which type of prior to use for the model par...
[ "Method", "to", "estimate", "the", "model", "parameters", "(", "CPDs", ")", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/estimators/BayesianEstimator.py#L21-L77
[ "def", "get_parameters", "(", "self", ",", "prior_type", "=", "'BDeu'", ",", "equivalent_sample_size", "=", "5", ",", "pseudo_counts", "=", "None", ")", ":", "parameters", "=", "[", "]", "for", "node", "in", "self", ".", "model", ".", "nodes", "(", ")", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BayesianEstimator.estimate_cpd
Method to estimate the CPD for a given variable. Parameters ---------- node: int, string (any hashable python object) The name of the variable for which the CPD is to be estimated. prior_type: 'dirichlet', 'BDeu', 'K2', string indicting which type of prior to us...
pgmpy/estimators/BayesianEstimator.py
def estimate_cpd(self, node, prior_type='BDeu', pseudo_counts=[], equivalent_sample_size=5): """ Method to estimate the CPD for a given variable. Parameters ---------- node: int, string (any hashable python object) The name of the variable for which the CPD is to be ...
def estimate_cpd(self, node, prior_type='BDeu', pseudo_counts=[], equivalent_sample_size=5): """ Method to estimate the CPD for a given variable. Parameters ---------- node: int, string (any hashable python object) The name of the variable for which the CPD is to be ...
[ "Method", "to", "estimate", "the", "CPD", "for", "a", "given", "variable", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/estimators/BayesianEstimator.py#L79-L154
[ "def", "estimate_cpd", "(", "self", ",", "node", ",", "prior_type", "=", "'BDeu'", ",", "pseudo_counts", "=", "[", "]", ",", "equivalent_sample_size", "=", "5", ")", ":", "node_cardinality", "=", "len", "(", "self", ".", "state_names", "[", "node", "]", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BayesianModelSampling.forward_sample
Generates sample(s) from joint distribution of the bayesian network. Parameters ---------- size: int size of sample to be generated return_type: string (dataframe | recarray) Return type for samples, either of 'dataframe' or 'recarray'. Defaults to '...
pgmpy/sampling/Sampling.py
def forward_sample(self, size=1, return_type='dataframe'): """ Generates sample(s) from joint distribution of the bayesian network. Parameters ---------- size: int size of sample to be generated return_type: string (dataframe | recarray) Return t...
def forward_sample(self, size=1, return_type='dataframe'): """ Generates sample(s) from joint distribution of the bayesian network. Parameters ---------- size: int size of sample to be generated return_type: string (dataframe | recarray) Return t...
[ "Generates", "sample", "(", "s", ")", "from", "joint", "distribution", "of", "the", "bayesian", "network", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/sampling/Sampling.py#L39-L90
[ "def", "forward_sample", "(", "self", ",", "size", "=", "1", ",", "return_type", "=", "'dataframe'", ")", ":", "types", "=", "[", "(", "var_name", ",", "'int'", ")", "for", "var_name", "in", "self", ".", "topological_order", "]", "sampled", "=", "np", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BayesianModelSampling.rejection_sample
Generates sample(s) from joint distribution of the bayesian network, given the evidence. Parameters ---------- evidence: list of `pgmpy.factor.State` namedtuples None if no evidence size: int size of sample to be generated return_type: string (dat...
pgmpy/sampling/Sampling.py
def rejection_sample(self, evidence=None, size=1, return_type="dataframe"): """ Generates sample(s) from joint distribution of the bayesian network, given the evidence. Parameters ---------- evidence: list of `pgmpy.factor.State` namedtuples None if no eviden...
def rejection_sample(self, evidence=None, size=1, return_type="dataframe"): """ Generates sample(s) from joint distribution of the bayesian network, given the evidence. Parameters ---------- evidence: list of `pgmpy.factor.State` namedtuples None if no eviden...
[ "Generates", "sample", "(", "s", ")", "from", "joint", "distribution", "of", "the", "bayesian", "network", "given", "the", "evidence", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/sampling/Sampling.py#L103-L161
[ "def", "rejection_sample", "(", "self", ",", "evidence", "=", "None", ",", "size", "=", "1", ",", "return_type", "=", "\"dataframe\"", ")", ":", "if", "evidence", "is", "None", ":", "return", "self", ".", "forward_sample", "(", "size", ")", "types", "=",...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BayesianModelSampling.likelihood_weighted_sample
Generates weighted sample(s) from joint distribution of the bayesian network, that comply with the given evidence. 'Probabilistic Graphical Model Principles and Techniques', Koller and Friedman, Algorithm 12.2 pp 493. Parameters ---------- evidence: list of `pgmpy.factor...
pgmpy/sampling/Sampling.py
def likelihood_weighted_sample(self, evidence=None, size=1, return_type="dataframe"): """ Generates weighted sample(s) from joint distribution of the bayesian network, that comply with the given evidence. 'Probabilistic Graphical Model Principles and Techniques', Koller and Fried...
def likelihood_weighted_sample(self, evidence=None, size=1, return_type="dataframe"): """ Generates weighted sample(s) from joint distribution of the bayesian network, that comply with the given evidence. 'Probabilistic Graphical Model Principles and Techniques', Koller and Fried...
[ "Generates", "weighted", "sample", "(", "s", ")", "from", "joint", "distribution", "of", "the", "bayesian", "network", "that", "comply", "with", "the", "given", "evidence", ".", "Probabilistic", "Graphical", "Model", "Principles", "and", "Techniques", "Koller", ...
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/sampling/Sampling.py#L163-L233
[ "def", "likelihood_weighted_sample", "(", "self", ",", "evidence", "=", "None", ",", "size", "=", "1", ",", "return_type", "=", "\"dataframe\"", ")", ":", "types", "=", "[", "(", "var_name", ",", "'int'", ")", "for", "var_name", "in", "self", ".", "topol...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
GibbsSampling._get_kernel_from_bayesian_model
Computes the Gibbs transition models from a Bayesian Network. 'Probabilistic Graphical Model Principles and Techniques', Koller and Friedman, Section 12.3.3 pp 512-513. Parameters: ----------- model: BayesianModel The model from which probabilities will be computed.
pgmpy/sampling/Sampling.py
def _get_kernel_from_bayesian_model(self, model): """ Computes the Gibbs transition models from a Bayesian Network. 'Probabilistic Graphical Model Principles and Techniques', Koller and Friedman, Section 12.3.3 pp 512-513. Parameters: ----------- model: BayesianM...
def _get_kernel_from_bayesian_model(self, model): """ Computes the Gibbs transition models from a Bayesian Network. 'Probabilistic Graphical Model Principles and Techniques', Koller and Friedman, Section 12.3.3 pp 512-513. Parameters: ----------- model: BayesianM...
[ "Computes", "the", "Gibbs", "transition", "models", "from", "a", "Bayesian", "Network", ".", "Probabilistic", "Graphical", "Model", "Principles", "and", "Techniques", "Koller", "and", "Friedman", "Section", "12", ".", "3", ".", "3", "pp", "512", "-", "513", ...
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/sampling/Sampling.py#L278-L303
[ "def", "_get_kernel_from_bayesian_model", "(", "self", ",", "model", ")", ":", "self", ".", "variables", "=", "np", ".", "array", "(", "model", ".", "nodes", "(", ")", ")", "self", ".", "cardinalities", "=", "{", "var", ":", "model", ".", "get_cpds", "...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
GibbsSampling._get_kernel_from_markov_model
Computes the Gibbs transition models from a Markov Network. 'Probabilistic Graphical Model Principles and Techniques', Koller and Friedman, Section 12.3.3 pp 512-513. Parameters: ----------- model: MarkovModel The model from which probabilities will be computed.
pgmpy/sampling/Sampling.py
def _get_kernel_from_markov_model(self, model): """ Computes the Gibbs transition models from a Markov Network. 'Probabilistic Graphical Model Principles and Techniques', Koller and Friedman, Section 12.3.3 pp 512-513. Parameters: ----------- model: MarkovModel ...
def _get_kernel_from_markov_model(self, model): """ Computes the Gibbs transition models from a Markov Network. 'Probabilistic Graphical Model Principles and Techniques', Koller and Friedman, Section 12.3.3 pp 512-513. Parameters: ----------- model: MarkovModel ...
[ "Computes", "the", "Gibbs", "transition", "models", "from", "a", "Markov", "Network", ".", "Probabilistic", "Graphical", "Model", "Principles", "and", "Techniques", "Koller", "and", "Friedman", "Section", "12", ".", "3", ".", "3", "pp", "512", "-", "513", "....
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/sampling/Sampling.py#L305-L337
[ "def", "_get_kernel_from_markov_model", "(", "self", ",", "model", ")", ":", "self", ".", "variables", "=", "np", ".", "array", "(", "model", ".", "nodes", "(", ")", ")", "factors_dict", "=", "{", "var", ":", "[", "]", "for", "var", "in", "self", "."...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
GibbsSampling.sample
Sample from the Markov Chain. Parameters: ----------- start_state: dict or array-like iterable Representing the starting states of the variables. If None is passed, a random start_state is chosen. size: int Number of samples to be generated. return_type: ...
pgmpy/sampling/Sampling.py
def sample(self, start_state=None, size=1, return_type="dataframe"): """ Sample from the Markov Chain. Parameters: ----------- start_state: dict or array-like iterable Representing the starting states of the variables. If None is passed, a random start_state is chose...
def sample(self, start_state=None, size=1, return_type="dataframe"): """ Sample from the Markov Chain. Parameters: ----------- start_state: dict or array-like iterable Representing the starting states of the variables. If None is passed, a random start_state is chose...
[ "Sample", "from", "the", "Markov", "Chain", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/sampling/Sampling.py#L339-L391
[ "def", "sample", "(", "self", ",", "start_state", "=", "None", ",", "size", "=", "1", ",", "return_type", "=", "\"dataframe\"", ")", ":", "if", "start_state", "is", "None", "and", "self", ".", "state", "is", "None", ":", "self", ".", "state", "=", "s...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
GibbsSampling.generate_sample
Generator version of self.sample Return Type: ------------ List of State namedtuples, representing the assignment to all variables of the model. Examples: --------- >>> from pgmpy.factors.discrete import DiscreteFactor >>> from pgmpy.sampling import GibbsSamplin...
pgmpy/sampling/Sampling.py
def generate_sample(self, start_state=None, size=1): """ Generator version of self.sample Return Type: ------------ List of State namedtuples, representing the assignment to all variables of the model. Examples: --------- >>> from pgmpy.factors.discrete ...
def generate_sample(self, start_state=None, size=1): """ Generator version of self.sample Return Type: ------------ List of State namedtuples, representing the assignment to all variables of the model. Examples: --------- >>> from pgmpy.factors.discrete ...
[ "Generator", "version", "of", "self", ".", "sample" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/sampling/Sampling.py#L393-L428
[ "def", "generate_sample", "(", "self", ",", "start_state", "=", "None", ",", "size", "=", "1", ")", ":", "if", "start_state", "is", "None", "and", "self", ".", "state", "is", "None", ":", "self", ".", "state", "=", "self", ".", "random_state", "(", "...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BaseEstimator._collect_state_names
Return a list of states that the variable takes in the data
pgmpy/estimators/base.py
def _collect_state_names(self, variable): "Return a list of states that the variable takes in the data" states = sorted(list(self.data.ix[:, variable].dropna().unique())) return states
def _collect_state_names(self, variable): "Return a list of states that the variable takes in the data" states = sorted(list(self.data.ix[:, variable].dropna().unique())) return states
[ "Return", "a", "list", "of", "states", "that", "the", "variable", "takes", "in", "the", "data" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/estimators/base.py#L55-L58
[ "def", "_collect_state_names", "(", "self", ",", "variable", ")", ":", "states", "=", "sorted", "(", "list", "(", "self", ".", "data", ".", "ix", "[", ":", ",", "variable", "]", ".", "dropna", "(", ")", ".", "unique", "(", ")", ")", ")", "return", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BaseEstimator.state_counts
Return counts how often each state of 'variable' occured in the data. If a list of parents is provided, counting is done conditionally for each state configuration of the parents. Parameters ---------- variable: string Name of the variable for which the state count i...
pgmpy/estimators/base.py
def state_counts(self, variable, parents=[], complete_samples_only=None): """ Return counts how often each state of 'variable' occured in the data. If a list of parents is provided, counting is done conditionally for each state configuration of the parents. Parameters --...
def state_counts(self, variable, parents=[], complete_samples_only=None): """ Return counts how often each state of 'variable' occured in the data. If a list of parents is provided, counting is done conditionally for each state configuration of the parents. Parameters --...
[ "Return", "counts", "how", "often", "each", "state", "of", "variable", "occured", "in", "the", "data", ".", "If", "a", "list", "of", "parents", "is", "provided", "counting", "is", "done", "conditionally", "for", "each", "state", "configuration", "of", "the",...
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/estimators/base.py#L62-L140
[ "def", "state_counts", "(", "self", ",", "variable", ",", "parents", "=", "[", "]", ",", "complete_samples_only", "=", "None", ")", ":", "parents", "=", "list", "(", "parents", ")", "# default for how to deal with missing data can be set in class constructor", "if", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
ParameterEstimator.state_counts
Return counts how often each state of 'variable' occured in the data. If the variable has parents, counting is done conditionally for each state configuration of the parents. Parameters ---------- variable: string Name of the variable for which the state count is to ...
pgmpy/estimators/base.py
def state_counts(self, variable, **kwargs): """ Return counts how often each state of 'variable' occured in the data. If the variable has parents, counting is done conditionally for each state configuration of the parents. Parameters ---------- variable: string ...
def state_counts(self, variable, **kwargs): """ Return counts how often each state of 'variable' occured in the data. If the variable has parents, counting is done conditionally for each state configuration of the parents. Parameters ---------- variable: string ...
[ "Return", "counts", "how", "often", "each", "state", "of", "variable", "occured", "in", "the", "data", ".", "If", "the", "variable", "has", "parents", "counting", "is", "done", "conditionally", "for", "each", "state", "configuration", "of", "the", "parents", ...
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/estimators/base.py#L296-L341
[ "def", "state_counts", "(", "self", ",", "variable", ",", "*", "*", "kwargs", ")", ":", "parents", "=", "sorted", "(", "self", ".", "model", ".", "get_parents", "(", "variable", ")", ")", "return", "super", "(", "ParameterEstimator", ",", "self", ")", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
ClusterGraph.add_node
Add a single node to the cluster graph. Parameters ---------- node: node A node should be a collection of nodes forming a clique. It can be a list, set or tuple of nodes Examples -------- >>> from pgmpy.models import ClusterGraph >>> G = ...
pgmpy/models/ClusterGraph.py
def add_node(self, node, **kwargs): """ Add a single node to the cluster graph. Parameters ---------- node: node A node should be a collection of nodes forming a clique. It can be a list, set or tuple of nodes Examples -------- >>...
def add_node(self, node, **kwargs): """ Add a single node to the cluster graph. Parameters ---------- node: node A node should be a collection of nodes forming a clique. It can be a list, set or tuple of nodes Examples -------- >>...
[ "Add", "a", "single", "node", "to", "the", "cluster", "graph", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/ClusterGraph.py#L63-L83
[ "def", "add_node", "(", "self", ",", "node", ",", "*", "*", "kwargs", ")", ":", "if", "not", "isinstance", "(", "node", ",", "(", "list", ",", "set", ",", "tuple", ")", ")", ":", "raise", "TypeError", "(", "'Node can only be a list, set or tuple of nodes f...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
ClusterGraph.add_nodes_from
Add multiple nodes to the cluster graph. Parameters ---------- nodes: iterable container A container of nodes (list, dict, set, etc.). Examples -------- >>> from pgmpy.models import ClusterGraph >>> G = ClusterGraph() >>> G.add_nodes_from([('...
pgmpy/models/ClusterGraph.py
def add_nodes_from(self, nodes, **kwargs): """ Add multiple nodes to the cluster graph. Parameters ---------- nodes: iterable container A container of nodes (list, dict, set, etc.). Examples -------- >>> from pgmpy.models import ClusterGraph ...
def add_nodes_from(self, nodes, **kwargs): """ Add multiple nodes to the cluster graph. Parameters ---------- nodes: iterable container A container of nodes (list, dict, set, etc.). Examples -------- >>> from pgmpy.models import ClusterGraph ...
[ "Add", "multiple", "nodes", "to", "the", "cluster", "graph", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/ClusterGraph.py#L85-L101
[ "def", "add_nodes_from", "(", "self", ",", "nodes", ",", "*", "*", "kwargs", ")", ":", "for", "node", "in", "nodes", ":", "self", ".", "add_node", "(", "node", ",", "*", "*", "kwargs", ")" ]
9381a66aba3c3871d3ccd00672b148d17d63239e
train
ClusterGraph.add_edge
Add an edge between two clique nodes. Parameters ---------- u, v: nodes Nodes can be any list or set or tuple of nodes forming a clique. Examples -------- >>> from pgmpy.models import ClusterGraph >>> G = ClusterGraph() >>> G.add_nodes_from([...
pgmpy/models/ClusterGraph.py
def add_edge(self, u, v, **kwargs): """ Add an edge between two clique nodes. Parameters ---------- u, v: nodes Nodes can be any list or set or tuple of nodes forming a clique. Examples -------- >>> from pgmpy.models import ClusterGraph ...
def add_edge(self, u, v, **kwargs): """ Add an edge between two clique nodes. Parameters ---------- u, v: nodes Nodes can be any list or set or tuple of nodes forming a clique. Examples -------- >>> from pgmpy.models import ClusterGraph ...
[ "Add", "an", "edge", "between", "two", "clique", "nodes", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/ClusterGraph.py#L103-L125
[ "def", "add_edge", "(", "self", ",", "u", ",", "v", ",", "*", "*", "kwargs", ")", ":", "set_u", "=", "set", "(", "u", ")", "set_v", "=", "set", "(", "v", ")", "if", "set_u", ".", "isdisjoint", "(", "set_v", ")", ":", "raise", "ValueError", "(",...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
ClusterGraph.add_factors
Associate a factor to the graph. See factors class for the order of potential values Parameters ---------- *factor: pgmpy.factors.factors object A factor object on any subset of the variables of the model which is to be associated with the model. Returns...
pgmpy/models/ClusterGraph.py
def add_factors(self, *factors): """ Associate a factor to the graph. See factors class for the order of potential values Parameters ---------- *factor: pgmpy.factors.factors object A factor object on any subset of the variables of the model which ...
def add_factors(self, *factors): """ Associate a factor to the graph. See factors class for the order of potential values Parameters ---------- *factor: pgmpy.factors.factors object A factor object on any subset of the variables of the model which ...
[ "Associate", "a", "factor", "to", "the", "graph", ".", "See", "factors", "class", "for", "the", "order", "of", "potential", "values" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/ClusterGraph.py#L127-L159
[ "def", "add_factors", "(", "self", ",", "*", "factors", ")", ":", "for", "factor", "in", "factors", ":", "factor_scope", "=", "set", "(", "factor", ".", "scope", "(", ")", ")", "nodes", "=", "[", "set", "(", "node", ")", "for", "node", "in", "self"...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
ClusterGraph.get_factors
Return the factors that have been added till now to the graph. If node is not None, it would return the factor corresponding to the given node. Examples -------- >>> from pgmpy.models import ClusterGraph >>> from pgmpy.factors.discrete import DiscreteFactor >>> ...
pgmpy/models/ClusterGraph.py
def get_factors(self, node=None): """ Return the factors that have been added till now to the graph. If node is not None, it would return the factor corresponding to the given node. Examples -------- >>> from pgmpy.models import ClusterGraph >>> from pgm...
def get_factors(self, node=None): """ Return the factors that have been added till now to the graph. If node is not None, it would return the factor corresponding to the given node. Examples -------- >>> from pgmpy.models import ClusterGraph >>> from pgm...
[ "Return", "the", "factors", "that", "have", "been", "added", "till", "now", "to", "the", "graph", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/ClusterGraph.py#L161-L192
[ "def", "get_factors", "(", "self", ",", "node", "=", "None", ")", ":", "if", "node", "is", "None", ":", "return", "self", ".", "factors", "else", ":", "nodes", "=", "[", "set", "(", "n", ")", "for", "n", "in", "self", ".", "nodes", "(", ")", "]...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
ClusterGraph.get_cardinality
Returns the cardinality of the node Parameters ---------- node: any hashable python object (optional) The node whose cardinality we want. If node is not specified returns a dictionary with the given variable as keys and their respective cardinality as values....
pgmpy/models/ClusterGraph.py
def get_cardinality(self, node=None): """ Returns the cardinality of the node Parameters ---------- node: any hashable python object (optional) The node whose cardinality we want. If node is not specified returns a dictionary with the given variable as ke...
def get_cardinality(self, node=None): """ Returns the cardinality of the node Parameters ---------- node: any hashable python object (optional) The node whose cardinality we want. If node is not specified returns a dictionary with the given variable as ke...
[ "Returns", "the", "cardinality", "of", "the", "node" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/ClusterGraph.py#L211-L255
[ "def", "get_cardinality", "(", "self", ",", "node", "=", "None", ")", ":", "if", "node", ":", "for", "factor", "in", "self", ".", "factors", ":", "for", "variable", ",", "cardinality", "in", "zip", "(", "factor", ".", "scope", "(", ")", ",", "factor"...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
ClusterGraph.get_partition_function
r""" Returns the partition function for a given undirected graph. A partition function is defined as .. math:: \sum_{X}(\prod_{i=1}^{m} \phi_i) where m is the number of factors present in the graph and X are all the random variables present. Examples -------- ...
pgmpy/models/ClusterGraph.py
def get_partition_function(self): r""" Returns the partition function for a given undirected graph. A partition function is defined as .. math:: \sum_{X}(\prod_{i=1}^{m} \phi_i) where m is the number of factors present in the graph and X are all the random variables pr...
def get_partition_function(self): r""" Returns the partition function for a given undirected graph. A partition function is defined as .. math:: \sum_{X}(\prod_{i=1}^{m} \phi_i) where m is the number of factors present in the graph and X are all the random variables pr...
[ "r", "Returns", "the", "partition", "function", "for", "a", "given", "undirected", "graph", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/ClusterGraph.py#L257-L285
[ "def", "get_partition_function", "(", "self", ")", ":", "if", "self", ".", "check_model", "(", ")", ":", "factor", "=", "self", ".", "factors", "[", "0", "]", "factor", "=", "factor_product", "(", "factor", ",", "*", "[", "self", ".", "factors", "[", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
ClusterGraph.check_model
Check the model for various errors. This method checks for the following errors. * Checks if factors are defined for all the cliques or not. * Check for running intersection property is not done explicitly over here as it done in the add_edges method. * Checks if cardinality i...
pgmpy/models/ClusterGraph.py
def check_model(self): """ Check the model for various errors. This method checks for the following errors. * Checks if factors are defined for all the cliques or not. * Check for running intersection property is not done explicitly over here as it done in the add_edge...
def check_model(self): """ Check the model for various errors. This method checks for the following errors. * Checks if factors are defined for all the cliques or not. * Check for running intersection property is not done explicitly over here as it done in the add_edge...
[ "Check", "the", "model", "for", "various", "errors", ".", "This", "method", "checks", "for", "the", "following", "errors", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/ClusterGraph.py#L287-L320
[ "def", "check_model", "(", "self", ")", ":", "for", "clique", "in", "self", ".", "nodes", "(", ")", ":", "factors", "=", "filter", "(", "lambda", "x", ":", "set", "(", "x", ".", "scope", "(", ")", ")", "==", "set", "(", "clique", ")", ",", "sel...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
ClusterGraph.copy
Returns a copy of ClusterGraph. Returns ------- ClusterGraph: copy of ClusterGraph Examples ------- >>> from pgmpy.factors.discrete import DiscreteFactor >>> G = ClusterGraph() >>> G.add_nodes_from([('a', 'b'), ('b', 'c')]) >>> G.add_edge(('a', '...
pgmpy/models/ClusterGraph.py
def copy(self): """ Returns a copy of ClusterGraph. Returns ------- ClusterGraph: copy of ClusterGraph Examples ------- >>> from pgmpy.factors.discrete import DiscreteFactor >>> G = ClusterGraph() >>> G.add_nodes_from([('a', 'b'), ('b', '...
def copy(self): """ Returns a copy of ClusterGraph. Returns ------- ClusterGraph: copy of ClusterGraph Examples ------- >>> from pgmpy.factors.discrete import DiscreteFactor >>> G = ClusterGraph() >>> G.add_nodes_from([('a', 'b'), ('b', '...
[ "Returns", "a", "copy", "of", "ClusterGraph", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/ClusterGraph.py#L322-L352
[ "def", "copy", "(", "self", ")", ":", "copy", "=", "ClusterGraph", "(", "self", ".", "edges", "(", ")", ")", "if", "self", ".", "factors", ":", "factors_copy", "=", "[", "factor", ".", "copy", "(", ")", "for", "factor", "in", "self", ".", "factors"...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
Mplp._update_message
This is the message-update method. Parameters ---------- sending_cluster: The resulting messages are lambda_{c-->s} from the given cluster 'c' to all of its intersection_sets 's'. Here 's' are the elements of intersection_sets_for_cluster_c. Reference --...
pgmpy/inference/mplp.py
def _update_message(self, sending_cluster): """ This is the message-update method. Parameters ---------- sending_cluster: The resulting messages are lambda_{c-->s} from the given cluster 'c' to all of its intersection_sets 's'. Here 's' are the elements ...
def _update_message(self, sending_cluster): """ This is the message-update method. Parameters ---------- sending_cluster: The resulting messages are lambda_{c-->s} from the given cluster 'c' to all of its intersection_sets 's'. Here 's' are the elements ...
[ "This", "is", "the", "message", "-", "update", "method", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/inference/mplp.py#L144-L203
[ "def", "_update_message", "(", "self", ",", "sending_cluster", ")", ":", "# The new updates will take place for the intersection_sets of this cluster.", "# The new updates are:", "# \\delta_{f \\rightarrow i}(x_i) = - \\delta_i^{-f} +", "# 1/{\\| f \\|} max_{x_{f-i}}\\left[{\\theta_f(x_f) + \\...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
Mplp._local_decode
Finds the index of the maximum values for all the single node dual objectives. Reference: code presented by Sontag in 2012 here: http://cs.nyu.edu/~dsontag/code/README_v2.html
pgmpy/inference/mplp.py
def _local_decode(self): """ Finds the index of the maximum values for all the single node dual objectives. Reference: code presented by Sontag in 2012 here: http://cs.nyu.edu/~dsontag/code/README_v2.html """ # The current assignment of the single node factors is stored ...
def _local_decode(self): """ Finds the index of the maximum values for all the single node dual objectives. Reference: code presented by Sontag in 2012 here: http://cs.nyu.edu/~dsontag/code/README_v2.html """ # The current assignment of the single node factors is stored ...
[ "Finds", "the", "index", "of", "the", "maximum", "values", "for", "all", "the", "single", "node", "dual", "objectives", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/inference/mplp.py#L205-L229
[ "def", "_local_decode", "(", "self", ")", ":", "# The current assignment of the single node factors is stored in the form of a dictionary", "decoded_result_assignment", "=", "{", "node", ":", "np", ".", "argmax", "(", "self", ".", "objective", "[", "node", "]", ".", "va...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
Mplp._is_converged
This method checks the integrality gap to ensure either: * we have found a near to exact solution or * stuck on a local minima. Parameters ---------- dual_threshold: double This sets the minimum width between the dual objective decrements. If the ...
pgmpy/inference/mplp.py
def _is_converged(self, dual_threshold=None, integrality_gap_threshold=None): """ This method checks the integrality gap to ensure either: * we have found a near to exact solution or * stuck on a local minima. Parameters ---------- dual_threshold: double ...
def _is_converged(self, dual_threshold=None, integrality_gap_threshold=None): """ This method checks the integrality gap to ensure either: * we have found a near to exact solution or * stuck on a local minima. Parameters ---------- dual_threshold: double ...
[ "This", "method", "checks", "the", "integrality", "gap", "to", "ensure", "either", ":", "*", "we", "have", "found", "a", "near", "to", "exact", "solution", "or", "*", "stuck", "on", "a", "local", "minima", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/inference/mplp.py#L231-L268
[ "def", "_is_converged", "(", "self", ",", "dual_threshold", "=", "None", ",", "integrality_gap_threshold", "=", "None", ")", ":", "# Find the new objective after the message updates", "new_dual_lp", "=", "sum", "(", "[", "np", ".", "amax", "(", "self", ".", "objec...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
Mplp.find_triangles
Finds all the triangles present in the given model Examples -------- >>> from pgmpy.models import MarkovModel >>> from pgmpy.factors.discrete import DiscreteFactor >>> from pgmpy.inference import Mplp >>> mm = MarkovModel() >>> mm.add_nodes_from(['x1', 'x2', 'x3'...
pgmpy/inference/mplp.py
def find_triangles(self): """ Finds all the triangles present in the given model Examples -------- >>> from pgmpy.models import MarkovModel >>> from pgmpy.factors.discrete import DiscreteFactor >>> from pgmpy.inference import Mplp >>> mm = MarkovModel() ...
def find_triangles(self): """ Finds all the triangles present in the given model Examples -------- >>> from pgmpy.models import MarkovModel >>> from pgmpy.factors.discrete import DiscreteFactor >>> from pgmpy.inference import Mplp >>> mm = MarkovModel() ...
[ "Finds", "all", "the", "triangles", "present", "in", "the", "given", "model" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/inference/mplp.py#L270-L289
[ "def", "find_triangles", "(", "self", ")", ":", "return", "list", "(", "filter", "(", "lambda", "x", ":", "len", "(", "x", ")", "==", "3", ",", "nx", ".", "find_cliques", "(", "self", ".", "model", ")", ")", ")" ]
9381a66aba3c3871d3ccd00672b148d17d63239e
train
Mplp._update_triangles
From a set of variables forming a triangle in the model, we form the corresponding Clusters. These clusters are then appended to the code. Parameters ---------- triangle_list : list The list of variables forming the triangles to be updated. It is of the form of ...
pgmpy/inference/mplp.py
def _update_triangles(self, triangles_list): """ From a set of variables forming a triangle in the model, we form the corresponding Clusters. These clusters are then appended to the code. Parameters ---------- triangle_list : list The list of vari...
def _update_triangles(self, triangles_list): """ From a set of variables forming a triangle in the model, we form the corresponding Clusters. These clusters are then appended to the code. Parameters ---------- triangle_list : list The list of vari...
[ "From", "a", "set", "of", "variables", "forming", "a", "triangle", "in", "the", "model", "we", "form", "the", "corresponding", "Clusters", ".", "These", "clusters", "are", "then", "appended", "to", "the", "code", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/inference/mplp.py#L291-L314
[ "def", "_update_triangles", "(", "self", ",", "triangles_list", ")", ":", "new_intersection_set", "=", "[", "]", "for", "triangle_vars", "in", "triangles_list", ":", "cardinalities", "=", "[", "self", ".", "cardinality", "[", "variable", "]", "for", "variable", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
Mplp._get_triplet_scores
Returns the score of each of the triplets found in the current model Parameters --------- triangles_list: list The list of variables forming the triangles to be updated. It is of the form of [['var_5', 'var_8', 'var_7'], ['var_4', 'var_5', 'var_7'...
pgmpy/inference/mplp.py
def _get_triplet_scores(self, triangles_list): """ Returns the score of each of the triplets found in the current model Parameters --------- triangles_list: list The list of variables forming the triangles to be updated. It is of the form of ...
def _get_triplet_scores(self, triangles_list): """ Returns the score of each of the triplets found in the current model Parameters --------- triangles_list: list The list of variables forming the triangles to be updated. It is of the form of ...
[ "Returns", "the", "score", "of", "each", "of", "the", "triplets", "found", "in", "the", "current", "model" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/inference/mplp.py#L316-L346
[ "def", "_get_triplet_scores", "(", "self", ",", "triangles_list", ")", ":", "triplet_scores", "=", "{", "}", "for", "triplet", "in", "triangles_list", ":", "# Find the intersection sets of the current triplet", "triplet_intersections", "=", "[", "intersect", "for", "int...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
Mplp._run_mplp
Updates messages until either Mplp converges or if doesn't converges; halts after no_iterations. Parameters -------- no_iterations: integer Number of maximum iterations that we want MPLP to run.
pgmpy/inference/mplp.py
def _run_mplp(self, no_iterations): """ Updates messages until either Mplp converges or if doesn't converges; halts after no_iterations. Parameters -------- no_iterations: integer Number of maximum iterations that we want MPLP to run. """ ...
def _run_mplp(self, no_iterations): """ Updates messages until either Mplp converges or if doesn't converges; halts after no_iterations. Parameters -------- no_iterations: integer Number of maximum iterations that we want MPLP to run. """ ...
[ "Updates", "messages", "until", "either", "Mplp", "converges", "or", "if", "doesn", "t", "converges", ";", "halts", "after", "no_iterations", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/inference/mplp.py#L348-L367
[ "def", "_run_mplp", "(", "self", ",", "no_iterations", ")", ":", "for", "niter", "in", "range", "(", "no_iterations", ")", ":", "# We take the clusters in the order they were added in the model and update messages for all factors whose", "# scope is greater than 1", "for", "fac...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
Mplp._tighten_triplet
This method finds all the triplets that are eligible and adds them iteratively in the bunch of max_triplets Parameters ---------- max_iterations: integer Maximum number of times we tighten the relaxation later_iter: integer Number of maximum ...
pgmpy/inference/mplp.py
def _tighten_triplet(self, max_iterations, later_iter, max_triplets, prolong): """ This method finds all the triplets that are eligible and adds them iteratively in the bunch of max_triplets Parameters ---------- max_iterations: integer Maximum number of ...
def _tighten_triplet(self, max_iterations, later_iter, max_triplets, prolong): """ This method finds all the triplets that are eligible and adds them iteratively in the bunch of max_triplets Parameters ---------- max_iterations: integer Maximum number of ...
[ "This", "method", "finds", "all", "the", "triplets", "that", "are", "eligible", "and", "adds", "them", "iteratively", "in", "the", "bunch", "of", "max_triplets" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/inference/mplp.py#L369-L410
[ "def", "_tighten_triplet", "(", "self", ",", "max_iterations", ",", "later_iter", ",", "max_triplets", ",", "prolong", ")", ":", "# Find all the triplets that are possible in the present model", "triangles", "=", "self", ".", "find_triangles", "(", ")", "# Evaluate scores...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
Mplp.map_query
MAP query method using Max Product LP method. This returns the best assignment of the nodes in the form of a dictionary. Parameters ---------- init_iter: integer Number of maximum iterations that we want MPLP to run for the first time. later_iter: integer ...
pgmpy/inference/mplp.py
def map_query(self, init_iter=1000, later_iter=20, dual_threshold=0.0002, integrality_gap_threshold=0.0002, tighten_triplet=True, max_triplets=5, max_iterations=100, prolong=False): """ MAP query method using Max Product LP method. This returns the best assignment of the nodes ...
def map_query(self, init_iter=1000, later_iter=20, dual_threshold=0.0002, integrality_gap_threshold=0.0002, tighten_triplet=True, max_triplets=5, max_iterations=100, prolong=False): """ MAP query method using Max Product LP method. This returns the best assignment of the nodes ...
[ "MAP", "query", "method", "using", "Max", "Product", "LP", "method", ".", "This", "returns", "the", "best", "assignment", "of", "the", "nodes", "in", "the", "form", "of", "a", "dictionary", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/inference/mplp.py#L439-L519
[ "def", "map_query", "(", "self", ",", "init_iter", "=", "1000", ",", "later_iter", "=", "20", ",", "dual_threshold", "=", "0.0002", ",", "integrality_gap_threshold", "=", "0.0002", ",", "tighten_triplet", "=", "True", ",", "max_triplets", "=", "5", ",", "max...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
MarkovModel.add_edge
Add an edge between u and v. The nodes u and v will be automatically added if they are not already in the graph Parameters ---------- u,v : nodes Nodes can be any hashable Python object. Examples -------- >>> from pgmpy.models import MarkovM...
pgmpy/models/MarkovModel.py
def add_edge(self, u, v, **kwargs): """ Add an edge between u and v. The nodes u and v will be automatically added if they are not already in the graph Parameters ---------- u,v : nodes Nodes can be any hashable Python object. Examples ...
def add_edge(self, u, v, **kwargs): """ Add an edge between u and v. The nodes u and v will be automatically added if they are not already in the graph Parameters ---------- u,v : nodes Nodes can be any hashable Python object. Examples ...
[ "Add", "an", "edge", "between", "u", "and", "v", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/MarkovModel.py#L89-L112
[ "def", "add_edge", "(", "self", ",", "u", ",", "v", ",", "*", "*", "kwargs", ")", ":", "# check that there is no self loop.", "if", "u", "!=", "v", ":", "super", "(", "MarkovModel", ",", "self", ")", ".", "add_edge", "(", "u", ",", "v", ",", "*", "...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
MarkovModel.add_factors
Associate a factor to the graph. See factors class for the order of potential values Parameters ---------- *factor: pgmpy.factors.factors object A factor object on any subset of the variables of the model which is to be associated with the model. Returns...
pgmpy/models/MarkovModel.py
def add_factors(self, *factors): """ Associate a factor to the graph. See factors class for the order of potential values Parameters ---------- *factor: pgmpy.factors.factors object A factor object on any subset of the variables of the model which ...
def add_factors(self, *factors): """ Associate a factor to the graph. See factors class for the order of potential values Parameters ---------- *factor: pgmpy.factors.factors object A factor object on any subset of the variables of the model which ...
[ "Associate", "a", "factor", "to", "the", "graph", ".", "See", "factors", "class", "for", "the", "order", "of", "potential", "values" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/MarkovModel.py#L114-L145
[ "def", "add_factors", "(", "self", ",", "*", "factors", ")", ":", "for", "factor", "in", "factors", ":", "if", "set", "(", "factor", ".", "variables", ")", "-", "set", "(", "factor", ".", "variables", ")", ".", "intersection", "(", "set", "(", "self"...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
MarkovModel.get_factors
Returns all the factors containing the node. If node is not specified returns all the factors that have been added till now to the graph. Parameter --------- node: any hashable python object (optional) The node whose factor we want. If node is not specified Examples...
pgmpy/models/MarkovModel.py
def get_factors(self, node=None): """ Returns all the factors containing the node. If node is not specified returns all the factors that have been added till now to the graph. Parameter --------- node: any hashable python object (optional) The node whose fact...
def get_factors(self, node=None): """ Returns all the factors containing the node. If node is not specified returns all the factors that have been added till now to the graph. Parameter --------- node: any hashable python object (optional) The node whose fact...
[ "Returns", "all", "the", "factors", "containing", "the", "node", ".", "If", "node", "is", "not", "specified", "returns", "all", "the", "factors", "that", "have", "been", "added", "till", "now", "to", "the", "graph", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/MarkovModel.py#L147-L182
[ "def", "get_factors", "(", "self", ",", "node", "=", "None", ")", ":", "if", "node", ":", "if", "node", "not", "in", "self", ".", "nodes", "(", ")", ":", "raise", "ValueError", "(", "'Node not present in the Undirected Graph'", ")", "node_factors", "=", "[...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
MarkovModel.check_model
Check the model for various errors. This method checks for the following errors - * Checks if the cardinalities of all the variables are consistent across all the factors. * Factors are defined for all the random variables. Returns ------- check: boolean Tru...
pgmpy/models/MarkovModel.py
def check_model(self): """ Check the model for various errors. This method checks for the following errors - * Checks if the cardinalities of all the variables are consistent across all the factors. * Factors are defined for all the random variables. Returns ---...
def check_model(self): """ Check the model for various errors. This method checks for the following errors - * Checks if the cardinalities of all the variables are consistent across all the factors. * Factors are defined for all the random variables. Returns ---...
[ "Check", "the", "model", "for", "various", "errors", ".", "This", "method", "checks", "for", "the", "following", "errors", "-" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/MarkovModel.py#L239-L263
[ "def", "check_model", "(", "self", ")", ":", "cardinalities", "=", "self", ".", "get_cardinality", "(", ")", "for", "factor", "in", "self", ".", "factors", ":", "for", "variable", ",", "cardinality", "in", "zip", "(", "factor", ".", "scope", "(", ")", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
MarkovModel.to_factor_graph
Converts the markov model into factor graph. A factor graph contains two types of nodes. One type corresponds to random variables whereas the second type corresponds to factors over these variables. The graph only contains edges between variables and factor nodes. Each factor node is as...
pgmpy/models/MarkovModel.py
def to_factor_graph(self): """ Converts the markov model into factor graph. A factor graph contains two types of nodes. One type corresponds to random variables whereas the second type corresponds to factors over these variables. The graph only contains edges between variables a...
def to_factor_graph(self): """ Converts the markov model into factor graph. A factor graph contains two types of nodes. One type corresponds to random variables whereas the second type corresponds to factors over these variables. The graph only contains edges between variables a...
[ "Converts", "the", "markov", "model", "into", "factor", "graph", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/MarkovModel.py#L265-L298
[ "def", "to_factor_graph", "(", "self", ")", ":", "from", "pgmpy", ".", "models", "import", "FactorGraph", "factor_graph", "=", "FactorGraph", "(", ")", "if", "not", "self", ".", "factors", ":", "raise", "ValueError", "(", "'Factors not associated with the random v...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
MarkovModel.triangulate
Triangulate the graph. If order of deletion is given heuristic algorithm will not be used. Parameters ---------- heuristic: H1 | H2 | H3 | H4 | H5 | H6 The heuristic algorithm to use to decide the deletion order of the variables to compute the triangulated graph...
pgmpy/models/MarkovModel.py
def triangulate(self, heuristic='H6', order=None, inplace=False): """ Triangulate the graph. If order of deletion is given heuristic algorithm will not be used. Parameters ---------- heuristic: H1 | H2 | H3 | H4 | H5 | H6 The heuristic algorithm to use to de...
def triangulate(self, heuristic='H6', order=None, inplace=False): """ Triangulate the graph. If order of deletion is given heuristic algorithm will not be used. Parameters ---------- heuristic: H1 | H2 | H3 | H4 | H5 | H6 The heuristic algorithm to use to de...
[ "Triangulate", "the", "graph", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/MarkovModel.py#L300-L471
[ "def", "triangulate", "(", "self", ",", "heuristic", "=", "'H6'", ",", "order", "=", "None", ",", "inplace", "=", "False", ")", ":", "self", ".", "check_model", "(", ")", "if", "self", ".", "is_triangulated", "(", ")", ":", "if", "inplace", ":", "ret...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
MarkovModel.to_junction_tree
Creates a junction tree (or clique tree) for a given markov model. For a given markov model (H) a junction tree (G) is a graph 1. where each node in G corresponds to a maximal clique in H 2. each sepset in G separates the variables strictly on one side of the edge to other. Exa...
pgmpy/models/MarkovModel.py
def to_junction_tree(self): """ Creates a junction tree (or clique tree) for a given markov model. For a given markov model (H) a junction tree (G) is a graph 1. where each node in G corresponds to a maximal clique in H 2. each sepset in G separates the variables strictly on one...
def to_junction_tree(self): """ Creates a junction tree (or clique tree) for a given markov model. For a given markov model (H) a junction tree (G) is a graph 1. where each node in G corresponds to a maximal clique in H 2. each sepset in G separates the variables strictly on one...
[ "Creates", "a", "junction", "tree", "(", "or", "clique", "tree", ")", "for", "a", "given", "markov", "model", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/MarkovModel.py#L473-L561
[ "def", "to_junction_tree", "(", "self", ")", ":", "from", "pgmpy", ".", "models", "import", "JunctionTree", "# Check whether the model is valid or not", "self", ".", "check_model", "(", ")", "# Triangulate the graph to make it chordal", "triangulated_graph", "=", "self", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
MarkovModel.get_local_independencies
Returns all the local independencies present in the markov model. Local independencies are the independence assertion in the form of .. math:: {X \perp W - {X} - MB(X) | MB(X)} where MB is the markov blanket of all the random variables in X Parameters ---------- latex: ...
pgmpy/models/MarkovModel.py
def get_local_independencies(self, latex=False): """ Returns all the local independencies present in the markov model. Local independencies are the independence assertion in the form of .. math:: {X \perp W - {X} - MB(X) | MB(X)} where MB is the markov blanket of all the random ...
def get_local_independencies(self, latex=False): """ Returns all the local independencies present in the markov model. Local independencies are the independence assertion in the form of .. math:: {X \perp W - {X} - MB(X) | MB(X)} where MB is the markov blanket of all the random ...
[ "Returns", "all", "the", "local", "independencies", "present", "in", "the", "markov", "model", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/MarkovModel.py#L581-L621
[ "def", "get_local_independencies", "(", "self", ",", "latex", "=", "False", ")", ":", "local_independencies", "=", "Independencies", "(", ")", "all_vars", "=", "set", "(", "self", ".", "nodes", "(", ")", ")", "for", "node", "in", "self", ".", "nodes", "(...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
MarkovModel.to_bayesian_model
Creates a Bayesian Model which is a minimum I-Map for this markov model. The ordering of parents may not remain constant. It would depend on the ordering of variable in the junction tree (which is not constant) all the time. Examples -------- >>> from pgmpy.models impor...
pgmpy/models/MarkovModel.py
def to_bayesian_model(self): """ Creates a Bayesian Model which is a minimum I-Map for this markov model. The ordering of parents may not remain constant. It would depend on the ordering of variable in the junction tree (which is not constant) all the time. Examples ...
def to_bayesian_model(self): """ Creates a Bayesian Model which is a minimum I-Map for this markov model. The ordering of parents may not remain constant. It would depend on the ordering of variable in the junction tree (which is not constant) all the time. Examples ...
[ "Creates", "a", "Bayesian", "Model", "which", "is", "a", "minimum", "I", "-", "Map", "for", "this", "markov", "model", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/MarkovModel.py#L623-L677
[ "def", "to_bayesian_model", "(", "self", ")", ":", "from", "pgmpy", ".", "models", "import", "BayesianModel", "bm", "=", "BayesianModel", "(", ")", "var_clique_dict", "=", "defaultdict", "(", "tuple", ")", "var_order", "=", "[", "]", "# Create a junction tree fr...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
MarkovModel.get_partition_function
Returns the partition function for a given undirected graph. A partition function is defined as .. math:: \sum_{X}(\prod_{i=1}^{m} \phi_i) where m is the number of factors present in the graph and X are all the random variables present. Examples -------- >>> f...
pgmpy/models/MarkovModel.py
def get_partition_function(self): """ Returns the partition function for a given undirected graph. A partition function is defined as .. math:: \sum_{X}(\prod_{i=1}^{m} \phi_i) where m is the number of factors present in the graph and X are all the random variables pre...
def get_partition_function(self): """ Returns the partition function for a given undirected graph. A partition function is defined as .. math:: \sum_{X}(\prod_{i=1}^{m} \phi_i) where m is the number of factors present in the graph and X are all the random variables pre...
[ "Returns", "the", "partition", "function", "for", "a", "given", "undirected", "graph", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/MarkovModel.py#L679-L711
[ "def", "get_partition_function", "(", "self", ")", ":", "self", ".", "check_model", "(", ")", "factor", "=", "self", ".", "factors", "[", "0", "]", "factor", "=", "factor_product", "(", "factor", ",", "*", "[", "self", ".", "factors", "[", "i", "]", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
MarkovModel.copy
Returns a copy of this Markov Model. Returns ------- MarkovModel: Copy of this Markov model. Examples ------- >>> from pgmpy.factors.discrete import DiscreteFactor >>> from pgmpy.models import MarkovModel >>> G = MarkovModel() >>> G.add_nodes_fro...
pgmpy/models/MarkovModel.py
def copy(self): """ Returns a copy of this Markov Model. Returns ------- MarkovModel: Copy of this Markov model. Examples ------- >>> from pgmpy.factors.discrete import DiscreteFactor >>> from pgmpy.models import MarkovModel >>> G = Marko...
def copy(self): """ Returns a copy of this Markov Model. Returns ------- MarkovModel: Copy of this Markov model. Examples ------- >>> from pgmpy.factors.discrete import DiscreteFactor >>> from pgmpy.models import MarkovModel >>> G = Marko...
[ "Returns", "a", "copy", "of", "this", "Markov", "Model", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/MarkovModel.py#L713-L748
[ "def", "copy", "(", "self", ")", ":", "clone_graph", "=", "MarkovModel", "(", "self", ".", "edges", "(", ")", ")", "clone_graph", ".", "add_nodes_from", "(", "self", ".", "nodes", "(", ")", ")", "if", "self", ".", "factors", ":", "factors_copy", "=", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
GaussianDistribution.pdf
Returns the probability density function(pdf). Returns ------- function: The probability density function of the distribution. Examples -------- >>> from pgmpy.factors.distributions import GaussianDistribution >>> dist = GD(variables=['x1', 'x2', 'x3'], ...
pgmpy/factors/distributions/GaussianDistribution.py
def pdf(self): """ Returns the probability density function(pdf). Returns ------- function: The probability density function of the distribution. Examples -------- >>> from pgmpy.factors.distributions import GaussianDistribution >>> dist = GD(var...
def pdf(self): """ Returns the probability density function(pdf). Returns ------- function: The probability density function of the distribution. Examples -------- >>> from pgmpy.factors.distributions import GaussianDistribution >>> dist = GD(var...
[ "Returns", "the", "probability", "density", "function", "(", "pdf", ")", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/distributions/GaussianDistribution.py#L73-L95
[ "def", "pdf", "(", "self", ")", ":", "return", "lambda", "*", "args", ":", "multivariate_normal", ".", "pdf", "(", "args", ",", "self", ".", "mean", ".", "reshape", "(", "1", ",", "len", "(", "self", ".", "variables", ")", ")", "[", "0", "]", ","...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
GaussianDistribution.precision_matrix
Returns the precision matrix of the distribution. Precision is defined as the inverse of the variance. This method returns the inverse matrix of the covariance. Examples -------- >>> import numpy as np >>> from pgmpy.factors.distributions import GaussianDistribution as ...
pgmpy/factors/distributions/GaussianDistribution.py
def precision_matrix(self): """ Returns the precision matrix of the distribution. Precision is defined as the inverse of the variance. This method returns the inverse matrix of the covariance. Examples -------- >>> import numpy as np >>> from pgmpy.facto...
def precision_matrix(self): """ Returns the precision matrix of the distribution. Precision is defined as the inverse of the variance. This method returns the inverse matrix of the covariance. Examples -------- >>> import numpy as np >>> from pgmpy.facto...
[ "Returns", "the", "precision", "matrix", "of", "the", "distribution", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/distributions/GaussianDistribution.py#L126-L149
[ "def", "precision_matrix", "(", "self", ")", ":", "if", "self", ".", "_precision_matrix", "is", "None", ":", "self", ".", "_precision_matrix", "=", "np", ".", "linalg", ".", "inv", "(", "self", ".", "covariance", ")", "return", "self", ".", "_precision_mat...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
GaussianDistribution.marginalize
Modifies the distribution with marginalized values. Parameters ---------- variables: iterator over any hashable object. List of variables over which marginalization is to be done. inplace: boolean If inplace=True it will modify the distribution itself, ...
pgmpy/factors/distributions/GaussianDistribution.py
def marginalize(self, variables, inplace=True): """ Modifies the distribution with marginalized values. Parameters ---------- variables: iterator over any hashable object. List of variables over which marginalization is to be done. inplace: boolean ...
def marginalize(self, variables, inplace=True): """ Modifies the distribution with marginalized values. Parameters ---------- variables: iterator over any hashable object. List of variables over which marginalization is to be done. inplace: boolean ...
[ "Modifies", "the", "distribution", "with", "marginalized", "values", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/distributions/GaussianDistribution.py#L151-L216
[ "def", "marginalize", "(", "self", ",", "variables", ",", "inplace", "=", "True", ")", ":", "if", "not", "isinstance", "(", "variables", ",", "list", ")", ":", "raise", "TypeError", "(", "\"variables: Expected type list or array-like,\"", "\"got type {var_type}\"", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
GaussianDistribution.reduce
Reduces the distribution to the context of the given variable values. The formula for the obtained conditional distribution is given by - For, .. math:: N(X_j | X_i = x_i) ~ N(mu_{j.i} ; sig_{j.i}) where, .. math:: mu_{j.i} = mu_j + sig_{j, i} * {sig_{i, i}^{-1}} * (x_i - mu_i...
pgmpy/factors/distributions/GaussianDistribution.py
def reduce(self, values, inplace=True): """ Reduces the distribution to the context of the given variable values. The formula for the obtained conditional distribution is given by - For, .. math:: N(X_j | X_i = x_i) ~ N(mu_{j.i} ; sig_{j.i}) where, .. math:: mu...
def reduce(self, values, inplace=True): """ Reduces the distribution to the context of the given variable values. The formula for the obtained conditional distribution is given by - For, .. math:: N(X_j | X_i = x_i) ~ N(mu_{j.i} ; sig_{j.i}) where, .. math:: mu...
[ "Reduces", "the", "distribution", "to", "the", "context", "of", "the", "given", "variable", "values", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/distributions/GaussianDistribution.py#L218-L307
[ "def", "reduce", "(", "self", ",", "values", ",", "inplace", "=", "True", ")", ":", "if", "not", "isinstance", "(", "values", ",", "list", ")", ":", "raise", "TypeError", "(", "\"values: Expected type list or array-like, \"", ",", "\"got type {var_type}\"", ".",...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
GaussianDistribution.normalize
Normalizes the distribution. In case of a Gaussian Distribution the distribution is always normalized, therefore this method doesn't do anything and has been implemented only for a consistent API across distributions.
pgmpy/factors/distributions/GaussianDistribution.py
def normalize(self, inplace=True): """ Normalizes the distribution. In case of a Gaussian Distribution the distribution is always normalized, therefore this method doesn't do anything and has been implemented only for a consistent API across distributions. """ phi...
def normalize(self, inplace=True): """ Normalizes the distribution. In case of a Gaussian Distribution the distribution is always normalized, therefore this method doesn't do anything and has been implemented only for a consistent API across distributions. """ phi...
[ "Normalizes", "the", "distribution", ".", "In", "case", "of", "a", "Gaussian", "Distribution", "the", "distribution", "is", "always", "normalized", "therefore", "this", "method", "doesn", "t", "do", "anything", "and", "has", "been", "implemented", "only", "for",...
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/distributions/GaussianDistribution.py#L309-L321
[ "def", "normalize", "(", "self", ",", "inplace", "=", "True", ")", ":", "phi", "=", "self", "if", "inplace", "else", "self", ".", "copy", "(", ")", "# The pdf of a Joint Gaussian distrinution is always", "# normalized. Hence, no changes.", "if", "not", "inplace", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
GaussianDistribution.copy
Return a copy of the distribution. Returns ------- GaussianDistribution: copy of the distribution Examples -------- >>> import numpy as np >>> from pgmpy.factors.distributions import GaussianDistribution as GD >>> gauss_dis = GD(variables=['x1', 'x2', 'x...
pgmpy/factors/distributions/GaussianDistribution.py
def copy(self): """ Return a copy of the distribution. Returns ------- GaussianDistribution: copy of the distribution Examples -------- >>> import numpy as np >>> from pgmpy.factors.distributions import GaussianDistribution as GD >>> gaus...
def copy(self): """ Return a copy of the distribution. Returns ------- GaussianDistribution: copy of the distribution Examples -------- >>> import numpy as np >>> from pgmpy.factors.distributions import GaussianDistribution as GD >>> gaus...
[ "Return", "a", "copy", "of", "the", "distribution", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/distributions/GaussianDistribution.py#L323-L362
[ "def", "copy", "(", "self", ")", ":", "copy_distribution", "=", "GaussianDistribution", "(", "variables", "=", "self", ".", "variables", ",", "mean", "=", "self", ".", "mean", ".", "copy", "(", ")", ",", "cov", "=", "self", ".", "covariance", ".", "cop...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
GaussianDistribution.to_canonical_factor
u""" Returns an equivalent CanonicalDistribution object. The formulas for calculating the cannonical factor parameters for N(μ; Σ) = C(K; h; g) are as follows - K = sigma^(-1) h = sigma^(-1) * mu g = -(0.5) * mu.T * sigma^(-1) * mu - log((2*pi)^(n/2) * det(s...
pgmpy/factors/distributions/GaussianDistribution.py
def to_canonical_factor(self): u""" Returns an equivalent CanonicalDistribution object. The formulas for calculating the cannonical factor parameters for N(μ; Σ) = C(K; h; g) are as follows - K = sigma^(-1) h = sigma^(-1) * mu g = -(0.5) * mu.T * sigma^(-1) * mu...
def to_canonical_factor(self): u""" Returns an equivalent CanonicalDistribution object. The formulas for calculating the cannonical factor parameters for N(μ; Σ) = C(K; h; g) are as follows - K = sigma^(-1) h = sigma^(-1) * mu g = -(0.5) * mu.T * sigma^(-1) * mu...
[ "u", "Returns", "an", "equivalent", "CanonicalDistribution", "object", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/distributions/GaussianDistribution.py#L364-L419
[ "def", "to_canonical_factor", "(", "self", ")", ":", "from", "pgmpy", ".", "factors", ".", "continuous", "import", "CanonicalDistribution", "mu", "=", "self", ".", "mean", "sigma", "=", "self", ".", "covariance", "K", "=", "self", ".", "precision_matrix", "h...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
GaussianDistribution._operate
Gives the CanonicalDistribution operation (product or divide) with the other factor. Parameters ---------- other: CanonicalDistribution The CanonicalDistribution to be multiplied. operation: String 'product' for multiplication operation and '...
pgmpy/factors/distributions/GaussianDistribution.py
def _operate(self, other, operation, inplace=True): """ Gives the CanonicalDistribution operation (product or divide) with the other factor. Parameters ---------- other: CanonicalDistribution The CanonicalDistribution to be multiplied. operation: Str...
def _operate(self, other, operation, inplace=True): """ Gives the CanonicalDistribution operation (product or divide) with the other factor. Parameters ---------- other: CanonicalDistribution The CanonicalDistribution to be multiplied. operation: Str...
[ "Gives", "the", "CanonicalDistribution", "operation", "(", "product", "or", "divide", ")", "with", "the", "other", "factor", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/distributions/GaussianDistribution.py#L421-L464
[ "def", "_operate", "(", "self", ",", "other", ",", "operation", ",", "inplace", "=", "True", ")", ":", "phi", "=", "self", ".", "to_canonical_factor", "(", ")", ".", "_operate", "(", "other", ".", "to_canonical_factor", "(", ")", ",", "operation", ",", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
GaussianDistribution.product
TODO: Make it work when using `*` instead of product. Returns the product of two gaussian distributions. Parameters ---------- other: GaussianDistribution The GaussianDistribution to be multiplied. inplace: boolean If True, modifies the distribution its...
pgmpy/factors/distributions/GaussianDistribution.py
def product(self, other, inplace=True): """ TODO: Make it work when using `*` instead of product. Returns the product of two gaussian distributions. Parameters ---------- other: GaussianDistribution The GaussianDistribution to be multiplied. inplace...
def product(self, other, inplace=True): """ TODO: Make it work when using `*` instead of product. Returns the product of two gaussian distributions. Parameters ---------- other: GaussianDistribution The GaussianDistribution to be multiplied. inplace...
[ "TODO", ":", "Make", "it", "work", "when", "using", "*", "instead", "of", "product", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/distributions/GaussianDistribution.py#L466-L506
[ "def", "product", "(", "self", ",", "other", ",", "inplace", "=", "True", ")", ":", "return", "self", ".", "_operate", "(", "other", ",", "operation", "=", "'product'", ",", "inplace", "=", "inplace", ")" ]
9381a66aba3c3871d3ccd00672b148d17d63239e
train
GaussianDistribution.divide
Returns the division of two gaussian distributions. Parameters ---------- other: GaussianDistribution The GaussianDistribution to be divided. inplace: boolean If True, modifies the distribution itself, otherwise returns a new GaussianDistribution obj...
pgmpy/factors/distributions/GaussianDistribution.py
def divide(self, other, inplace=True): """ Returns the division of two gaussian distributions. Parameters ---------- other: GaussianDistribution The GaussianDistribution to be divided. inplace: boolean If True, modifies the distribution itself, o...
def divide(self, other, inplace=True): """ Returns the division of two gaussian distributions. Parameters ---------- other: GaussianDistribution The GaussianDistribution to be divided. inplace: boolean If True, modifies the distribution itself, o...
[ "Returns", "the", "division", "of", "two", "gaussian", "distributions", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/distributions/GaussianDistribution.py#L508-L546
[ "def", "divide", "(", "self", ",", "other", ",", "inplace", "=", "True", ")", ":", "return", "self", ".", "_operate", "(", "other", ",", "operation", "=", "'divide'", ",", "inplace", "=", "inplace", ")" ]
9381a66aba3c3871d3ccd00672b148d17d63239e
train
CustomDistribution.discretize
Discretizes the continuous distribution into discrete probability masses using specified method. Parameters ---------- method: string, BaseDiscretizer instance A Discretizer Class from pgmpy.factors.discretize *args, **kwargs: values The parameters to be...
pgmpy/factors/distributions/CustomDistribution.py
def discretize(self, method, *args, **kwargs): """ Discretizes the continuous distribution into discrete probability masses using specified method. Parameters ---------- method: string, BaseDiscretizer instance A Discretizer Class from pgmpy.factors.discretiz...
def discretize(self, method, *args, **kwargs): """ Discretizes the continuous distribution into discrete probability masses using specified method. Parameters ---------- method: string, BaseDiscretizer instance A Discretizer Class from pgmpy.factors.discretiz...
[ "Discretizes", "the", "continuous", "distribution", "into", "discrete", "probability", "masses", "using", "specified", "method", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/distributions/CustomDistribution.py#L151-L182
[ "def", "discretize", "(", "self", ",", "method", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "super", "(", "CustomDistribution", ",", "self", ")", ".", "discretize", "(", "method", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
9381a66aba3c3871d3ccd00672b148d17d63239e
train
CustomDistribution.reduce
Reduces the factor to the context of the given variable values. Parameters ---------- values: list, array-like A list of tuples of the form (variable_name, variable_value). inplace: boolean If inplace=True it will modify the factor itself, else would return ...
pgmpy/factors/distributions/CustomDistribution.py
def reduce(self, values, inplace=True): """ Reduces the factor to the context of the given variable values. Parameters ---------- values: list, array-like A list of tuples of the form (variable_name, variable_value). inplace: boolean If inplace=T...
def reduce(self, values, inplace=True): """ Reduces the factor to the context of the given variable values. Parameters ---------- values: list, array-like A list of tuples of the form (variable_name, variable_value). inplace: boolean If inplace=T...
[ "Reduces", "the", "factor", "to", "the", "context", "of", "the", "given", "variable", "values", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/distributions/CustomDistribution.py#L184-L258
[ "def", "reduce", "(", "self", ",", "values", ",", "inplace", "=", "True", ")", ":", "if", "not", "isinstance", "(", "values", ",", "(", "list", ",", "tuple", ",", "np", ".", "ndarray", ")", ")", ":", "raise", "TypeError", "(", "\"variables: Expected ty...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
CustomDistribution.marginalize
Marginalize the distribution with respect to the given variables. Parameters ---------- variables: list, array-like List of variables to be removed from the marginalized distribution. inplace: boolean If inplace=True it will modify the factor itself, else would ...
pgmpy/factors/distributions/CustomDistribution.py
def marginalize(self, variables, inplace=True): """ Marginalize the distribution with respect to the given variables. Parameters ---------- variables: list, array-like List of variables to be removed from the marginalized distribution. inplace: boolean ...
def marginalize(self, variables, inplace=True): """ Marginalize the distribution with respect to the given variables. Parameters ---------- variables: list, array-like List of variables to be removed from the marginalized distribution. inplace: boolean ...
[ "Marginalize", "the", "distribution", "with", "respect", "to", "the", "given", "variables", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/distributions/CustomDistribution.py#L260-L330
[ "def", "marginalize", "(", "self", ",", "variables", ",", "inplace", "=", "True", ")", ":", "if", "len", "(", "variables", ")", "==", "0", ":", "raise", "ValueError", "(", "\"Shouldn't be calling marginalize over no variable.\"", ")", "if", "not", "isinstance", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
CustomDistribution.normalize
Normalizes the pdf of the distribution so that it integrates to 1 over all the variables. Parameters ---------- inplace: boolean If inplace=True it will modify the distribution itself, else would return a new distribution. Returns ------- ...
pgmpy/factors/distributions/CustomDistribution.py
def normalize(self, inplace=True): """ Normalizes the pdf of the distribution so that it integrates to 1 over all the variables. Parameters ---------- inplace: boolean If inplace=True it will modify the distribution itself, else would return a new...
def normalize(self, inplace=True): """ Normalizes the pdf of the distribution so that it integrates to 1 over all the variables. Parameters ---------- inplace: boolean If inplace=True it will modify the distribution itself, else would return a new...
[ "Normalizes", "the", "pdf", "of", "the", "distribution", "so", "that", "it", "integrates", "to", "1", "over", "all", "the", "variables", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/distributions/CustomDistribution.py#L332-L371
[ "def", "normalize", "(", "self", ",", "inplace", "=", "True", ")", ":", "phi", "=", "self", "if", "inplace", "else", "self", ".", "copy", "(", ")", "pdf", "=", "self", ".", "pdf", "pdf_mod", "=", "integrate", ".", "nquad", "(", "pdf", ",", "[", "...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
CustomDistribution._operate
Gives the CustomDistribution operation (product or divide) with the other distribution. Parameters ---------- other: CustomDistribution The CustomDistribution to be multiplied. operation: str 'product' for multiplication operation and 'divide' for ...
pgmpy/factors/distributions/CustomDistribution.py
def _operate(self, other, operation, inplace=True): """ Gives the CustomDistribution operation (product or divide) with the other distribution. Parameters ---------- other: CustomDistribution The CustomDistribution to be multiplied. operation: str ...
def _operate(self, other, operation, inplace=True): """ Gives the CustomDistribution operation (product or divide) with the other distribution. Parameters ---------- other: CustomDistribution The CustomDistribution to be multiplied. operation: str ...
[ "Gives", "the", "CustomDistribution", "operation", "(", "product", "or", "divide", ")", "with", "the", "other", "distribution", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/distributions/CustomDistribution.py#L376-L426
[ "def", "_operate", "(", "self", ",", "other", ",", "operation", ",", "inplace", "=", "True", ")", ":", "if", "not", "isinstance", "(", "other", ",", "CustomDistribution", ")", ":", "raise", "TypeError", "(", "\"CustomDistribution objects can only be multiplied \""...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
VariableElimination._variable_elimination
Implementation of a generalized variable elimination. Parameters ---------- variables: list, array-like variables that are not to be eliminated. operation: str ('marginalize' | 'maximize') The operation to do for eliminating the variable. evidence: dict ...
pgmpy/inference/ExactInference.py
def _variable_elimination(self, variables, operation, evidence=None, elimination_order=None, joint=True): """ Implementation of a generalized variable elimination. Parameters ---------- variables: list, array-like variables that are not to be eliminated. oper...
def _variable_elimination(self, variables, operation, evidence=None, elimination_order=None, joint=True): """ Implementation of a generalized variable elimination. Parameters ---------- variables: list, array-like variables that are not to be eliminated. oper...
[ "Implementation", "of", "a", "generalized", "variable", "elimination", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/inference/ExactInference.py#L19-L107
[ "def", "_variable_elimination", "(", "self", ",", "variables", ",", "operation", ",", "evidence", "=", "None", ",", "elimination_order", "=", "None", ",", "joint", "=", "True", ")", ":", "if", "isinstance", "(", "variables", ",", "string_types", ")", ":", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
VariableElimination.query
Parameters ---------- variables: list list of variables for which you want to compute the probability evidence: dict a dict key, value pair as {var: state_of_var_observed} None if no evidence elimination_order: list order of variable elim...
pgmpy/inference/ExactInference.py
def query(self, variables, evidence=None, elimination_order=None, joint=True): """ Parameters ---------- variables: list list of variables for which you want to compute the probability evidence: dict a dict key, value pair as {var: state_of_var_observed} ...
def query(self, variables, evidence=None, elimination_order=None, joint=True): """ Parameters ---------- variables: list list of variables for which you want to compute the probability evidence: dict a dict key, value pair as {var: state_of_var_observed} ...
[ "Parameters", "----------", "variables", ":", "list", "list", "of", "variables", "for", "which", "you", "want", "to", "compute", "the", "probability" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/inference/ExactInference.py#L109-L143
[ "def", "query", "(", "self", ",", "variables", ",", "evidence", "=", "None", ",", "elimination_order", "=", "None", ",", "joint", "=", "True", ")", ":", "return", "self", ".", "_variable_elimination", "(", "variables", ",", "'marginalize'", ",", "evidence", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
VariableElimination.max_marginal
Computes the max-marginal over the variables given the evidence. Parameters ---------- variables: list list of variables over which we want to compute the max-marginal. evidence: dict a dict key, value pair as {var: state_of_var_observed} None if no e...
pgmpy/inference/ExactInference.py
def max_marginal(self, variables=None, evidence=None, elimination_order=None): """ Computes the max-marginal over the variables given the evidence. Parameters ---------- variables: list list of variables over which we want to compute the max-marginal. evidenc...
def max_marginal(self, variables=None, evidence=None, elimination_order=None): """ Computes the max-marginal over the variables given the evidence. Parameters ---------- variables: list list of variables over which we want to compute the max-marginal. evidenc...
[ "Computes", "the", "max", "-", "marginal", "over", "the", "variables", "given", "the", "evidence", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/inference/ExactInference.py#L145-L179
[ "def", "max_marginal", "(", "self", ",", "variables", "=", "None", ",", "evidence", "=", "None", ",", "elimination_order", "=", "None", ")", ":", "if", "not", "variables", ":", "variables", "=", "[", "]", "final_distribution", "=", "self", ".", "_variable_...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
VariableElimination.map_query
Computes the MAP Query over the variables given the evidence. Note: When multiple variables are passed, it returns the map_query for each of them individually. Parameters ---------- variables: list list of variables over which we want to compute the max-marginal. ...
pgmpy/inference/ExactInference.py
def map_query(self, variables=None, evidence=None, elimination_order=None): """ Computes the MAP Query over the variables given the evidence. Note: When multiple variables are passed, it returns the map_query for each of them individually. Parameters ---------- ...
def map_query(self, variables=None, evidence=None, elimination_order=None): """ Computes the MAP Query over the variables given the evidence. Note: When multiple variables are passed, it returns the map_query for each of them individually. Parameters ---------- ...
[ "Computes", "the", "MAP", "Query", "over", "the", "variables", "given", "the", "evidence", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/inference/ExactInference.py#L182-L231
[ "def", "map_query", "(", "self", ",", "variables", "=", "None", ",", "evidence", "=", "None", ",", "elimination_order", "=", "None", ")", ":", "# TODO:Check the note in docstring. Change that behavior to return the joint MAP", "final_distribution", "=", "self", ".", "_v...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
VariableElimination.induced_graph
Returns the induced graph formed by running Variable Elimination on the network. Parameters ---------- elimination_order: list, array like List of variables in the order in which they are to be eliminated. Examples -------- >>> import numpy as np >>>...
pgmpy/inference/ExactInference.py
def induced_graph(self, elimination_order): """ Returns the induced graph formed by running Variable Elimination on the network. Parameters ---------- elimination_order: list, array like List of variables in the order in which they are to be eliminated. Exam...
def induced_graph(self, elimination_order): """ Returns the induced graph formed by running Variable Elimination on the network. Parameters ---------- elimination_order: list, array like List of variables in the order in which they are to be eliminated. Exam...
[ "Returns", "the", "induced", "graph", "formed", "by", "running", "Variable", "Elimination", "on", "the", "network", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/inference/ExactInference.py#L233-L285
[ "def", "induced_graph", "(", "self", ",", "elimination_order", ")", ":", "# If the elimination order does not contain the same variables as the model", "if", "set", "(", "elimination_order", ")", "!=", "set", "(", "self", ".", "variables", ")", ":", "raise", "ValueError...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
VariableElimination.induced_width
Returns the width (integer) of the induced graph formed by running Variable Elimination on the network. The width is the defined as the number of nodes in the largest clique in the graph minus 1. Parameters ---------- elimination_order: list, array like List of variables in ...
pgmpy/inference/ExactInference.py
def induced_width(self, elimination_order): """ Returns the width (integer) of the induced graph formed by running Variable Elimination on the network. The width is the defined as the number of nodes in the largest clique in the graph minus 1. Parameters ---------- elimi...
def induced_width(self, elimination_order): """ Returns the width (integer) of the induced graph formed by running Variable Elimination on the network. The width is the defined as the number of nodes in the largest clique in the graph minus 1. Parameters ---------- elimi...
[ "Returns", "the", "width", "(", "integer", ")", "of", "the", "induced", "graph", "formed", "by", "running", "Variable", "Elimination", "on", "the", "network", ".", "The", "width", "is", "the", "defined", "as", "the", "number", "of", "nodes", "in", "the", ...
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/inference/ExactInference.py#L287-L312
[ "def", "induced_width", "(", "self", ",", "elimination_order", ")", ":", "induced_graph", "=", "self", ".", "induced_graph", "(", "elimination_order", ")", "return", "nx", ".", "graph_clique_number", "(", "induced_graph", ")", "-", "1" ]
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BeliefPropagation._update_beliefs
This is belief-update method. Parameters ---------- sending_clique: node (as the operation is on junction tree, node should be a tuple) Node sending the message recieving_clique: node (as the operation is on junction tree, node should be a tuple) Node recieving t...
pgmpy/inference/ExactInference.py
def _update_beliefs(self, sending_clique, recieving_clique, operation): """ This is belief-update method. Parameters ---------- sending_clique: node (as the operation is on junction tree, node should be a tuple) Node sending the message recieving_clique: node...
def _update_beliefs(self, sending_clique, recieving_clique, operation): """ This is belief-update method. Parameters ---------- sending_clique: node (as the operation is on junction tree, node should be a tuple) Node sending the message recieving_clique: node...
[ "This", "is", "belief", "-", "update", "method", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/inference/ExactInference.py#L360-L389
[ "def", "_update_beliefs", "(", "self", ",", "sending_clique", ",", "recieving_clique", ",", "operation", ")", ":", "sepset", "=", "frozenset", "(", "sending_clique", ")", ".", "intersection", "(", "frozenset", "(", "recieving_clique", ")", ")", "sepset_key", "="...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BeliefPropagation._is_converged
Checks whether the calibration has converged or not. At convergence the sepset belief would be precisely the sepset marginal. Parameters ---------- operation: str ('marginalize' | 'maximize') The operation to do for passing messages between nodes. if operation ==...
pgmpy/inference/ExactInference.py
def _is_converged(self, operation): """ Checks whether the calibration has converged or not. At convergence the sepset belief would be precisely the sepset marginal. Parameters ---------- operation: str ('marginalize' | 'maximize') The operation to do for pas...
def _is_converged(self, operation): """ Checks whether the calibration has converged or not. At convergence the sepset belief would be precisely the sepset marginal. Parameters ---------- operation: str ('marginalize' | 'maximize') The operation to do for pas...
[ "Checks", "whether", "the", "calibration", "has", "converged", "or", "not", ".", "At", "convergence", "the", "sepset", "belief", "would", "be", "precisely", "the", "sepset", "marginal", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/inference/ExactInference.py#L391-L428
[ "def", "_is_converged", "(", "self", ",", "operation", ")", ":", "# If no clique belief, then the clique tree is not calibrated", "if", "not", "self", ".", "clique_beliefs", ":", "return", "False", "for", "edge", "in", "self", ".", "junction_tree", ".", "edges", "("...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BeliefPropagation._calibrate_junction_tree
Generalized calibration of junction tree or clique using belief propagation. This method can be used for both calibrating as well as max-calibrating. Uses Lauritzen-Spiegelhalter algorithm or belief-update message passing. Parameters ---------- operation: str ('marginalize' | 'm...
pgmpy/inference/ExactInference.py
def _calibrate_junction_tree(self, operation): """ Generalized calibration of junction tree or clique using belief propagation. This method can be used for both calibrating as well as max-calibrating. Uses Lauritzen-Spiegelhalter algorithm or belief-update message passing. Param...
def _calibrate_junction_tree(self, operation): """ Generalized calibration of junction tree or clique using belief propagation. This method can be used for both calibrating as well as max-calibrating. Uses Lauritzen-Spiegelhalter algorithm or belief-update message passing. Param...
[ "Generalized", "calibration", "of", "junction", "tree", "or", "clique", "using", "belief", "propagation", ".", "This", "method", "can", "be", "used", "for", "both", "calibrating", "as", "well", "as", "max", "-", "calibrating", ".", "Uses", "Lauritzen", "-", ...
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/inference/ExactInference.py#L430-L465
[ "def", "_calibrate_junction_tree", "(", "self", ",", "operation", ")", ":", "# Initialize clique beliefs as well as sepset beliefs", "self", ".", "clique_beliefs", "=", "{", "clique", ":", "self", ".", "junction_tree", ".", "get_factors", "(", "clique", ")", "for", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BeliefPropagation._query
This is a generalized query method that can be used for both query and map query. Parameters ---------- variables: list list of variables for which you want to compute the probability operation: str ('marginalize' | 'maximize') The operation to do for passing mes...
pgmpy/inference/ExactInference.py
def _query(self, variables, operation, evidence=None, joint=True): """ This is a generalized query method that can be used for both query and map query. Parameters ---------- variables: list list of variables for which you want to compute the probability oper...
def _query(self, variables, operation, evidence=None, joint=True): """ This is a generalized query method that can be used for both query and map query. Parameters ---------- variables: list list of variables for which you want to compute the probability oper...
[ "This", "is", "a", "generalized", "query", "method", "that", "can", "be", "used", "for", "both", "query", "and", "map", "query", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/inference/ExactInference.py#L533-L627
[ "def", "_query", "(", "self", ",", "variables", ",", "operation", ",", "evidence", "=", "None", ",", "joint", "=", "True", ")", ":", "is_calibrated", "=", "self", ".", "_is_converged", "(", "operation", "=", "operation", ")", "# Calibrate the junction tree if ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BeliefPropagation.query
Query method using belief propagation. Parameters ---------- variables: list list of variables for which you want to compute the probability evidence: dict a dict key, value pair as {var: state_of_var_observed} None if no evidence joint: boo...
pgmpy/inference/ExactInference.py
def query(self, variables, evidence=None, joint=True): """ Query method using belief propagation. Parameters ---------- variables: list list of variables for which you want to compute the probability evidence: dict a dict key, value pair as {var:...
def query(self, variables, evidence=None, joint=True): """ Query method using belief propagation. Parameters ---------- variables: list list of variables for which you want to compute the probability evidence: dict a dict key, value pair as {var:...
[ "Query", "method", "using", "belief", "propagation", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/inference/ExactInference.py#L629-L673
[ "def", "query", "(", "self", ",", "variables", ",", "evidence", "=", "None", ",", "joint", "=", "True", ")", ":", "return", "self", ".", "_query", "(", "variables", "=", "variables", ",", "operation", "=", "'marginalize'", ",", "evidence", "=", "evidence...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BeliefPropagation.map_query
MAP Query method using belief propagation. Note: When multiple variables are passed, it returns the map_query for each of them individually. Parameters ---------- variables: list list of variables for which you want to compute the probability evidence: dict ...
pgmpy/inference/ExactInference.py
def map_query(self, variables=None, evidence=None): """ MAP Query method using belief propagation. Note: When multiple variables are passed, it returns the map_query for each of them individually. Parameters ---------- variables: list list of variabl...
def map_query(self, variables=None, evidence=None): """ MAP Query method using belief propagation. Note: When multiple variables are passed, it returns the map_query for each of them individually. Parameters ---------- variables: list list of variabl...
[ "MAP", "Query", "method", "using", "belief", "propagation", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/inference/ExactInference.py#L675-L739
[ "def", "map_query", "(", "self", ",", "variables", "=", "None", ",", "evidence", "=", "None", ")", ":", "# TODO:Check the note in docstring. Change that behavior to return the joint MAP", "if", "not", "variables", ":", "variables", "=", "set", "(", "self", ".", "var...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
LinearGaussianCPD.maximum_likelihood_estimator
Fit using MLE method. Parameters ---------- data: pandas.DataFrame or 2D array Dataframe of values containing samples from the conditional distribution, (Y|X) and corresponding X values. states: All the input states that are jointly gaussian. Returns ...
pgmpy/factors/continuous/LinearGaussianCPD.py
def maximum_likelihood_estimator(self, data, states): """ Fit using MLE method. Parameters ---------- data: pandas.DataFrame or 2D array Dataframe of values containing samples from the conditional distribution, (Y|X) and corresponding X values. ...
def maximum_likelihood_estimator(self, data, states): """ Fit using MLE method. Parameters ---------- data: pandas.DataFrame or 2D array Dataframe of values containing samples from the conditional distribution, (Y|X) and corresponding X values. ...
[ "Fit", "using", "MLE", "method", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/continuous/LinearGaussianCPD.py#L96-L160
[ "def", "maximum_likelihood_estimator", "(", "self", ",", "data", ",", "states", ")", ":", "x_df", "=", "pd", ".", "DataFrame", "(", "data", ",", "columns", "=", "states", ")", "x_len", "=", "len", "(", "self", ".", "evidence", ")", "sym_coefs", "=", "[...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
LinearGaussianCPD.fit
Determine βs from data Parameters ---------- data: pandas.DataFrame Dataframe containing samples from the conditional distribution, p(Y|X) estimator: 'MLE' or 'MAP' completely_samples_only: boolean (True or False) Are they downsampled or complete? De...
pgmpy/factors/continuous/LinearGaussianCPD.py
def fit( self, data, states, estimator=None, complete_samples_only=True, **kwargs): """ Determine βs from data Parameters ---------- data: pandas.DataFrame Dataframe containing samples from the c...
def fit( self, data, states, estimator=None, complete_samples_only=True, **kwargs): """ Determine βs from data Parameters ---------- data: pandas.DataFrame Dataframe containing samples from the c...
[ "Determine", "βs", "from", "data" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/continuous/LinearGaussianCPD.py#L162-L188
[ "def", "fit", "(", "self", ",", "data", ",", "states", ",", "estimator", "=", "None", ",", "complete_samples_only", "=", "True", ",", "*", "*", "kwargs", ")", ":", "if", "estimator", "==", "'MLE'", ":", "mean", ",", "variance", "=", "self", ".", "max...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
LinearGaussianCPD.copy
Returns a copy of the distribution. Returns ------- LinearGaussianCPD: copy of the distribution Examples -------- >>> from pgmpy.factors.continuous import LinearGaussianCPD >>> cpd = LinearGaussianCPD('Y', [0.2, -2, 3, 7], 9.6, ['X1', 'X2', 'X3']) >>> c...
pgmpy/factors/continuous/LinearGaussianCPD.py
def copy(self): """ Returns a copy of the distribution. Returns ------- LinearGaussianCPD: copy of the distribution Examples -------- >>> from pgmpy.factors.continuous import LinearGaussianCPD >>> cpd = LinearGaussianCPD('Y', [0.2, -2, 3, 7], 9....
def copy(self): """ Returns a copy of the distribution. Returns ------- LinearGaussianCPD: copy of the distribution Examples -------- >>> from pgmpy.factors.continuous import LinearGaussianCPD >>> cpd = LinearGaussianCPD('Y', [0.2, -2, 3, 7], 9....
[ "Returns", "a", "copy", "of", "the", "distribution", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/continuous/LinearGaussianCPD.py#L204-L225
[ "def", "copy", "(", "self", ")", ":", "copy_cpd", "=", "LinearGaussianCPD", "(", "self", ".", "variable", ",", "self", ".", "beta", ",", "self", ".", "variance", ",", "list", "(", "self", ".", "evidence", ")", ")", "return", "copy_cpd" ]
9381a66aba3c3871d3ccd00672b148d17d63239e
train
_pipe_segment_with_colons
Return a segment of a horizontal line with optional colons which indicate column's alignment (as in `pipe` output format).
pgmpy/extern/tabulate.py
def _pipe_segment_with_colons(align, colwidth): """Return a segment of a horizontal line with optional colons which indicate column's alignment (as in `pipe` output format).""" w = colwidth if align in ["right", "decimal"]: return ('-' * (w - 1)) + ":" elif align == "center": return ...
def _pipe_segment_with_colons(align, colwidth): """Return a segment of a horizontal line with optional colons which indicate column's alignment (as in `pipe` output format).""" w = colwidth if align in ["right", "decimal"]: return ('-' * (w - 1)) + ":" elif align == "center": return ...
[ "Return", "a", "segment", "of", "a", "horizontal", "line", "with", "optional", "colons", "which", "indicate", "column", "s", "alignment", "(", "as", "in", "pipe", "output", "format", ")", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/extern/tabulate.py#L100-L111
[ "def", "_pipe_segment_with_colons", "(", "align", ",", "colwidth", ")", ":", "w", "=", "colwidth", "if", "align", "in", "[", "\"right\"", ",", "\"decimal\"", "]", ":", "return", "(", "'-'", "*", "(", "w", "-", "1", ")", ")", "+", "\":\"", "elif", "al...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
_pipe_line_with_colons
Return a horizontal line with optional colons to indicate column's alignment (as in `pipe` output format).
pgmpy/extern/tabulate.py
def _pipe_line_with_colons(colwidths, colaligns): """Return a horizontal line with optional colons to indicate column's alignment (as in `pipe` output format).""" segments = [_pipe_segment_with_colons(a, w) for a, w in zip(colaligns, colwidths)] return "|" + "|".join(segments) + "|"
def _pipe_line_with_colons(colwidths, colaligns): """Return a horizontal line with optional colons to indicate column's alignment (as in `pipe` output format).""" segments = [_pipe_segment_with_colons(a, w) for a, w in zip(colaligns, colwidths)] return "|" + "|".join(segments) + "|"
[ "Return", "a", "horizontal", "line", "with", "optional", "colons", "to", "indicate", "column", "s", "alignment", "(", "as", "in", "pipe", "output", "format", ")", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/extern/tabulate.py#L114-L118
[ "def", "_pipe_line_with_colons", "(", "colwidths", ",", "colaligns", ")", ":", "segments", "=", "[", "_pipe_segment_with_colons", "(", "a", ",", "w", ")", "for", "a", ",", "w", "in", "zip", "(", "colaligns", ",", "colwidths", ")", "]", "return", "\"|\"", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
simple_separated_format
Construct a simple TableFormat with columns separated by a separator. >>> tsv = simple_separated_format("\\t") ; \ tabulate([["foo", 1], ["spam", 23]], tablefmt=tsv) == 'foo \\t 1\\nspam\\t23' True
pgmpy/extern/tabulate.py
def simple_separated_format(separator): """Construct a simple TableFormat with columns separated by a separator. >>> tsv = simple_separated_format("\\t") ; \ tabulate([["foo", 1], ["spam", 23]], tablefmt=tsv) == 'foo \\t 1\\nspam\\t23' True """ return TableFormat(None, None, None, None, ...
def simple_separated_format(separator): """Construct a simple TableFormat with columns separated by a separator. >>> tsv = simple_separated_format("\\t") ; \ tabulate([["foo", 1], ["spam", 23]], tablefmt=tsv) == 'foo \\t 1\\nspam\\t23' True """ return TableFormat(None, None, None, None, ...
[ "Construct", "a", "simple", "TableFormat", "with", "columns", "separated", "by", "a", "separator", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/extern/tabulate.py#L220-L231
[ "def", "simple_separated_format", "(", "separator", ")", ":", "return", "TableFormat", "(", "None", ",", "None", ",", "None", ",", "None", ",", "headerrow", "=", "DataRow", "(", "''", ",", "separator", ",", "''", ")", ",", "datarow", "=", "DataRow", "(",...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
_isint
>>> _isint("123") True >>> _isint("123.45") False
pgmpy/extern/tabulate.py
def _isint(string): """ >>> _isint("123") True >>> _isint("123.45") False """ return type(string) is int or \ (isinstance(string, _binary_type) or isinstance(string, _text_type)) and \ _isconvertible(int, string)
def _isint(string): """ >>> _isint("123") True >>> _isint("123.45") False """ return type(string) is int or \ (isinstance(string, _binary_type) or isinstance(string, _text_type)) and \ _isconvertible(int, string)
[ ">>>", "_isint", "(", "123", ")", "True", ">>>", "_isint", "(", "123", ".", "45", ")", "False" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/extern/tabulate.py#L254-L263
[ "def", "_isint", "(", "string", ")", ":", "return", "type", "(", "string", ")", "is", "int", "or", "(", "isinstance", "(", "string", ",", "_binary_type", ")", "or", "isinstance", "(", "string", ",", "_text_type", ")", ")", "and", "_isconvertible", "(", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
_afterpoint
Symbols after a decimal point, -1 if the string lacks the decimal point. >>> _afterpoint("123.45") 2 >>> _afterpoint("1001") -1 >>> _afterpoint("eggs") -1 >>> _afterpoint("123e45") 2
pgmpy/extern/tabulate.py
def _afterpoint(string): """Symbols after a decimal point, -1 if the string lacks the decimal point. >>> _afterpoint("123.45") 2 >>> _afterpoint("1001") -1 >>> _afterpoint("eggs") -1 >>> _afterpoint("123e45") 2 """ if _isnumber(string): if _isint(string): ...
def _afterpoint(string): """Symbols after a decimal point, -1 if the string lacks the decimal point. >>> _afterpoint("123.45") 2 >>> _afterpoint("1001") -1 >>> _afterpoint("eggs") -1 >>> _afterpoint("123e45") 2 """ if _isnumber(string): if _isint(string): ...
[ "Symbols", "after", "a", "decimal", "point", "-", "1", "if", "the", "string", "lacks", "the", "decimal", "point", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/extern/tabulate.py#L300-L324
[ "def", "_afterpoint", "(", "string", ")", ":", "if", "_isnumber", "(", "string", ")", ":", "if", "_isint", "(", "string", ")", ":", "return", "-", "1", "else", ":", "pos", "=", "string", ".", "rfind", "(", "\".\"", ")", "pos", "=", "string", ".", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
_padleft
Flush right. >>> _padleft(6, '\u044f\u0439\u0446\u0430') == ' \u044f\u0439\u0446\u0430' True
pgmpy/extern/tabulate.py
def _padleft(width, s, has_invisible=True): """Flush right. >>> _padleft(6, '\u044f\u0439\u0446\u0430') == ' \u044f\u0439\u0446\u0430' True """ iwidth = width + len(s) - len(_strip_invisible(s)) if has_invisible else width fmt = "{0:>%ds}" % iwidth return fmt.format(s)
def _padleft(width, s, has_invisible=True): """Flush right. >>> _padleft(6, '\u044f\u0439\u0446\u0430') == ' \u044f\u0439\u0446\u0430' True """ iwidth = width + len(s) - len(_strip_invisible(s)) if has_invisible else width fmt = "{0:>%ds}" % iwidth return fmt.format(s)
[ "Flush", "right", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/extern/tabulate.py#L327-L336
[ "def", "_padleft", "(", "width", ",", "s", ",", "has_invisible", "=", "True", ")", ":", "iwidth", "=", "width", "+", "len", "(", "s", ")", "-", "len", "(", "_strip_invisible", "(", "s", ")", ")", "if", "has_invisible", "else", "width", "fmt", "=", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
_strip_invisible
Remove invisible ANSI color codes.
pgmpy/extern/tabulate.py
def _strip_invisible(s): "Remove invisible ANSI color codes." if isinstance(s, _text_type): return re.sub(_invisible_codes, "", s) else: # a bytestring return re.sub(_invisible_codes_bytes, "", s)
def _strip_invisible(s): "Remove invisible ANSI color codes." if isinstance(s, _text_type): return re.sub(_invisible_codes, "", s) else: # a bytestring return re.sub(_invisible_codes_bytes, "", s)
[ "Remove", "invisible", "ANSI", "color", "codes", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/extern/tabulate.py#L363-L368
[ "def", "_strip_invisible", "(", "s", ")", ":", "if", "isinstance", "(", "s", ",", "_text_type", ")", ":", "return", "re", ".", "sub", "(", "_invisible_codes", ",", "\"\"", ",", "s", ")", "else", ":", "# a bytestring", "return", "re", ".", "sub", "(", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
_visible_width
Visible width of a printed string. ANSI color codes are removed. >>> _visible_width('\x1b[31mhello\x1b[0m'), _visible_width("world") (5, 5)
pgmpy/extern/tabulate.py
def _visible_width(s): """Visible width of a printed string. ANSI color codes are removed. >>> _visible_width('\x1b[31mhello\x1b[0m'), _visible_width("world") (5, 5) """ if isinstance(s, _text_type) or isinstance(s, _binary_type): return len(_strip_invisible(s)) else: return le...
def _visible_width(s): """Visible width of a printed string. ANSI color codes are removed. >>> _visible_width('\x1b[31mhello\x1b[0m'), _visible_width("world") (5, 5) """ if isinstance(s, _text_type) or isinstance(s, _binary_type): return len(_strip_invisible(s)) else: return le...
[ "Visible", "width", "of", "a", "printed", "string", ".", "ANSI", "color", "codes", "are", "removed", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/extern/tabulate.py#L371-L381
[ "def", "_visible_width", "(", "s", ")", ":", "if", "isinstance", "(", "s", ",", "_text_type", ")", "or", "isinstance", "(", "s", ",", "_binary_type", ")", ":", "return", "len", "(", "_strip_invisible", "(", "s", ")", ")", "else", ":", "return", "len", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
_column_type
The least generic type all column values are convertible to. >>> _column_type(["1", "2"]) is _int_type True >>> _column_type(["1", "2.3"]) is _float_type True >>> _column_type(["1", "2.3", "four"]) is _text_type True >>> _column_type(["four", '\u043f\u044f\u0442\u044c']) is _text_type T...
pgmpy/extern/tabulate.py
def _column_type(strings, has_invisible=True): """The least generic type all column values are convertible to. >>> _column_type(["1", "2"]) is _int_type True >>> _column_type(["1", "2.3"]) is _float_type True >>> _column_type(["1", "2.3", "four"]) is _text_type True >>> _column_type(["f...
def _column_type(strings, has_invisible=True): """The least generic type all column values are convertible to. >>> _column_type(["1", "2"]) is _int_type True >>> _column_type(["1", "2.3"]) is _float_type True >>> _column_type(["1", "2.3", "four"]) is _text_type True >>> _column_type(["f...
[ "The", "least", "generic", "type", "all", "column", "values", "are", "convertible", "to", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/extern/tabulate.py#L429-L450
[ "def", "_column_type", "(", "strings", ",", "has_invisible", "=", "True", ")", ":", "types", "=", "[", "_type", "(", "s", ",", "has_invisible", ")", "for", "s", "in", "strings", "]", "return", "reduce", "(", "_more_generic", ",", "types", ",", "int", "...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
_build_simple_row
Format row according to DataRow format without padding.
pgmpy/extern/tabulate.py
def _build_simple_row(padded_cells, rowfmt): "Format row according to DataRow format without padding." begin, sep, end = rowfmt return (begin + sep.join(padded_cells) + end).rstrip()
def _build_simple_row(padded_cells, rowfmt): "Format row according to DataRow format without padding." begin, sep, end = rowfmt return (begin + sep.join(padded_cells) + end).rstrip()
[ "Format", "row", "according", "to", "DataRow", "format", "without", "padding", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/extern/tabulate.py#L834-L837
[ "def", "_build_simple_row", "(", "padded_cells", ",", "rowfmt", ")", ":", "begin", ",", "sep", ",", "end", "=", "rowfmt", "return", "(", "begin", "+", "sep", ".", "join", "(", "padded_cells", ")", "+", "end", ")", ".", "rstrip", "(", ")" ]
9381a66aba3c3871d3ccd00672b148d17d63239e
train
_build_row
Return a string which represents a row of data cells.
pgmpy/extern/tabulate.py
def _build_row(padded_cells, colwidths, colaligns, rowfmt): "Return a string which represents a row of data cells." if not rowfmt: return None if hasattr(rowfmt, "__call__"): return rowfmt(padded_cells, colwidths, colaligns) else: return _build_simple_row(padded_cells, rowfmt)
def _build_row(padded_cells, colwidths, colaligns, rowfmt): "Return a string which represents a row of data cells." if not rowfmt: return None if hasattr(rowfmt, "__call__"): return rowfmt(padded_cells, colwidths, colaligns) else: return _build_simple_row(padded_cells, rowfmt)
[ "Return", "a", "string", "which", "represents", "a", "row", "of", "data", "cells", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/extern/tabulate.py#L840-L847
[ "def", "_build_row", "(", "padded_cells", ",", "colwidths", ",", "colaligns", ",", "rowfmt", ")", ":", "if", "not", "rowfmt", ":", "return", "None", "if", "hasattr", "(", "rowfmt", ",", "\"__call__\"", ")", ":", "return", "rowfmt", "(", "padded_cells", ","...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
_build_line
Return a string which represents a horizontal line.
pgmpy/extern/tabulate.py
def _build_line(colwidths, colaligns, linefmt): "Return a string which represents a horizontal line." if not linefmt: return None if hasattr(linefmt, "__call__"): return linefmt(colwidths, colaligns) else: begin, fill, sep, end = linefmt cells = [fill*w for w in colwidth...
def _build_line(colwidths, colaligns, linefmt): "Return a string which represents a horizontal line." if not linefmt: return None if hasattr(linefmt, "__call__"): return linefmt(colwidths, colaligns) else: begin, fill, sep, end = linefmt cells = [fill*w for w in colwidth...
[ "Return", "a", "string", "which", "represents", "a", "horizontal", "line", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/extern/tabulate.py#L850-L859
[ "def", "_build_line", "(", "colwidths", ",", "colaligns", ",", "linefmt", ")", ":", "if", "not", "linefmt", ":", "return", "None", "if", "hasattr", "(", "linefmt", ",", "\"__call__\"", ")", ":", "return", "linefmt", "(", "colwidths", ",", "colaligns", ")",...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
_format_table
Produce a plain-text representation of the table.
pgmpy/extern/tabulate.py
def _format_table(fmt, headers, rows, colwidths, colaligns): """Produce a plain-text representation of the table.""" lines = [] hidden = fmt.with_header_hide if (headers and fmt.with_header_hide) else [] pad = fmt.padding headerrow = fmt.headerrow padded_widths = [(w + 2*pad) for w in colwidths...
def _format_table(fmt, headers, rows, colwidths, colaligns): """Produce a plain-text representation of the table.""" lines = [] hidden = fmt.with_header_hide if (headers and fmt.with_header_hide) else [] pad = fmt.padding headerrow = fmt.headerrow padded_widths = [(w + 2*pad) for w in colwidths...
[ "Produce", "a", "plain", "-", "text", "representation", "of", "the", "table", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/extern/tabulate.py#L871-L904
[ "def", "_format_table", "(", "fmt", ",", "headers", ",", "rows", ",", "colwidths", ",", "colaligns", ")", ":", "lines", "=", "[", "]", "hidden", "=", "fmt", ".", "with_header_hide", "if", "(", "headers", "and", "fmt", ".", "with_header_hide", ")", "else"...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BaseDiscretizer.get_labels
Returns a list of strings representing the values about which the discretization method calculates the probabilty masses. Default value is the points - [low, low+step, low+2*step, ......... , high-step] unless the method is overridden by a subclass. Examples ---...
pgmpy/factors/continuous/discretize.py
def get_labels(self): """ Returns a list of strings representing the values about which the discretization method calculates the probabilty masses. Default value is the points - [low, low+step, low+2*step, ......... , high-step] unless the method is overridden by...
def get_labels(self): """ Returns a list of strings representing the values about which the discretization method calculates the probabilty masses. Default value is the points - [low, low+step, low+2*step, ......... , high-step] unless the method is overridden by...
[ "Returns", "a", "list", "of", "strings", "representing", "the", "values", "about", "which", "the", "discretization", "method", "calculates", "the", "probabilty", "masses", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/continuous/discretize.py#L67-L96
[ "def", "get_labels", "(", "self", ")", ":", "step", "=", "(", "self", ".", "high", "-", "self", ".", "low", ")", "/", "self", ".", "cardinality", "labels", "=", "[", "'x={i}'", ".", "format", "(", "i", "=", "str", "(", "i", ")", ")", "for", "i"...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
UnbiasedDiscretizer._lim_moment
This method calculates the kth order limiting moment of the distribution. It is given by - E(u) = Integral (-inf to u) [ (x^k)*pdf(x) dx ] + (u^k)(1-cdf(u)) where, pdf is the probability density function and cdf is the cumulative density function of the distribution. Reference...
pgmpy/factors/continuous/discretize.py
def _lim_moment(self, u, order=1): """ This method calculates the kth order limiting moment of the distribution. It is given by - E(u) = Integral (-inf to u) [ (x^k)*pdf(x) dx ] + (u^k)(1-cdf(u)) where, pdf is the probability density function and cdf is the cumulative d...
def _lim_moment(self, u, order=1): """ This method calculates the kth order limiting moment of the distribution. It is given by - E(u) = Integral (-inf to u) [ (x^k)*pdf(x) dx ] + (u^k)(1-cdf(u)) where, pdf is the probability density function and cdf is the cumulative d...
[ "This", "method", "calculates", "the", "kth", "order", "limiting", "moment", "of", "the", "distribution", ".", "It", "is", "given", "by", "-" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/continuous/discretize.py#L204-L231
[ "def", "_lim_moment", "(", "self", ",", "u", ",", "order", "=", "1", ")", ":", "def", "fun", "(", "x", ")", ":", "return", "np", ".", "power", "(", "x", ",", "order", ")", "*", "self", ".", "factor", ".", "pdf", "(", "x", ")", "return", "(", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
MaximumLikelihoodEstimator.get_parameters
Method to estimate the model parameters (CPDs) using Maximum Likelihood Estimation. Returns ------- parameters: list List of TabularCPDs, one for each variable of the model Examples -------- >>> import numpy as np >>> import pandas as pd >>> ...
pgmpy/estimators/MLE.py
def get_parameters(self): """ Method to estimate the model parameters (CPDs) using Maximum Likelihood Estimation. Returns ------- parameters: list List of TabularCPDs, one for each variable of the model Examples -------- >>> import numpy as n...
def get_parameters(self): """ Method to estimate the model parameters (CPDs) using Maximum Likelihood Estimation. Returns ------- parameters: list List of TabularCPDs, one for each variable of the model Examples -------- >>> import numpy as n...
[ "Method", "to", "estimate", "the", "model", "parameters", "(", "CPDs", ")", "using", "Maximum", "Likelihood", "Estimation", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/estimators/MLE.py#L51-L82
[ "def", "get_parameters", "(", "self", ")", ":", "parameters", "=", "[", "]", "for", "node", "in", "sorted", "(", "self", ".", "model", ".", "nodes", "(", ")", ")", ":", "cpd", "=", "self", ".", "estimate_cpd", "(", "node", ")", "parameters", ".", "...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
MaximumLikelihoodEstimator.estimate_cpd
Method to estimate the CPD for a given variable. Parameters ---------- node: int, string (any hashable python object) The name of the variable for which the CPD is to be estimated. Returns ------- CPD: TabularCPD Examples -------- >>...
pgmpy/estimators/MLE.py
def estimate_cpd(self, node): """ Method to estimate the CPD for a given variable. Parameters ---------- node: int, string (any hashable python object) The name of the variable for which the CPD is to be estimated. Returns ------- CPD: Tabula...
def estimate_cpd(self, node): """ Method to estimate the CPD for a given variable. Parameters ---------- node: int, string (any hashable python object) The name of the variable for which the CPD is to be estimated. Returns ------- CPD: Tabula...
[ "Method", "to", "estimate", "the", "CPD", "for", "a", "given", "variable", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/estimators/MLE.py#L84-L139
[ "def", "estimate_cpd", "(", "self", ",", "node", ")", ":", "state_counts", "=", "self", ".", "state_counts", "(", "node", ")", "# if a column contains only `0`s (no states observed for some configuration", "# of parents' states) fill that column uniformly instead", "state_counts"...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
ConstraintBasedEstimator.estimate
Estimates a DAG for the data set, using the PC constraint-based structure learning algorithm. Independencies are identified from the data set using a chi-squared statistic with the acceptance threshold of `significance_level`. PC identifies a partially directed acyclic graph (PDAG), given ...
pgmpy/estimators/ConstraintBasedEstimator.py
def estimate(self, significance_level=0.01): """ Estimates a DAG for the data set, using the PC constraint-based structure learning algorithm. Independencies are identified from the data set using a chi-squared statistic with the acceptance threshold of `significance_level`. PC i...
def estimate(self, significance_level=0.01): """ Estimates a DAG for the data set, using the PC constraint-based structure learning algorithm. Independencies are identified from the data set using a chi-squared statistic with the acceptance threshold of `significance_level`. PC i...
[ "Estimates", "a", "DAG", "for", "the", "data", "set", "using", "the", "PC", "constraint", "-", "based", "structure", "learning", "algorithm", ".", "Independencies", "are", "identified", "from", "the", "data", "set", "using", "a", "chi", "-", "squared", "stat...
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/estimators/ConstraintBasedEstimator.py#L48-L108
[ "def", "estimate", "(", "self", ",", "significance_level", "=", "0.01", ")", ":", "skel", ",", "separating_sets", "=", "self", ".", "estimate_skeleton", "(", "significance_level", ")", "pdag", "=", "self", ".", "skeleton_to_pdag", "(", "skel", ",", "separating...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
ConstraintBasedEstimator.estimate_skeleton
Estimates a graph skeleton (UndirectedGraph) for the data set. Uses the build_skeleton method (PC algorithm); independencies are determined using a chisquare statistic with the acceptance threshold of `significance_level`. Returns a tuple `(skeleton, separating_sets). Parameters ...
pgmpy/estimators/ConstraintBasedEstimator.py
def estimate_skeleton(self, significance_level=0.01): """Estimates a graph skeleton (UndirectedGraph) for the data set. Uses the build_skeleton method (PC algorithm); independencies are determined using a chisquare statistic with the acceptance threshold of `significance_level`. Returns ...
def estimate_skeleton(self, significance_level=0.01): """Estimates a graph skeleton (UndirectedGraph) for the data set. Uses the build_skeleton method (PC algorithm); independencies are determined using a chisquare statistic with the acceptance threshold of `significance_level`. Returns ...
[ "Estimates", "a", "graph", "skeleton", "(", "UndirectedGraph", ")", "for", "the", "data", "set", ".", "Uses", "the", "build_skeleton", "method", "(", "PC", "algorithm", ")", ";", "independencies", "are", "determined", "using", "a", "chisquare", "statistic", "w...
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/estimators/ConstraintBasedEstimator.py#L110-L181
[ "def", "estimate_skeleton", "(", "self", ",", "significance_level", "=", "0.01", ")", ":", "nodes", "=", "self", ".", "state_names", ".", "keys", "(", ")", "def", "is_independent", "(", "X", ",", "Y", ",", "Zs", ")", ":", "\"\"\"Returns result of hypothesis ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
ConstraintBasedEstimator.estimate_from_independencies
Estimates a DAG from an Independencies()-object or a decision function for conditional independencies. This requires that the set of independencies admits a faithful representation (e.g. is a set of d-seperation for some BN or is closed under the semi-graphoid axioms). See `build_skeleto...
pgmpy/estimators/ConstraintBasedEstimator.py
def estimate_from_independencies(nodes, independencies): """Estimates a DAG from an Independencies()-object or a decision function for conditional independencies. This requires that the set of independencies admits a faithful representation (e.g. is a set of d-seperation for some BN or i...
def estimate_from_independencies(nodes, independencies): """Estimates a DAG from an Independencies()-object or a decision function for conditional independencies. This requires that the set of independencies admits a faithful representation (e.g. is a set of d-seperation for some BN or i...
[ "Estimates", "a", "DAG", "from", "an", "Independencies", "()", "-", "object", "or", "a", "decision", "function", "for", "conditional", "independencies", ".", "This", "requires", "that", "the", "set", "of", "independencies", "admits", "a", "faithful", "representa...
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/estimators/ConstraintBasedEstimator.py#L184-L232
[ "def", "estimate_from_independencies", "(", "nodes", ",", "independencies", ")", ":", "skel", ",", "separating_sets", "=", "ConstraintBasedEstimator", ".", "build_skeleton", "(", "nodes", ",", "independencies", ")", "pdag", "=", "ConstraintBasedEstimator", ".", "skele...
9381a66aba3c3871d3ccd00672b148d17d63239e