aGrUM  0.14.1
gum::learning::CorrectedMutualInformation< ALLOC > Class Template Reference

The class computing n times the corrected mutual information, as used in the 3off2 algorithm. More...

#include <correctedMutualInformation.h>

Public Member Functions

Constructors / Destructors
 CorrectedMutualInformation (const DBRowGeneratorParser< ALLOC > &parser, const Apriori< ALLOC > &apriori, const std::vector< std::pair< std::size_t, std::size_t >, ALLOC< std::pair< std::size_t, std::size_t > > > &ranges, const Bijection< NodeId, std::size_t, ALLOC< std::size_t > > &nodeId2columns=Bijection< NodeId, std::size_t, ALLOC< std::size_t > >(), const allocator_type &alloc=allocator_type())
 default constructor More...
 
 CorrectedMutualInformation (const DBRowGeneratorParser< ALLOC > &parser, const Apriori< ALLOC > &apriori, const Bijection< NodeId, std::size_t, ALLOC< std::size_t > > &nodeId2columns=Bijection< NodeId, std::size_t, ALLOC< std::size_t > >(), const allocator_type &alloc=allocator_type())
 default constructor More...
 
 CorrectedMutualInformation (const CorrectedMutualInformation< ALLOC > &from)
 copy constructor More...
 
 CorrectedMutualInformation (const CorrectedMutualInformation< ALLOC > &from, const allocator_type &alloc)
 copy constructor with a given allocator More...
 
 CorrectedMutualInformation (CorrectedMutualInformation< ALLOC > &&from)
 move constructor More...
 
 CorrectedMutualInformation (CorrectedMutualInformation< ALLOC > &&from, const allocator_type &alloc)
 move constructor with a given allocator More...
 
virtual CorrectedMutualInformation< ALLOC > * clone () const
 virtual copy constructor More...
 
virtual CorrectedMutualInformation< ALLOC > * clone (const allocator_type &alloc) const
 virtual copy constructor with a given allocator More...
 
virtual ~CorrectedMutualInformation ()
 destructor More...
 
Operators
CorrectedMutualInformation< ALLOC > & operator= (const CorrectedMutualInformation< ALLOC > &from)
 copy operator More...
 
CorrectedMutualInformation< ALLOC > & operator= (CorrectedMutualInformation< ALLOC > &&from)
 move operator More...
 
caching functions
virtual void clear ()
 clears all the data structures from memory More...
 
virtual void clearCache ()
 clears all the current caches More...
 
virtual void useCache (bool on_off)
 turn on/off the use of all the caches More...
 
void useICache (bool on_off)
 turn on/off the use of the ICache (the mutual information cache) More...
 
void clearICache ()
 clears the ICache (the mutual information cache) More...
 
void useHCache (bool on_off)
 turn on/off the use of the HCache (the cache for the entropies) More...
 
void clearHCache ()
 clears the HCache (the cache for the entropies) More...
 
void useKCache (bool on_off)
 turn on/off the use of the KCache (the cache for the penalties) More...
 
void clearKCache ()
 clears the KCache (the cache for the penalties) More...
 
void useCnrCache (bool on_off)
 turn on/off the use of the CnrCache (the cache for the Cnr formula) More...
 
void clearCnrCache ()
 clears the CnrCache (the cache for the Cnr formula) More...
 
score functions
double score (NodeId var1, NodeId var2)
 returns the 2-point mutual information corresponding to a given nodeset More...
 
double score (NodeId var1, NodeId var2, const std::vector< NodeId, ALLOC< NodeId > > &conditioning_ids)
 returns the 2-point mutual information corresponding to a given nodeset More...
 
double score (NodeId var1, NodeId var2, NodeId var3)
 returns the 3-point mutual information corresponding to a given nodeset More...
 
double score (NodeId var1, NodeId var2, NodeId var3, const std::vector< NodeId, ALLOC< NodeId > > &conditioning_ids)
 returns the 3-point mutual information corresponding to a given nodeset More...
 
Accessors / Modifiers
void useMDL ()
 use the MDL penalty function More...
 
void useNML ()
 use the kNML penalty function More...
 
void useNoCorr ()
 use no correction/penalty function More...
 
virtual void setMaxNbThreads (std::size_t nb) const
 changes the max number of threads used to parse the database More...
 
virtual std::size_t nbThreads () const
 returns the number of threads used to parse the database More...
 
virtual void setMinNbRowsPerThread (const std::size_t nb) const
 changes the number min of rows a thread should process in a multithreading context More...
 
virtual std::size_t minNbRowsPerThread () const
 returns the minimum of rows that each thread should process More...
 
template<template< typename > class XALLOC>
void setRanges (const std::vector< std::pair< std::size_t, std::size_t >, XALLOC< std::pair< std::size_t, std::size_t > > > &new_ranges)
 sets new ranges to perform the countings used by the mutual information More...
 
void clearRanges ()
 reset the ranges to the one range corresponding to the whole database More...
 
const std::vector< std::pair< std::size_t, std::size_t >, ALLOC< std::pair< std::size_t, std::size_t > > > & ranges () const
 returns the current ranges More...
 
allocator_type getAllocator () const
 returns the allocator used by the score More...
 

Public Types

enum  KModeTypes { KModeTypes::MDL, KModeTypes::NML, KModeTypes::NoCorr }
 the description type for the complexity correction More...
 
using allocator_type = ALLOC< NodeId >
 type for the allocators passed in arguments of methods More...
 

Detailed Description

template<template< typename > class ALLOC = std::allocator>
class gum::learning::CorrectedMutualInformation< ALLOC >

The class computing n times the corrected mutual information, as used in the 3off2 algorithm.

This class handles the computations and storage of the mutual information values used in 3off2 and potential corrections.

Definition at line 53 of file correctedMutualInformation.h.

Member Typedef Documentation

◆ allocator_type

template<template< typename > class ALLOC = std::allocator>
using gum::learning::CorrectedMutualInformation< ALLOC >::allocator_type = ALLOC< NodeId >

type for the allocators passed in arguments of methods

Definition at line 56 of file correctedMutualInformation.h.

Member Enumeration Documentation

◆ KModeTypes

template<template< typename > class ALLOC = std::allocator>
enum gum::learning::CorrectedMutualInformation::KModeTypes
strong

the description type for the complexity correction

Enumerator
MDL 
NML 
NoCorr 

Definition at line 311 of file correctedMutualInformation.h.

311 { MDL, NML, NoCorr };

Constructor & Destructor Documentation

◆ CorrectedMutualInformation() [1/6]

template<template< typename > class ALLOC = std::allocator>
gum::learning::CorrectedMutualInformation< ALLOC >::CorrectedMutualInformation ( const DBRowGeneratorParser< ALLOC > &  parser,
const Apriori< ALLOC > &  apriori,
const std::vector< std::pair< std::size_t, std::size_t >, ALLOC< std::pair< std::size_t, std::size_t > > > &  ranges,
const Bijection< NodeId, std::size_t, ALLOC< std::size_t > > &  nodeId2columns = BijectionNodeId, std::size_t, ALLOC< std::size_t > >(),
const allocator_type alloc = allocator_type() 
)

default constructor

Parameters
parserthe parser used to parse the database
aprioriAn apriori that we add to the computation of the score (this should come from expert knowledge): this consists in adding numbers to countings in the contingency tables
rangesa set of pairs {(X1,Y1),...,(Xn,Yn)} of database's rows indices. The countings are then performed only on the union of the rows [Xi,Yi), i in {1,...,n}. This is useful, e.g, when performing cross validation tasks, in which part of the database should be ignored. An empty set of ranges is equivalent to an interval [X,Y) ranging over the whole database.
nodeId2Columnsa mapping from the ids of the nodes in the graphical model to the corresponding column in the DatabaseTable parsed by the parser. This enables estimating from a database in which variable A corresponds to the 2nd column the parameters of a BN in which variable A has a NodeId of 5. An empty nodeId2Columns bijection means that the mapping is an identity, i.e., the value of a NodeId is equal to the index of the column in the DatabaseTable.
allocthe allocator used to allocate the structures within the Score.
Warning
If nodeId2columns is not empty, then only the scores over the ids belonging to this bijection can be computed: applying method score() over other ids will raise exception NotFound.

◆ CorrectedMutualInformation() [2/6]

template<template< typename > class ALLOC = std::allocator>
gum::learning::CorrectedMutualInformation< ALLOC >::CorrectedMutualInformation ( const DBRowGeneratorParser< ALLOC > &  parser,
const Apriori< ALLOC > &  apriori,
const Bijection< NodeId, std::size_t, ALLOC< std::size_t > > &  nodeId2columns = BijectionNodeId, std::size_t, ALLOC< std::size_t > >(),
const allocator_type alloc = allocator_type() 
)

default constructor

Parameters
parserthe parser used to parse the database
aprioriAn apriori that we add to the computation of the score (this should come from expert knowledge): this consists in adding numbers to countings in the contingency tables
nodeId2Columnsa mapping from the ids of the nodes in the graphical model to the corresponding column in the DatabaseTable parsed by the parser. This enables estimating from a database in which variable A corresponds to the 2nd column the parameters of a BN in which variable A has a NodeId of 5. An empty nodeId2Columns bijection means that the mapping is an identity, i.e., the value of a NodeId is equal to the index of the column in the DatabaseTable.
allocthe allocator used to allocate the structures within the Score.
Warning
If nodeId2columns is not empty, then only the scores over the ids belonging to this bijection can be computed: applying method score() over other ids will raise exception NotFound.

◆ CorrectedMutualInformation() [3/6]

template<template< typename > class ALLOC = std::allocator>
gum::learning::CorrectedMutualInformation< ALLOC >::CorrectedMutualInformation ( const CorrectedMutualInformation< ALLOC > &  from)

copy constructor

◆ CorrectedMutualInformation() [4/6]

template<template< typename > class ALLOC = std::allocator>
gum::learning::CorrectedMutualInformation< ALLOC >::CorrectedMutualInformation ( const CorrectedMutualInformation< ALLOC > &  from,
const allocator_type alloc 
)

copy constructor with a given allocator

◆ CorrectedMutualInformation() [5/6]

template<template< typename > class ALLOC = std::allocator>
gum::learning::CorrectedMutualInformation< ALLOC >::CorrectedMutualInformation ( CorrectedMutualInformation< ALLOC > &&  from)

move constructor

◆ CorrectedMutualInformation() [6/6]

template<template< typename > class ALLOC = std::allocator>
gum::learning::CorrectedMutualInformation< ALLOC >::CorrectedMutualInformation ( CorrectedMutualInformation< ALLOC > &&  from,
const allocator_type alloc 
)

move constructor with a given allocator

◆ ~CorrectedMutualInformation()

template<template< typename > class ALLOC = std::allocator>
virtual gum::learning::CorrectedMutualInformation< ALLOC >::~CorrectedMutualInformation ( )
virtual

destructor

Member Function Documentation

◆ clear()

template<template< typename > class ALLOC = std::allocator>
virtual void gum::learning::CorrectedMutualInformation< ALLOC >::clear ( )
virtual

clears all the data structures from memory

◆ clearCache()

template<template< typename > class ALLOC = std::allocator>
virtual void gum::learning::CorrectedMutualInformation< ALLOC >::clearCache ( )
virtual

clears all the current caches

There are 4 caches in the CorrectedMutualInformation class:

The I cache is intended to cache the computations of the mutual

informations used by 3off2

the H cache is intended to store the results of the computations

of the entropies used in the mutual information formula

the K cache is intended to store the penalties computed so far

the Cnr cache is intended to store the results of the computations

of the Cnr formula used by the kNML penalty

◆ clearCnrCache()

template<template< typename > class ALLOC = std::allocator>
void gum::learning::CorrectedMutualInformation< ALLOC >::clearCnrCache ( )

clears the CnrCache (the cache for the Cnr formula)

◆ clearHCache()

template<template< typename > class ALLOC = std::allocator>
void gum::learning::CorrectedMutualInformation< ALLOC >::clearHCache ( )

clears the HCache (the cache for the entropies)

◆ clearICache()

template<template< typename > class ALLOC = std::allocator>
void gum::learning::CorrectedMutualInformation< ALLOC >::clearICache ( )

clears the ICache (the mutual information cache)

◆ clearKCache()

template<template< typename > class ALLOC = std::allocator>
void gum::learning::CorrectedMutualInformation< ALLOC >::clearKCache ( )

clears the KCache (the cache for the penalties)

◆ clearRanges()

template<template< typename > class ALLOC = std::allocator>
void gum::learning::CorrectedMutualInformation< ALLOC >::clearRanges ( )

reset the ranges to the one range corresponding to the whole database

◆ clone() [1/2]

template<template< typename > class ALLOC = std::allocator>
virtual CorrectedMutualInformation< ALLOC >* gum::learning::CorrectedMutualInformation< ALLOC >::clone ( ) const
virtual

virtual copy constructor

◆ clone() [2/2]

template<template< typename > class ALLOC = std::allocator>
virtual CorrectedMutualInformation< ALLOC >* gum::learning::CorrectedMutualInformation< ALLOC >::clone ( const allocator_type alloc) const
virtual

virtual copy constructor with a given allocator

◆ getAllocator()

template<template< typename > class ALLOC = std::allocator>
allocator_type gum::learning::CorrectedMutualInformation< ALLOC >::getAllocator ( ) const

returns the allocator used by the score

◆ minNbRowsPerThread()

template<template< typename > class ALLOC = std::allocator>
virtual std::size_t gum::learning::CorrectedMutualInformation< ALLOC >::minNbRowsPerThread ( ) const
virtual

returns the minimum of rows that each thread should process

◆ nbThreads()

template<template< typename > class ALLOC = std::allocator>
virtual std::size_t gum::learning::CorrectedMutualInformation< ALLOC >::nbThreads ( ) const
virtual

returns the number of threads used to parse the database

◆ operator=() [1/2]

template<template< typename > class ALLOC = std::allocator>
CorrectedMutualInformation< ALLOC >& gum::learning::CorrectedMutualInformation< ALLOC >::operator= ( const CorrectedMutualInformation< ALLOC > &  from)

copy operator

◆ operator=() [2/2]

template<template< typename > class ALLOC = std::allocator>
CorrectedMutualInformation< ALLOC >& gum::learning::CorrectedMutualInformation< ALLOC >::operator= ( CorrectedMutualInformation< ALLOC > &&  from)

move operator

◆ ranges()

template<template< typename > class ALLOC = std::allocator>
const std::vector< std::pair< std::size_t, std::size_t >, ALLOC< std::pair< std::size_t, std::size_t > > >& gum::learning::CorrectedMutualInformation< ALLOC >::ranges ( ) const

returns the current ranges

◆ score() [1/4]

template<template< typename > class ALLOC = std::allocator>
double gum::learning::CorrectedMutualInformation< ALLOC >::score ( NodeId  var1,
NodeId  var2 
)

returns the 2-point mutual information corresponding to a given nodeset

Referenced by gum::learning::Miic::_findBestContributor(), gum::learning::Miic::_getUnshieldedTriples(), gum::learning::Miic::_getUnshieldedTriplesMIIC(), gum::learning::Miic::_initiation(), and gum::learning::Miic::_iteration().

+ Here is the caller graph for this function:

◆ score() [2/4]

template<template< typename > class ALLOC = std::allocator>
double gum::learning::CorrectedMutualInformation< ALLOC >::score ( NodeId  var1,
NodeId  var2,
const std::vector< NodeId, ALLOC< NodeId > > &  conditioning_ids 
)

returns the 2-point mutual information corresponding to a given nodeset

◆ score() [3/4]

template<template< typename > class ALLOC = std::allocator>
double gum::learning::CorrectedMutualInformation< ALLOC >::score ( NodeId  var1,
NodeId  var2,
NodeId  var3 
)

returns the 3-point mutual information corresponding to a given nodeset

◆ score() [4/4]

template<template< typename > class ALLOC = std::allocator>
double gum::learning::CorrectedMutualInformation< ALLOC >::score ( NodeId  var1,
NodeId  var2,
NodeId  var3,
const std::vector< NodeId, ALLOC< NodeId > > &  conditioning_ids 
)

returns the 3-point mutual information corresponding to a given nodeset

◆ setMaxNbThreads()

template<template< typename > class ALLOC = std::allocator>
virtual void gum::learning::CorrectedMutualInformation< ALLOC >::setMaxNbThreads ( std::size_t  nb) const
virtual

changes the max number of threads used to parse the database

◆ setMinNbRowsPerThread()

template<template< typename > class ALLOC = std::allocator>
virtual void gum::learning::CorrectedMutualInformation< ALLOC >::setMinNbRowsPerThread ( const std::size_t  nb) const
virtual

changes the number min of rows a thread should process in a multithreading context

When computing score, several threads are used by record counters to perform countings on the rows of the database, the MinNbRowsPerThread method indicates how many rows each thread should at least process. This is used to compute the number of threads actually run. This number is equal to the min between the max number of threads allowed and the number of records in the database divided by nb.

◆ setRanges()

template<template< typename > class ALLOC = std::allocator>
template<template< typename > class XALLOC>
void gum::learning::CorrectedMutualInformation< ALLOC >::setRanges ( const std::vector< std::pair< std::size_t, std::size_t >, XALLOC< std::pair< std::size_t, std::size_t > > > &  new_ranges)

sets new ranges to perform the countings used by the mutual information

Parameters
rangesa set of pairs {(X1,Y1),...,(Xn,Yn)} of database's rows indices. The countings are then performed only on the union of the rows [Xi,Yi), i in {1,...,n}. This is useful, e.g, when performing cross validation tasks, in which part of the database should be ignored. An empty set of ranges is equivalent to an interval [X,Y) ranging over the whole database.

◆ useCache()

template<template< typename > class ALLOC = std::allocator>
virtual void gum::learning::CorrectedMutualInformation< ALLOC >::useCache ( bool  on_off)
virtual

turn on/off the use of all the caches

There are 4 caches in the CorrectedMutualInformation class:

The I cache is intended to cache the computations of the mutual

informations used by 3off2

the H cache is intended to store the results of the computations

of the entropies used in the mutual information formula

the K cache is intended to store the penalties computed so far

the Cnr cache is intended to store the results of the computations

of the Cnr formula used by the kNML penalty

◆ useCnrCache()

template<template< typename > class ALLOC = std::allocator>
void gum::learning::CorrectedMutualInformation< ALLOC >::useCnrCache ( bool  on_off)

turn on/off the use of the CnrCache (the cache for the Cnr formula)

◆ useHCache()

template<template< typename > class ALLOC = std::allocator>
void gum::learning::CorrectedMutualInformation< ALLOC >::useHCache ( bool  on_off)

turn on/off the use of the HCache (the cache for the entropies)

◆ useICache()

template<template< typename > class ALLOC = std::allocator>
void gum::learning::CorrectedMutualInformation< ALLOC >::useICache ( bool  on_off)

turn on/off the use of the ICache (the mutual information cache)

◆ useKCache()

template<template< typename > class ALLOC = std::allocator>
void gum::learning::CorrectedMutualInformation< ALLOC >::useKCache ( bool  on_off)

turn on/off the use of the KCache (the cache for the penalties)

◆ useMDL()

template<template< typename > class ALLOC = std::allocator>
void gum::learning::CorrectedMutualInformation< ALLOC >::useMDL ( )

use the MDL penalty function

Referenced by gum::learning::genericBNLearner::__createCorrectedMutualInformation().

+ Here is the caller graph for this function:

◆ useNML()

template<template< typename > class ALLOC = std::allocator>
void gum::learning::CorrectedMutualInformation< ALLOC >::useNML ( )

use the kNML penalty function

Referenced by gum::learning::genericBNLearner::__createCorrectedMutualInformation().

+ Here is the caller graph for this function:

◆ useNoCorr()

template<template< typename > class ALLOC = std::allocator>
void gum::learning::CorrectedMutualInformation< ALLOC >::useNoCorr ( )

use no correction/penalty function

Referenced by gum::learning::genericBNLearner::__createCorrectedMutualInformation().

+ Here is the caller graph for this function:

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