Direct Graphical Models  v.1.5.3
DirectGraphicalModels::CInfer Class Referenceabstract

Base abstract class for random model inference. More...

#include <Infer.h>

Inheritance diagram for DirectGraphicalModels::CInfer:
Collaboration diagram for DirectGraphicalModels::CInfer:

## Public Member Functions

CInfer (CGraph *pGraph)
Constructor. More...

virtual ~CInfer (void)

virtual vec_byte_t decode (unsigned int nIt=0, Mat &lossMatrix=Mat())
Approximate decoding. More...

virtual void infer (unsigned int nIt=1)=0
Inference. More...

vec_float_t getConfidence (void) const
Returns the confidence of the prediction. More...

vec_float_t getPotentials (byte state) const
Returns the potnetials for the selected state (class) More...

## Additional Inherited Members

Protected Member Functions inherited from DirectGraphicalModels::CDecode
CDecode (CGraph *pGraph)
Constructor. More...

void setState (vec_byte_t &state, qword configuration) const
Sets the state according to the configuration index configuration. More...

void incState (vec_byte_t &state) const
Increases the state by one, i.e. switches the state array to the consequent configuration. More...

vec_float_t calculatePotentials (void) const
Calculates potentials for all possible configurations. More...

virtual ~CDecode (void)

virtual vec_byte_t decode (unsigned int nIt=0, Mat &lossMatrix=Mat()) const
Approximate decoding. More...

Static Protected Member Functions inherited from DirectGraphicalModels::CDecode
static vec_byte_t decode (const CGraph *pGraph, Mat &lossMatrix=Mat())
Approximate decoding. More...

static Mat getDefaultLossMatrix (byte nStates)
Returns a default loss matrix $$L$$. More...

Protected Attributes inherited from DirectGraphicalModels::CDecode
CGraphm_pGraph
Pointer to the graph. More...

## Detailed Description

Base abstract class for random model inference.

Definition at line 19 of file Infer.h.

## ◆ CInfer()

 DirectGraphicalModels::CInfer::CInfer ( CGraph * pGraph )
inline

Constructor.

Parameters
 pGraph The graph

Definition at line 26 of file Infer.h.

## ◆ ~CInfer()

 virtual DirectGraphicalModels::CInfer::~CInfer ( void )
inlinevirtual

Definition at line 27 of file Infer.h.

## ◆ decode()

 virtual vec_byte_t DirectGraphicalModels::CInfer::decode ( unsigned int nIt = 0, Mat & lossMatrix = Mat() )
inlinevirtual

Approximate decoding.

This function calls first inference infer() and then, using resulting marginal probabilities, estimates the most probable configuration of states (classes) in the graph via CDecode::decode().

This function modifies Node::Pot containers of graph nodes

Parameters
 nIt Number of iterations lossMatrix (optional) The loss matrix $$L$$ (size: nStates x nStates; type: CV_32FC1). It must be a quadratic zero-diagonal matrix, whith all non-diagonal elements $$L_{i,j} > 0, \forall i\neq j$$. The elemets $$L_{i,j}$$ represent a loss if state $$j$$ is classified as a state $$i$$.
Returns
The most probable configuration
Note
This function estimates the most likely configuration, based on the marginal probabilities (potentials) in graph nodes, which in general is NOT the same as the set of most likely states, which corresponds to the configuration with the highest joint probability. In other words:
using namespace DirectGraphicalModels;
CGraph * graph = new CGraph(nStates);
CInfer * inferer = new CInferExact(graph);
CDecode * decoder = new CDecodeExact(graph);
inferer->decode() == decoder->decode(); // This statement is not always true!

Definition at line 50 of file Infer.h.

Here is the call graph for this function:

## ◆ getConfidence()

 vec_float_t DirectGraphicalModels::CInfer::getConfidence ( void ) const

Returns the confidence of the prediction.

This function calculates the confidence values for the predicted states (classes) in the graph via CInfer::decode(). The confidence values lie in range [0; 1].

Returns
The confidence values for each node of graph.

Definition at line 6 of file Infer.cpp.

Here is the call graph for this function:

## ◆ getPotentials()

 vec_float_t DirectGraphicalModels::CInfer::getPotentials ( byte state ) const

Returns the potnetials for the selected state (class)

Parameters
 state The state (class) of interest
Returns
The potential values for each node of the graph.

Definition at line 27 of file Infer.cpp.

Here is the call graph for this function:

## ◆ infer()

 virtual void DirectGraphicalModels::CInfer::infer ( unsigned int nIt = 1 )
pure virtual

Inference.

This function estimates the marginal potentials for each graph node, and stores them as node potentials

This function modifies Node::Pot containers of graph nodes

Parameters
 nIt Number of iterations
Note
This function must not to be linear, i.e. $$infer(\alpha\times N)\not\equiv\alpha\times infer(N)$$
This function substitutes the graph nodes' potentials with estimated marginal potentials
Here is the caller graph for this function:

The documentation for this class was generated from the following files: