jpt.sequential_trees

Attributes

fglib

Classes

SequentialJPT

Module Contents

jpt.sequential_trees.fglib = None
class jpt.sequential_trees.SequentialJPT(template_tree: jpt.trees.JPT)
logger
template_tree: jpt.trees.JPT
transition_model: np.array or None = None
fit(sequences: List[numpy.ndarray], timesteps: int = 2)

Fits the transition and emission models. The emission model is fitted with respect to the variables in the next timestep, but it doesn’t use them.

@param sequences: The sequences to learn from @param timesteps: The timesteps to jointly model (minimum of 2 required)

_shift_variable_to_timestep(variable: jpt.variables.Variable, timestep: int = 1) jpt.variables.Variable

Create a new variable where the name is shifted by +n and the domain remains the same.

@param variable: The variable to shift @param timestep: timestep in the future, i.e. timestep >= 1

ground(evidence: List[jpt.variables.VariableAssignment])

Ground a factor graph where inference can be done. The factor graph is grounded with one variable for each timestep, one prior node as factor for each timestep and one factor node for each transition.

@param evidence: A list of VariableMaps that describe evidence in the given timesteps.

ground_fglib(evidence: List[jpt.variables.VariableAssignment])

Ground a factor graph where inference can be done. The factor graph is grounded with one variable for each timestep, one prior node as factor for each timestep and one factor node for each transition.

@param evidence: A list of VariableMaps that describe evidence in the given timesteps.

abstract mpe(evidence)
abstract probability(query, evidence) float

Calculate the probability of sequence ‘query’ given sequence ‘evidence’.

@param query: The question @param evidence: The evidence @return: probability (float)

independent_marginals(evidence: List[LabelAssignment or Dict]) List[jpt.trees.JPT]

Return the independent marginal distributions of all variables in this sequence along all timesteps.

@param evidence: The evidence observed in every timesteps. The length of this list determines the length

of the whole sequence

to_json()
static from_json(data)