Linear Gaussian CPD

class pgmpy.factors.continuous.LinearGaussianCPD.LinearGaussianCPD(variable, evidence_mean, evidence_variance, evidence=[], beta=None)[source]

For, X -> Y the Linear Gaussian model assumes that the mean of Y is a linear function of mean of X and the variance of Y does not depend on X.

For example,

p(Y|X) = N(-2x + 0.9 ; 1)

Here, x is the mean of the variable X.

Let Y be a continuous variable with continuous parents X1, X2, \cdots, Xk. We say that Y has a linear Gaussian CPD if there are parameters \beta_0, \beta_1, ..., \beta_k and \sigma_2 such that,

p(Y |x1, x2, ..., xk) = \mathcal{N}(\beta_0 + x1*\beta_1 + ......... + xk*\beta_k ; \sigma_2)

In vector notation,

p(Y |x) = \mathcal{N}(\beta_0 + \boldmath{β}.T * \boldmath{x} ; \sigma_2)

References

copy()[source]

Returns a copy of the distribution.

Returns:

LinearGaussianCPD

Return type:

copy of the distribution

Examples

>>> from pgmpy.factors.continuous import LinearGaussianCPD
>>> cpd = LinearGaussianCPD('Y',  [0.2, -2, 3, 7], 9.6, ['X1', 'X2', 'X3'])
>>> copy_cpd = cpd.copy()
>>> copy_cpd.variable
'Y'
>>> copy_cpd.evidence
['X1', 'X2', 'X3']
fit(data, states, estimator=None, **kwargs)[source]

Determine βs from data

Parameters:

data (pandas.DataFrame) – Dataframe containing samples from the conditional distribution, p(Y|X) estimator: ‘MLE’ or ‘MAP’

maximum_likelihood_estimator(data, states)[source]

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:

beta, variance (tuple)

Return type:

Returns estimated betas and the variance.