![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
Learn a graphical representation of a function as a decision tree. More...
#include <agrum/FMDP/planning/FunctionGraph/iti.h>
Public Member Functions | |
| Size | size () |
Constructor & destructor. | |
| ITI (MultiDimFunctionGraph< double > *target, double attributeSelectionThreshold, gum::VariableSet attributeListe, const DiscreteVariable *learnedValue) | |
| ITI constructor for functions describing the behaviour of one variable according to a set of other variable such as conditionnal probabilities. | |
| ITI (MultiDimFunctionGraph< double > *target, double attributeSelectionThreshold, gum::VariableSet attributeListe) | |
| ITI constructeur for real functions. | |
| ~ITI () | |
| Default destructor. | |
Visit Methods | |
| NodeId | root () const |
| bool | isTerminal (NodeId ni) const |
| const DiscreteVariable * | nodeVar (NodeId ni) const |
| NodeId | nodeSon (NodeId ni, Idx modality) const |
| Idx | nodeNbObservation (NodeId ni) const |
| virtual void | insertSetOfVars (MultiDimFunctionGraph< double > *ret) const |
Protected Member Functions | |
| void | insertSetOfVars_ (MultiDimFunctionGraph< double > *ret) |
| insertSetOfVars_ | |
Protected Attributes | |
| MultiDimFunctionGraph< double > * | target_ |
| The final diagram we're building. | |
| gum::VariableSet | setOfVars_ |
| const DiscreteVariable * | value_ |
| Sequence< ValueType > | valueAssumed_ |
| bool | needUpdate_ |
Model handling datastructures | |
| NodeGraphPart | model_ |
| The source of nodeId. | |
| NodeId | root_ |
| The root of the ordered tree. | |
| HashTable< NodeId, const DiscreteVariable * > | nodeVarMap_ |
| Gives for any node its associated variable. | |
| HashTable< NodeId, NodeId * > | nodeSonsMap_ |
| A table giving for any node a table mapping to its son idx is the modality of associated variable. | |
| HashTable< const DiscreteVariable *, LinkedList< NodeId > * > | var2Node_ |
| Associates to any variable the list of all nodes associated to this variable. | |
| HashTable< NodeId, NodeDatabase< AttributeSelection, isScalar > * > | nodeId2Database_ |
| This hashtable binds every node to an associated NodeDatabase which handles every observation that concerns that node. | |
| HashTable< NodeId, Set< const Observation * > * > | leafDatabase_ |
| This hashtable binds to every leaf an associated set of all hte observations compatible with it. | |
Private Types | |
| using | ValueType |
Private Member Functions | |
Constructor & destructor. | |
| void | _clearValue_ () |
| Template function dispatcher. | |
New Observation insertion methods | |
| void | _assumeValue_ (const Observation *obs) |
| Get value assumed by studied variable for current observation. | |
| Idx | _branchObs_ (const Observation *obs, const DiscreteVariable *var) |
| Seek modality assumed in obs for given var. | |
Private Attributes | |
| HashTable< NodeId, bool > | _staleTable_ |
| Hashtable indicating if given node has been modified (upon receiving new exemple or through a transpose) The aim is not if we have revise the installed variable on that node. | |
| Idx | _nbTotalObservation_ |
| The total number of observation added to this tree. | |
| double | _attributeSelectionThreshold_ |
| The threshold above which we consider variables to be dependant. | |
New Observation insertion methods | |
| void | addObservation (const Observation *obs) |
| Inserts a new observation. | |
| void | updateNodeWithObservation_ (const Observation *newObs, NodeId currentNodeId) |
| Will update internal graph's NodeDatabase of given node with the new observation. | |
Graph Structure update methods | |
| void | updateGraph () |
| Updates the internal graph after a new observation has been added. | |
| NodeId | insertNode_ (NodeDatabase< AttributeSelection, isScalar > *nDB, const DiscreteVariable *boundVar) |
| inserts a new node in internal graph | |
| void | chgNodeBoundVar_ (NodeId chgedNodeId, const DiscreteVariable *desiredVar) |
| Changes the associated variable of a node. | |
| void | removeNode_ (NodeId removedNodeId) |
| Removes a node from the internal graph. | |
Function Graph Updating methods | |
| void | updateFunctionGraph () |
| Updates target to currently learned graph structure. | |
| NodeId | _insertNodeInFunctionGraph_ (NodeId src) |
| Inserts an internal node in the target. | |
| NodeId | _insertTerminalNode_ (NodeId src) |
| Insert a terminal node in the target. | |
| NodeId | _insertTerminalNode_ (NodeId src, Int2Type< true >) |
| Insert a terminal node in the target. | |
| NodeId | _insertTerminalNode_ (NodeId src, Int2Type< false >) |
| Insert a terminal node in the target. | |
Graph Structure update methods | |
| virtual void | updateVar (const DiscreteVariable *) |
| If a new modality appears to exists for given variable, call this method to turn every associated node to this variable into leaf. Graph has then indeed to be revised. | |
| void | updateNode_ (NodeId nody, gum::VariableSet &bestVars) |
| From the given sets of node, selects randomly one and installs it on given node. | |
| virtual void | convertNode2Leaf_ (NodeId) |
| Turns the given node into a leaf if not already so. | |
| virtual void | transpose_ (NodeId, const DiscreteVariable *) |
| Installs given variable to the given node, ensuring that the variable is not present in its subtree. | |
| virtual NodeId | insertInternalNode_ (NodeDatabase< AttributeSelection, isScalar > *nDB, const DiscreteVariable *boundVar, NodeId *sonsMap) |
| inserts a new internal node in internal graph | |
| virtual NodeId | insertLeafNode_ (NodeDatabase< AttributeSelection, isScalar > *nDB, const DiscreteVariable *boundVar, Set< const Observation * > *obsSet) |
| inserts a new leaf node in internal graohs | |
Learn a graphical representation of a function as a decision tree.
This learning is done incrementaly. Hence first observation are add to the structure and then the structure is updated. Maintains two graph function : one internal for the learning and a target which is updated on demand.
|
privateinherited |
Definition at line 84 of file incrementalGraphLearner.h.
| gum::ITI< AttributeSelection, isScalar >::ITI | ( | MultiDimFunctionGraph< double > * | target, |
| double | attributeSelectionThreshold, | ||
| gum::VariableSet | attributeListe, | ||
| const DiscreteVariable * | learnedValue ) |
ITI constructor for functions describing the behaviour of one variable according to a set of other variable such as conditionnal probabilities.
| target | : the MultiDimFunctionGraph in which we load the structure |
| attributeSelectionThreshold | : threshold under which a node is not installed (pe-pruning) |
| attributeListe | : Set of vars on which we rely to explain the behaviour of learned variable |
| learnedValue | : the variable from which we try to learn the behaviour |
| target | : the MultiDimFunctionGraph in which we load the structure |
| attributeSelectionThreshold | : threshold under which a node is not installed (pe-pruning) |
| temporaryAPIfix | : Issue in API in regard to IMDDI |
| attributeListe | : Set of vars on which we rely to explain the behaviour of learned variable |
| learnedValue | : the variable from which we try to learn the behaviour |
Definition at line 84 of file iti_tpl.h.
References gum::IncrementalGraphLearner< AttributeSelection, false >::IncrementalGraphLearner(), ITI(), _attributeSelectionThreshold_, _nbTotalObservation_, _staleTable_, and gum::IncrementalGraphLearner< AttributeSelection, false >::root_.
Referenced by ITI(), ITI(), and ~ITI().
| gum::ITI< AttributeSelection, isScalar >::ITI | ( | MultiDimFunctionGraph< double > * | target, |
| double | attributeSelectionThreshold, | ||
| gum::VariableSet | attributeListe ) |
ITI constructeur for real functions.
We try to predict the output of a function f given a set of variable
| target | : the MultiDimFunctionGraph in which we load the structure |
| attributeSelectionThreshold | : threshold under which a node is not installed (pe-pruning) |
| attributeListe | : Set of vars on which we rely to explain the behaviour of learned function |
We try to predict the output of a function f given a set of variable
| target | : the MultiDimFunctionGraph in which we load the structure |
| attributeSelectionThreshold | : threshold under which a node is not installed (pe-pruning) |
| temporaryAPIfix | : Issue in API in regard to IMDDI |
| attributeListeSet | of vars on which we rely to explain the behaviour of learned function |
Definition at line 107 of file iti_tpl.h.
References gum::IncrementalGraphLearner< AttributeSelection, false >::IncrementalGraphLearner(), ITI(), _attributeSelectionThreshold_, _nbTotalObservation_, _staleTable_, and gum::IncrementalGraphLearner< AttributeSelection, false >::root_.
|
inlineprivateinherited |
Get value assumed by studied variable for current observation.
Definition at line 153 of file incrementalGraphLearner.h.
|
inlineprivateinherited |
Seek modality assumed in obs for given var.
Definition at line 168 of file incrementalGraphLearner.h.
Referenced by addObservation(), and insertLeafNode_().
|
inlineprivateinherited |
Template function dispatcher.
Definition at line 117 of file incrementalGraphLearner.h.
Referenced by ~IncrementalGraphLearner().
|
private |
Inserts an internal node in the target.
| src | the source node in internal graph |
| the | source node in internal graph |
Definition at line 279 of file iti_tpl.h.
References _insertNodeInFunctionGraph_(), _insertTerminalNode_(), gum::IncrementalGraphLearner< AttributeSelection, false >::nodeSonsMap_, gum::IncrementalGraphLearner< AttributeSelection, false >::nodeVarMap_, gum::IncrementalGraphLearner< AttributeSelection, false >::target_, and gum::IncrementalGraphLearner< AttributeSelection, false >::value_.
Referenced by _insertNodeInFunctionGraph_(), and updateFunctionGraph().
Insert a terminal node in the target.
This function is a dispatcher that will call the right function according to the value of the template isScalar
| src | the source node in the learned graph |
Definition at line 229 of file iti.h.
References _insertTerminalNode_().
Referenced by _insertNodeInFunctionGraph_(), and _insertTerminalNode_().
|
private |
Insert a terminal node in the target.
This function is called if we're learning the behaviour of a variable. Inserts then this variable and the relevant value beneath into target.
| src | the source node in the learned graph |
This function is called if we're learning a real value function. Inserts then a single value in target.
| the | source node in the learned graph |
Definition at line 308 of file iti_tpl.h.
References gum::IncrementalGraphLearner< AttributeSelection, false >::nodeId2Database_, SOA_ALLOCATE, gum::IncrementalGraphLearner< AttributeSelection, false >::target_, and gum::IncrementalGraphLearner< AttributeSelection, false >::value_.
|
private |
Insert a terminal node in the target.
This function is called if we're learning a real value function. Inserts then a single value in target.
| src | the source node in the learned graph |
This function is called if we're learning the behaviour of a variable. Inserts then this variable and the relevant value beneath into target.
| the | source node in the learned graph |
Definition at line 337 of file iti_tpl.h.
References gum::IncrementalGraphLearner< AttributeSelection, false >::nodeId2Database_, and gum::IncrementalGraphLearner< AttributeSelection, false >::target_.
|
virtual |
Inserts a new observation.
| obs | the new observation to learn |
| the | new observation to learn |
Reimplemented from gum::IncrementalGraphLearner< AttributeSelection, false >.
Definition at line 130 of file iti_tpl.h.
References _nbTotalObservation_, and gum::IncrementalGraphLearner< AttributeSelection, isScalar >::addObservation().
|
protectedvirtual |
Changes the associated variable of a node.
| chgedNodeId | : the node to change |
| desiredVar | : its new associated variable |
Reimplemented from gum::IncrementalGraphLearner< AttributeSelection, false >.
Definition at line 237 of file iti_tpl.h.
References _staleTable_, gum::IncrementalGraphLearner< AttributeSelection, isScalar >::chgNodeBoundVar_(), and gum::IncrementalGraphLearner< AttributeSelection, false >::nodeVarMap_.
|
protectedvirtualinherited |
Turns the given node into a leaf if not already so.
Definition at line 230 of file incrementalGraphLearner_tpl.h.
References chgNodeBoundVar_(), nodeSonsMap_, nodeVarMap_, and value_.
Referenced by gum::IMDDI< AttributeSelection, isScalar >::updateGraph(), and updateNode_().
|
protectedvirtualinherited |
inserts a new internal node in internal graph
| nDB | : the associated database |
| boundVar | : the associated variable |
| sonsMap | : a table giving node's sons node |
Definition at line 258 of file incrementalGraphLearner_tpl.h.
References setOfVars_, and value_.
|
protectedvirtualinherited |
inserts a new leaf node in internal graohs
| nDB | : the associated database |
| boundVar | : the associated variable |
| obsSet | : the set of observation this leaf retains |
Reimplemented in gum::IMDDI< AttributeSelection, isScalar >.
Definition at line 271 of file incrementalGraphLearner_tpl.h.
References _branchObs_(), gum::NodeDatabase< AttributeSelection, isScalar >::addObservation(), and leafDatabase_.
Referenced by chgNodeBoundVar_().
|
protectedvirtual |
inserts a new node in internal graph
inserts a new node in internal graohs
| nDB | : the associated database |
| boundVar | : the associated variable |
Reimplemented from gum::IncrementalGraphLearner< AttributeSelection, false >.
Definition at line 221 of file iti_tpl.h.
References _staleTable_, and gum::IncrementalGraphLearner< AttributeSelection, isScalar >::insertNode_().
|
inlinevirtualinherited |
Implements gum::IVisitableGraphLearner.
Reimplemented in gum::IMDDI< AttributeSelection, isScalar >.
Definition at line 349 of file incrementalGraphLearner.h.
|
inlineprotected |
insertSetOfVars_
| ret |
Definition at line 265 of file iti.h.
References gum::MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >::add(), and gum::IncrementalGraphLearner< AttributeSelection, false >::setOfVars_.
|
inlinevirtualinherited |
|
inlinevirtualinherited |
|
inlinevirtualinherited |
|
inlinevirtualinherited |
Removes a node from the internal graph.
| removedNodeId | : the node to remove |
Reimplemented from gum::IncrementalGraphLearner< AttributeSelection, false >.
Definition at line 253 of file iti_tpl.h.
References _staleTable_, and gum::IncrementalGraphLearner< AttributeSelection, isScalar >::removeNode_().
|
inlinevirtualinherited |
|
inlineinherited |
Definition at line 313 of file incrementalGraphLearner.h.
|
protectedvirtualinherited |
Installs given variable to the given node, ensuring that the variable is not present in its subtree.
Definition at line 236 of file incrementalGraphLearner_tpl.h.
Referenced by gum::IMDDI< AttributeSelection, isScalar >::_updateNodeSet_(), and updateVar().
|
virtual |
Updates target to currently learned graph structure.
Implements gum::IncrementalGraphLearner< AttributeSelection, false >.
Definition at line 266 of file iti_tpl.h.
References _insertNodeInFunctionGraph_(), gum::IncrementalGraphLearner< AttributeSelection, false >::root_, and gum::IncrementalGraphLearner< AttributeSelection, false >::target_.
|
virtual |
Updates the internal graph after a new observation has been added.
Implements gum::IncrementalGraphLearner< AttributeSelection, false >.
Definition at line 160 of file iti_tpl.h.
References _attributeSelectionThreshold_, _staleTable_, gum::HashTable< Key, Val >::beginSafe(), gum::HashTable< Key, Val >::cendSafe(), gum::Set< Key >::clear(), gum::HashTable< Key, Val >::endSafe(), gum::Set< Key >::erase(), gum::HashTable< Key, Val >::insert(), gum::Set< Key >::insert(), gum::IncrementalGraphLearner< AttributeSelection, false >::nodeId2Database_, gum::IncrementalGraphLearner< AttributeSelection, false >::nodeSonsMap_, gum::IncrementalGraphLearner< AttributeSelection, false >::nodeVarMap_, gum::IncrementalGraphLearner< AttributeSelection, false >::root_, gum::IncrementalGraphLearner< AttributeSelection, false >::setOfVars_, gum::IncrementalGraphLearner< AttributeSelection, false >::updateNode_(), and gum::IncrementalGraphLearner< AttributeSelection, false >::value_.
|
protectedinherited |
From the given sets of node, selects randomly one and installs it on given node.
Chechks of course if node's current variable is not in that set first.
| nody | : the node we update |
| bestVars | : the set of interessting vars to be installed here |
Chechks of course if node's current variable is not in that set first.
| nody | : the node we update |
| bestVar | : the set of interessting vars to be installed here |
Definition at line 225 of file incrementalGraphLearner_tpl.h.
References convertNode2Leaf_(), leafDatabase_, and removeNode_().
Referenced by gum::ITI< AttributeSelection, isScalar >::updateGraph().
|
protectedvirtual |
Will update internal graph's NodeDatabase of given node with the new observation.
| newObs | |
| currentNodeId |
Reimplemented from gum::IncrementalGraphLearner< AttributeSelection, false >.
Definition at line 144 of file iti_tpl.h.
References _staleTable_, and gum::IncrementalGraphLearner< AttributeSelection, isScalar >::updateNodeWithObservation_().
|
virtualinherited |
If a new modality appears to exists for given variable, call this method to turn every associated node to this variable into leaf. Graph has then indeed to be revised.
Definition at line 207 of file incrementalGraphLearner_tpl.h.
References transpose_().
The threshold above which we consider variables to be dependant.
Definition at line 282 of file iti.h.
Referenced by ITI(), ITI(), and updateGraph().
The total number of observation added to this tree.
Definition at line 279 of file iti.h.
Referenced by ITI(), ITI(), and addObservation().
Hashtable indicating if given node has been modified (upon receiving new exemple or through a transpose) The aim is not if we have revise the installed variable on that node.
Definition at line 276 of file iti.h.
Referenced by ITI(), ITI(), chgNodeBoundVar_(), insertNode_(), removeNode_(), updateGraph(), and updateNodeWithObservation_().
|
protectedinherited |
This hashtable binds to every leaf an associated set of all hte observations compatible with it.
Definition at line 403 of file incrementalGraphLearner.h.
Referenced by ~IncrementalGraphLearner(), insertLeafNode_(), and updateNode_().
|
protectedinherited |
The source of nodeId.
Definition at line 369 of file incrementalGraphLearner.h.
Referenced by gum::IMDDI< AttributeSelection, isScalar >::IMDDI(), and gum::IMDDI< AttributeSelection, isScalar >::IMDDI().
|
protectedinherited |
Definition at line 416 of file incrementalGraphLearner.h.
Referenced by gum::IMDDI< AttributeSelection, isScalar >::updateFunctionGraph().
|
protectedinherited |
This hashtable binds every node to an associated NodeDatabase which handles every observation that concerns that node.
Definition at line 397 of file incrementalGraphLearner.h.
Referenced by gum::IMDDI< AttributeSelection, isScalar >::_addLeaf_(), gum::IMDDI< AttributeSelection, isScalar >::_downdateScore_(), gum::ITI< AttributeSelection, isScalar >::_insertTerminalNode_(), gum::ITI< AttributeSelection, isScalar >::_insertTerminalNode_(), gum::IMDDI< AttributeSelection, isScalar >::_updateNodeSet_(), gum::IMDDI< AttributeSelection, isScalar >::_updateScore_(), and gum::ITI< AttributeSelection, isScalar >::updateGraph().
|
protectedinherited |
A table giving for any node a table mapping to its son idx is the modality of associated variable.
Definition at line 385 of file incrementalGraphLearner.h.
Referenced by ~IncrementalGraphLearner(), gum::ITI< AttributeSelection, isScalar >::_insertNodeInFunctionGraph_(), gum::IMDDI< AttributeSelection, isScalar >::_rebuildFunctionGraph_(), gum::IMDDI< AttributeSelection, isScalar >::_updateNodeSet_(), addObservation(), convertNode2Leaf_(), removeNode_(), and gum::ITI< AttributeSelection, isScalar >::updateGraph().
|
protectedinherited |
Gives for any node its associated variable.
Definition at line 379 of file incrementalGraphLearner.h.
Referenced by ~IncrementalGraphLearner(), gum::ITI< AttributeSelection, isScalar >::_insertNodeInFunctionGraph_(), gum::IMDDI< AttributeSelection, isScalar >::_updateNodeSet_(), addObservation(), gum::IMDDI< AttributeSelection, isScalar >::chgNodeBoundVar_(), gum::ITI< AttributeSelection, isScalar >::chgNodeBoundVar_(), convertNode2Leaf_(), insertNode_(), gum::IMDDI< AttributeSelection, isScalar >::removeNode_(), gum::ITI< AttributeSelection, isScalar >::updateGraph(), and gum::IMDDI< AttributeSelection, isScalar >::updateNodeWithObservation_().
|
protectedinherited |
The root of the ordered tree.
Definition at line 374 of file incrementalGraphLearner.h.
Referenced by gum::IMDDI< AttributeSelection, isScalar >::IMDDI(), gum::IMDDI< AttributeSelection, isScalar >::IMDDI(), gum::ITI< AttributeSelection, isScalar >::ITI(), gum::ITI< AttributeSelection, isScalar >::ITI(), gum::IMDDI< AttributeSelection, isScalar >::_rebuildFunctionGraph_(), gum::ITI< AttributeSelection, isScalar >::updateFunctionGraph(), gum::IMDDI< AttributeSelection, isScalar >::updateGraph(), and gum::ITI< AttributeSelection, isScalar >::updateGraph().
|
protectedinherited |
|
protectedinherited |
The final diagram we're building.
Definition at line 409 of file incrementalGraphLearner.h.
Referenced by gum::IMDDI< AttributeSelection, isScalar >::_insertLeafInFunctionGraph_(), gum::IMDDI< AttributeSelection, isScalar >::_insertLeafInFunctionGraph_(), gum::ITI< AttributeSelection, isScalar >::_insertNodeInFunctionGraph_(), gum::ITI< AttributeSelection, isScalar >::_insertTerminalNode_(), gum::ITI< AttributeSelection, isScalar >::_insertTerminalNode_(), gum::IMDDI< AttributeSelection, isScalar >::_rebuildFunctionGraph_(), and gum::ITI< AttributeSelection, isScalar >::updateFunctionGraph().
|
protectedinherited |
Definition at line 413 of file incrementalGraphLearner.h.
Referenced by gum::IMDDI< AttributeSelection, isScalar >::_insertLeafInFunctionGraph_(), gum::ITI< AttributeSelection, isScalar >::_insertNodeInFunctionGraph_(), gum::ITI< AttributeSelection, isScalar >::_insertTerminalNode_(), gum::IMDDI< AttributeSelection, isScalar >::_rebuildFunctionGraph_(), gum::IMDDI< AttributeSelection, isScalar >::chgNodeBoundVar_(), chgNodeBoundVar_(), convertNode2Leaf_(), insertInternalNode_(), gum::IMDDI< AttributeSelection, isScalar >::removeNode_(), gum::ITI< AttributeSelection, isScalar >::updateGraph(), and gum::IMDDI< AttributeSelection, isScalar >::updateNodeWithObservation_().
|
protectedinherited |
Definition at line 414 of file incrementalGraphLearner.h.
Referenced by gum::IMDDI< AttributeSelection, isScalar >::_addLeaf_(), and gum::IMDDI< AttributeSelection, isScalar >::_insertLeafInFunctionGraph_().
|
protectedinherited |
Associates to any variable the list of all nodes associated to this variable.
Definition at line 391 of file incrementalGraphLearner.h.
Referenced by ~IncrementalGraphLearner(), and gum::IMDDI< AttributeSelection, isScalar >::_rebuildFunctionGraph_().