class OutputModel

class deeptime.markov.hmm.OutputModel(n_hidden_states: int, n_observable_states: int, ignore_outliers: bool = True)

Output model superclass. Contains basic functionality and interfaces which output models are supposed to implement.

Parameters:
  • n_hidden_states (int) – Number of hidden states.

  • n_observable_states (int) – Number of observable states if discrete state space, otherwise -1

  • ignore_outliers (bool, optional, default=True) – By outliers observations that have zero probability given the current model are meant. ignore_outliers=True means that outliers will be treated as if no observation was made, which is equivalent to making this observation with equal probability from any hidden state. ignore_outliers=False means that an Exception or in the worst case an unhandled crash will occur if an outlier is observed.

Attributes

ignore_outliers

By outliers observations that have zero probability given the current model are meant.

n_hidden_states

Number of hidden states.

n_observable_states

Number of observable states, can be -1 if not applicable (e.g., in a continous observable space).

Methods

copy()

Makes a deep copy of this model.

fit(observations, weights)

Fits the output model given the observations and weights.

generate_observation_trajectory(...)

Generates a synthetic trajectory in observation space given a trajectory in hidden state space.

get_params([deep])

Get the parameters.

sample(observations_per_state)

Samples a new set of parameters for this output model given a list of observations for each hidden state.

set_params(**params)

Set the parameters of this estimator.

submodel([states, obs])

Restricts this model to a set of hidden states and observable states (if applicable).

to_state_probability_trajectory(observations)

Converts a list of observations to hidden state probabilities, i.e., for each observation \(o_t\), one obtains a vector \(p_t\in\mathbb{R}^{n_\mathrm{hidden}}\) denoting how probable that particular observation is in one of the hidden states.

copy() Model

Makes a deep copy of this model.

Returns:

A new copy of this model.

Return type:

copy

abstract fit(observations: List[ndarray], weights: List[ndarray])

Fits the output model given the observations and weights.

Parameters:
  • observations (list of ndarray) – A list of K observation trajectories

  • weights (list of ndarray) – A list of K weight matrices, each having length T_k of their corresponding observation trajectory. Evaluating weights[k][t,n] should yield the weight assignment from observations[k][t] to state index n.

Returns:

self – Reference to self.

Return type:

OutputModel

abstract generate_observation_trajectory(hidden_state_trajectory: ndarray) ndarray

Generates a synthetic trajectory in observation space given a trajectory in hidden state space.

Parameters:

hidden_state_trajectory ((T, 1) ndarray) – Hidden state trajectory.

Returns:

observations – Observation timeseries \(\{o_t\}_t\), where \(o_t\) is the observation associated to hidden state \(s_t\).

Return type:

(T, d) ndarray

get_params(deep=False)

Get the parameters.

Returns:

params – Parameter names mapped to their values.

Return type:

mapping of string to any

abstract sample(observations_per_state: List[ndarray]) None

Samples a new set of parameters for this output model given a list of observations for each hidden state.

Parameters:

observations_per_state (list of ndarray) – The observations per state, i.e., len(observations_per_state) must evaluate to the value of n_hidden_states.

set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters:

**params (dict) – Estimator parameters.

Returns:

self – Estimator instance.

Return type:

object

abstract submodel(states: Optional[ndarray] = None, obs: Optional[ndarray] = None)

Restricts this model to a set of hidden states and observable states (if applicable).

Parameters:
  • states (ndarray, optional, default=None) – The hidden states to restrict to, per default no restriction.

  • obs (ndarray, optional, default=None) – The observable states to restrict to (if applicable), per default no restriction.

Returns:

submodel – The restricted output model.

Return type:

OutputModel

abstract to_state_probability_trajectory(observations: ndarray) ndarray

Converts a list of observations to hidden state probabilities, i.e., for each observation \(o_t\), one obtains a vector \(p_t\in\mathbb{R}^{n_\mathrm{hidden}}\) denoting how probable that particular observation is in one of the hidden states.

Parameters:

observations ((T, d) ndarray) – Array of observations.

Returns:

state_probabilities – State probability trajectory.

Return type:

(T, n_hidden) ndarray

property ignore_outliers: bool

By outliers observations that have zero probability given the current model are meant. ignore_outliers=True means that outliers will be treated as if no observation was made, which is equivalent to making this observation with equal probability from any hidden state. ignore_outliers=False means that an Exception or in the worst case an unhandled crash will occur if an outlier is observed.

property n_hidden_states: int

Number of hidden states.

property n_observable_states: int

Number of observable states, can be -1 if not applicable (e.g., in a continous observable space).