API Reference / base /

estimators.py

Base class for probability estimators.

Estimators model the probability distribution of a single variable and support incremental (add_value) as well as batch (fit) updates.

Classes

ProbabilityEstimator

class base.estimators.ProbabilityEstimator(ABC)

Abstract base class for all probability estimators.

Estimators are used to model the probability distribution of a variable.
Constructor
__init__(
    self,
)

Methods

__init__ (self)

Initialize the estimator.

add_value (self, value: float, weight: float=1.0) -> None

Add a value to the estimator.

Parameters
value
float
The value to add.
weight
float = 1.0
The weight of the value.
Returns
None
get_probability (self, value: float) -> float

Get the probability of a value given the estimated distribution.

Parameters
value
float
The value to get the probability for.
Returns
probability
float
Probability density or mass at value.
add_values (self, values: np.ndarray, weights: Optional[np.ndarray]=None) -> None

Add multiple values to the estimator.

Parameters
values
np.ndarray of shape (n_values,)
Array of values to add.
weights
np.ndarray of shape (n_values,)
Weight for each value. Defaults to uniform weights of 1.0.
Returns
None
fit (self, values: np.ndarray, weights: Optional[np.ndarray]=None) -> 'ProbabilityEstimator'

Fit the estimator to data (batch mode).

Parameters
values
np.ndarray of shape (n_values,)
Array of values to fit on.
weights
np.ndarray of shape (n_values,)
Weight for each value. Defaults to uniform weights of 1.0.
Returns
self
ProbabilityEstimator
The fitted estimator, for method chaining.