![]() |
aGrUM 3.1.1
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 | |
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 () override | |
| Default destructor. | |
Visit Methods | |
| Size | size () |
| NodeId | root () const override |
| bool | isTerminal (NodeId ni) const override |
| const DiscreteVariable * | nodeVar (NodeId ni) const override |
| NodeId | nodeSon (NodeId ni, Idx modality) const override |
| Idx | nodeNbObservation (NodeId ni) const override |
| void | insertSetOfVars (MultiDimFunctionGraph< double > *ret) const override |
Protected Member Functions | |
Function Graph Updating methods | |
| 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) override |
| Inserts a new observation. | |
| void | updateNodeWithObservation_ (const Observation *newObs, NodeId currentNodeId) override |
| Will update internal graph's NodeDatabase of given node with the new observation. | |
Graph Structure update methods | |
| void | updateGraph () override |
| Updates the internal graph after a new observation has been added. | |
| NodeId | insertNode_ (NodeDatabase< AttributeSelection, isScalar > *nDB, const DiscreteVariable *boundVar) override |
| inserts a new node in internal graph | |
| void | chgNodeBoundVar_ (NodeId chgedNodeId, const DiscreteVariable *desiredVar) override |
| Changes the associated variable of a node. | |
| void | removeNode_ (NodeId removedNodeId) override |
| Removes a node from the internal graph. | |
Function Graph Updating methods | |
| void | updateFunctionGraph () override |
| 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 85 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 108 of file iti_tpl.h.
References gum::IncrementalGraphLearner< AttributeSelection, false >::IncrementalGraphLearner(), ITI(), _attributeSelectionThreshold_, _nbTotalObservation_, _staleTable_, and gum::IncrementalGraphLearner< AttributeSelection, false >::root_.
|
privateinherited |
Get value assumed by studied variable for current observation.
Definition at line 153 of file incrementalGraphLearner_tpl.h.
References leafDatabase_, and updateNodeWithObservation_().
|
privateinherited |
Seek modality assumed in obs for given var.
Definition at line 164 of file incrementalGraphLearner_tpl.h.
Referenced by addObservation().
|
privateinherited |
Template function dispatcher.
Definition at line 117 of file incrementalGraphLearner_tpl.h.
References IncrementalGraphLearner(), _clearValue_(), and leafDatabase_.
Referenced by _clearValue_().
|
private |
Inserts an internal node in the target.
| src | the source node in internal graph |
| the | source node in internal graph |
Definition at line 280 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 359 of file iti_tpl.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 309 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 338 of file iti_tpl.h.
References gum::IncrementalGraphLearner< AttributeSelection, false >::nodeId2Database_, and gum::IncrementalGraphLearner< AttributeSelection, false >::target_.
|
overridevirtual |
Inserts a new observation.
| obs | the new observation to learn |
| the | new observation to learn |
Reimplemented from gum::IncrementalGraphLearner< AttributeSelection, false >.
Definition at line 131 of file iti_tpl.h.
References _nbTotalObservation_, and gum::IncrementalGraphLearner< AttributeSelection, isScalar >::addObservation().
|
overrideprotectedvirtual |
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 238 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 218 of file incrementalGraphLearner_tpl.h.
Referenced by transpose_(), and gum::IMDDI< AttributeSelection, isScalar >::updateGraph().
|
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 246 of file incrementalGraphLearner_tpl.h.
References nodeVarMap_, 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 259 of file incrementalGraphLearner_tpl.h.
References setOfVars_, and value_.
Referenced by removeNode_().
|
overrideprotectedvirtual |
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 222 of file iti_tpl.h.
References _staleTable_, and gum::IncrementalGraphLearner< AttributeSelection, isScalar >::insertNode_().
|
overridevirtualinherited |
Implements gum::IVisitableGraphLearner.
Definition at line 315 of file incrementalGraphLearner_tpl.h.
References nodeId2Database_, nodeSonsMap_, nodeVarMap_, setOfVars_, and value_.
|
protected |
insertSetOfVars_
| ret |
Definition at line 364 of file iti_tpl.h.
References gum::MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy >::add(), and gum::IncrementalGraphLearner< AttributeSelection, false >::setOfVars_.
|
overridevirtualinherited |
Implements gum::IVisitableGraphLearner.
Definition at line 307 of file incrementalGraphLearner_tpl.h.
|
overridevirtualinherited |
Implements gum::IVisitableGraphLearner.
Definition at line 313 of file incrementalGraphLearner_tpl.h.
|
overridevirtualinherited |
Implements gum::IVisitableGraphLearner.
Definition at line 311 of file incrementalGraphLearner_tpl.h.
|
overridevirtualinherited |
Implements gum::IVisitableGraphLearner.
Definition at line 309 of file incrementalGraphLearner_tpl.h.
|
overrideprotectedvirtual |
Removes a node from the internal graph.
| removedNodeId | : the node to remove |
Reimplemented from gum::IncrementalGraphLearner< AttributeSelection, false >.
Definition at line 254 of file iti_tpl.h.
References _staleTable_, and gum::IncrementalGraphLearner< AttributeSelection, isScalar >::removeNode_().
|
overridevirtualinherited |
Implements gum::IVisitableGraphLearner.
Definition at line 305 of file incrementalGraphLearner_tpl.h.
|
inherited |
Definition at line 303 of file incrementalGraphLearner_tpl.h.
References nodeSonsMap_, nodeVarMap_, and transpose_().
|
protectedvirtualinherited |
Installs given variable to the given node, ensuring that the variable is not present in its subtree.
Definition at line 224 of file incrementalGraphLearner_tpl.h.
References convertNode2Leaf_(), leafDatabase_, nodeSonsMap_, nodeVarMap_, and removeNode_().
Referenced by gum::IMDDI< AttributeSelection, isScalar >::_updateNodeSet_(), and size().
|
overridevirtual |
Updates target to currently learned graph structure.
Implements gum::IncrementalGraphLearner< AttributeSelection, false >.
Definition at line 267 of file iti_tpl.h.
References _insertNodeInFunctionGraph_(), gum::IncrementalGraphLearner< AttributeSelection, false >::root_, and gum::IncrementalGraphLearner< AttributeSelection, false >::target_.
|
overridevirtual |
Updates the internal graph after a new observation has been added.
Implements gum::IncrementalGraphLearner< AttributeSelection, false >.
Definition at line 161 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 213 of file incrementalGraphLearner_tpl.h.
Referenced by gum::ITI< AttributeSelection, isScalar >::updateGraph().
|
overrideprotectedvirtual |
Will update internal graph's NodeDatabase of given node with the new observation.
| newObs | |
| currentNodeId |
Reimplemented from gum::IncrementalGraphLearner< AttributeSelection, false >.
Definition at line 145 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 195 of file incrementalGraphLearner_tpl.h.
The threshold above which we consider variables to be dependant.
Definition at line 272 of file iti.h.
Referenced by ITI(), ITI(), and updateGraph().
The total number of observation added to this tree.
Definition at line 269 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 266 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 364 of file incrementalGraphLearner.h.
Referenced by _assumeValue_(), _clearValue_(), and transpose_().
|
protectedinherited |
The source of nodeId.
Definition at line 330 of file incrementalGraphLearner.h.
Referenced by gum::IMDDI< AttributeSelection, isScalar >::IMDDI(), and gum::IMDDI< AttributeSelection, isScalar >::IMDDI().
|
protectedinherited |
Definition at line 377 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 358 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_(), insertSetOfVars(), 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 346 of file incrementalGraphLearner.h.
Referenced by ~IncrementalGraphLearner(), gum::ITI< AttributeSelection, isScalar >::_insertNodeInFunctionGraph_(), gum::IMDDI< AttributeSelection, isScalar >::_rebuildFunctionGraph_(), gum::IMDDI< AttributeSelection, isScalar >::_updateNodeSet_(), addObservation(), insertSetOfVars(), removeNode_(), size(), transpose_(), and gum::ITI< AttributeSelection, isScalar >::updateGraph().
|
protectedinherited |
Gives for any node its associated variable.
Definition at line 340 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_(), insertInternalNode_(), insertSetOfVars(), gum::IMDDI< AttributeSelection, isScalar >::removeNode_(), size(), transpose_(), gum::ITI< AttributeSelection, isScalar >::updateGraph(), and gum::IMDDI< AttributeSelection, isScalar >::updateNodeWithObservation_().
|
protectedinherited |
The root of the ordered tree.
Definition at line 335 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 370 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 374 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_(), insertInternalNode_(), insertLeafNode_(), insertNode_(), insertSetOfVars(), gum::IMDDI< AttributeSelection, isScalar >::removeNode_(), removeNode_(), gum::ITI< AttributeSelection, isScalar >::updateGraph(), and gum::IMDDI< AttributeSelection, isScalar >::updateNodeWithObservation_().
|
protectedinherited |
Definition at line 375 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 352 of file incrementalGraphLearner.h.
Referenced by ~IncrementalGraphLearner(), and gum::IMDDI< AttributeSelection, isScalar >::_rebuildFunctionGraph_().