pqp.estimation package

Submodules

pqp.estimation.estimator module

class pqp.estimation.estimator.EstimationResult(operation, step)

Bases: Result

Stores the result of estimation

value

the estimated value

Type:

float

class pqp.estimation.estimator.Estimator(op)

Bases: Result, ABC

Abstract base class for estimators

approx(expr, assignments=None)

Approximates the value of an expression

Parameters:
  • expr (AbstractExpression) – The expression to approximate

  • assignments (dict) – variable assignments (optional)

Returns:

the approximate value of the expression

Return type:

float

abstract domain_of(var)

Return the domain of a Variable

Parameters:

var (Variable or str) – The variable to get the domain of

Returns:

the domain of the variable

Return type:

Domain

abstract estimate(expr: AbstractExpression, assignments=None)

Estimate the value of an expression

Parameters:
  • expr (AbstractExpression) – The expression to estimate

  • assignments (dict) – dict of variable assignments (optional)

Returns:

the result of the estimation

Return type:

EstimationResult

abstract get_observed()

Return the set of Variables that are considered observed in the model

Returns:

the observed variables

Return type:

set

pqp.estimation.multinomial_estimator module

class pqp.estimation.multinomial_estimator.MultinomialEstimator(data, observed=None, prior=0, coerce=True)

Bases: Estimator

Estimates the distribution of a categorical variable using a multinomial likelihood and dirichlet prior

At a basic level, this estimator estimates the probability of an observation using the proportion of past observations which are identical. When prior is set to zero, this is exactly what it does, and positivty is not guaranteed.

If you set prior to a positive value, this is interpreted as a number of “virtual” observations. The estimator behaves as if, before fitting to the data, it had already seen this many data points. It distributes this likelihood evenly across all possible observations in the domain of the variables. This guarantess positivity.

Parameters:
  • data (Data) – The data to use for the distribution

  • observed (list) – The variables which are considered observed, defaults to all

  • prior (float) – The prior strength, defaults to 0

  • coerce (bool) – If True, coerce the data to a Data object, defaults to True

domain_of(var)

Return the domain of a Variable

Parameters:

var (Variable or str) – The variable to get the domain of

Returns:

the domain of the variable

Return type:

Domain

estimate(**kwargs)

Estimate the value of an expression

Parameters:
  • expr (AbstractExpression) – The expression to estimate

  • assignments (dict) – dict of variable assignments (optional)

Returns:

the result of the estimation

Return type:

EstimationResult

get_observed()

Return the set of Variables that are considered observed in the model

Returns:

the observed variables

Return type:

set

Module contents