![]() |
aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
|
<agrum/FMDP/learning/datastructure/incrementalGraphLearner> More...
#include <incrementalGraphLearner.h>
Public Member Functions | |
Size | size () |
Function Graph Updating methods | |
virtual void | updateFunctionGraph ()=0 |
Updates target to currently learned graph structure. More... | |
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 Attributes | |
MultiDimFunctionGraph< double > * | target_ |
The final diagram we're building. More... | |
Set< const DiscreteVariable *> | setOfVars_ |
const DiscreteVariable * | value_ |
Sequence< ValueType > | valueAssumed_ |
bool | needUpdate_ |
Model handling datastructures | |
NodeGraphPart | model_ |
The source of nodeId. More... | |
NodeId | root_ |
The root of the ordered tree. More... | |
HashTable< NodeId, const DiscreteVariable *> | nodeVarMap_ |
Gives for any node its associated variable. More... | |
HashTable< NodeId, NodeId *> | nodeSonsMap_ |
A table giving for any node a table mapping to its son idx is the modality of associated variable. More... | |
HashTable< const DiscreteVariable *, LinkedList< NodeId > *> | var2Node_ |
Associates to any variable the list of all nodes associated to this variable. More... | |
HashTable< NodeId, NodeDatabase< AttributeSelection, isScalar > *> | nodeId2Database_ |
This hashtable binds every node to an associated NodeDatabase which handles every observation that concerns that node. More... | |
HashTable< NodeId, Set< const Observation *> *> | leafDatabase_ |
This hashtable binds to every leaf an associated set of all hte observations compatible with it. More... | |
Constructor & destructor. | |
IncrementalGraphLearner (MultiDimFunctionGraph< double > *target, Set< const DiscreteVariable * > attributesSet, const DiscreteVariable *learnVariable) | |
Default constructor. More... | |
virtual | ~IncrementalGraphLearner () |
Default destructor. More... | |
void | _clearValue_ () |
Template function dispatcher. More... | |
void | _clearValue_ (Int2Type< true >) |
In the case where we're learning a function of real values this has to be wiped out upon destruction (to be deprecated) More... | |
void | _clearValue_ (Int2Type< false >) |
In case where we're learning function of variable behaviour, this should do nothing. More... | |
New Observation insertion methods | |
virtual void | addObservation (const Observation *obs) |
Inserts a new observation. More... | |
void | _assumeValue_ (const Observation *obs) |
Get value assumed by studied variable for current observation. More... | |
void | _assumeValue_ (const Observation *obs, Int2Type< true >) |
Inserts a new observation. More... | |
void | _assumeValue_ (const Observation *obs, Int2Type< false >) |
Inserts a new observation. More... | |
Idx | _branchObs_ (const Observation *obs, const DiscreteVariable *var) |
Seek modality assumed in obs for given var. More... | |
Idx | _branchObs_ (const Observation *obs, const DiscreteVariable *var, Int2Type< true >) |
Inserts a new observation. More... | |
Idx | _branchObs_ (const Observation *obs, const DiscreteVariable *var, Int2Type< false >) |
Inserts a new observation. More... | |
virtual void | updateNodeWithObservation_ (const Observation *newObs, NodeId currentNodeId) |
Will update internal graph's NodeDatabase of given node with the new observation. More... | |
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. More... | |
virtual void | updateGraph ()=0 |
Updates the tree after a new observation has been added. More... | |
void | updateNode_ (NodeId nody, Set< const DiscreteVariable * > &bestVars) |
From the given sets of node, selects randomly one and installs it on given node. More... | |
virtual void | convertNode2Leaf_ (NodeId) |
Turns the given node into a leaf if not already so. More... | |
virtual void | transpose_ (NodeId, const DiscreteVariable *) |
Installs given variable to the given node, ensuring that the variable is not present in its subtree. More... | |
virtual NodeId | insertNode_ (NodeDatabase< AttributeSelection, isScalar > *nDB, const DiscreteVariable *boundVar) |
inserts a new node in internal graph More... | |
virtual NodeId | insertInternalNode_ (NodeDatabase< AttributeSelection, isScalar > *nDB, const DiscreteVariable *boundVar, NodeId *sonsMap) |
inserts a new internal node in internal graph More... | |
virtual NodeId | insertLeafNode_ (NodeDatabase< AttributeSelection, isScalar > *nDB, const DiscreteVariable *boundVar, Set< const Observation * > *obsSet) |
inserts a new leaf node in internal graohs More... | |
virtual void | chgNodeBoundVar_ (NodeId chgedNodeId, const DiscreteVariable *desiredVar) |
Changes the associated variable of a node. More... | |
virtual void | removeNode_ (NodeId removedNodeId) |
Removes a node from the internal graph. More... | |
<agrum/FMDP/learning/datastructure/incrementalGraphLearner>
Abstract class for incrementaly learn a graphical representation of a function. Can handle both function of real values, and function explaining the behaviour of a variable given set of other variables (as typically in conditionnal probabilities)
Maintains two graph in memory, one which is incrementaly updated and the other one which is updated on demand and is usable by the outside.
Definition at line 65 of file incrementalGraphLearner.h.
|
private |
Definition at line 66 of file incrementalGraphLearner.h.
gum::IncrementalGraphLearner< AttributeSelection, isScalar >::IncrementalGraphLearner | ( | MultiDimFunctionGraph< double > * | target, |
Set< const DiscreteVariable * > | varList, | ||
const DiscreteVariable * | value | ||
) |
Default constructor.
target | : the output diagram usable by the outside |
attributesSet | : set of variables from which we try to describe the learned function |
learnVariable | : if we tried to learn a the behaviour of a variable given variable given another set of variables, this is the one. If we are learning a function of real value, this is just a computationnal trick (and is to be deprecated) |
Definition at line 61 of file incrementalGraphLearner_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Default destructor.
Definition at line 85 of file incrementalGraphLearner_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
inlineprivate |
Get value assumed by studied variable for current observation.
Definition at line 134 of file incrementalGraphLearner.h.
|
inlineprivate |
Inserts a new observation.
the | new observation to learn |
Definition at line 135 of file incrementalGraphLearner.h.
|
inlineprivate |
Inserts a new observation.
the | new observation to learn |
Definition at line 138 of file incrementalGraphLearner.h.
|
inlineprivate |
Seek modality assumed in obs for given var.
Definition at line 148 of file incrementalGraphLearner.h.
|
inlineprivate |
Inserts a new observation.
the | new observation to learn |
Definition at line 151 of file incrementalGraphLearner.h.
|
inlineprivate |
Inserts a new observation.
the | new observation to learn |
Definition at line 154 of file incrementalGraphLearner.h.
|
inlineprivate |
Template function dispatcher.
Definition at line 99 of file incrementalGraphLearner.h.
|
inlineprivate |
In the case where we're learning a function of real values this has to be wiped out upon destruction (to be deprecated)
Definition at line 105 of file incrementalGraphLearner.h.
|
inlineprivate |
In case where we're learning function of variable behaviour, this should do nothing.
Definition at line 111 of file incrementalGraphLearner.h.
|
virtual |
Inserts a new observation.
the | new observation to learn |
Reimplemented in gum::ITI< AttributeSelection, isScalar >, and gum::IMDDI< AttributeSelection, isScalar >.
Definition at line 116 of file incrementalGraphLearner_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
protectedvirtual |
Changes the associated variable of a node.
chgedNodeId | : the node to change |
desiredVar | : its new associated variable |
Reimplemented in gum::ITI< AttributeSelection, isScalar >, and gum::IMDDI< AttributeSelection, isScalar >.
Definition at line 400 of file incrementalGraphLearner_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
protectedvirtual |
Turns the given node into a leaf if not already so.
Definition at line 200 of file incrementalGraphLearner_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
protectedvirtual |
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 362 of file incrementalGraphLearner_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
protectedvirtual |
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 382 of file incrementalGraphLearner_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
protectedvirtual |
inserts a new node in internal graph
nDB | : the associated database |
boundVar | : the associated variable |
Reimplemented in gum::ITI< AttributeSelection, isScalar >.
Definition at line 338 of file incrementalGraphLearner_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
inlinevirtual |
Implements gum::IVisitableGraphLearner.
Reimplemented in gum::IMDDI< AttributeSelection, isScalar >.
Definition at line 326 of file incrementalGraphLearner.h.
|
inlinevirtual |
Implements gum::IVisitableGraphLearner.
Definition at line 306 of file incrementalGraphLearner.h.
|
inlinevirtual |
Implements gum::IVisitableGraphLearner.
Definition at line 321 of file incrementalGraphLearner.h.
|
inlinevirtual |
Implements gum::IVisitableGraphLearner.
Definition at line 316 of file incrementalGraphLearner.h.
|
inlinevirtual |
Implements gum::IVisitableGraphLearner.
Definition at line 311 of file incrementalGraphLearner.h.
|
protectedvirtual |
Removes a node from the internal graph.
removedNodeId | : the node to remove |
Reimplemented in gum::ITI< AttributeSelection, isScalar >, and gum::IMDDI< AttributeSelection, isScalar >.
Definition at line 429 of file incrementalGraphLearner_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
inlinevirtual |
Implements gum::IVisitableGraphLearner.
Definition at line 301 of file incrementalGraphLearner.h.
|
inline |
Definition at line 290 of file incrementalGraphLearner.h.
|
protectedvirtual |
Installs given variable to the given node, ensuring that the variable is not present in its subtree.
Definition at line 227 of file incrementalGraphLearner_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
pure virtual |
Updates target to currently learned graph structure.
Implemented in gum::ITI< AttributeSelection, isScalar >, and gum::IMDDI< AttributeSelection, isScalar >.
|
pure virtual |
Updates the tree after a new observation has been added.
Implemented in gum::ITI< AttributeSelection, isScalar >, and gum::IMDDI< AttributeSelection, isScalar >.
|
protected |
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 169 of file incrementalGraphLearner_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
inlineprotectedvirtual |
Will update internal graph's NodeDatabase of given node with the new observation.
newObs | |
currentNodeId |
Reimplemented in gum::ITI< AttributeSelection, isScalar >, and gum::IMDDI< AttributeSelection, isScalar >.
Definition at line 167 of file incrementalGraphLearner.h.
|
virtual |
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 147 of file incrementalGraphLearner_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
protected |
This hashtable binds to every leaf an associated set of all hte observations compatible with it.
Definition at line 379 of file incrementalGraphLearner.h.
|
protected |
The source of nodeId.
Definition at line 345 of file incrementalGraphLearner.h.
|
protected |
Definition at line 392 of file incrementalGraphLearner.h.
|
protected |
This hashtable binds every node to an associated NodeDatabase which handles every observation that concerns that node.
Definition at line 373 of file incrementalGraphLearner.h.
|
protected |
A table giving for any node a table mapping to its son idx is the modality of associated variable.
Definition at line 361 of file incrementalGraphLearner.h.
|
protected |
Gives for any node its associated variable.
Definition at line 355 of file incrementalGraphLearner.h.
|
protected |
The root of the ordered tree.
Definition at line 350 of file incrementalGraphLearner.h.
|
protected |
Definition at line 387 of file incrementalGraphLearner.h.
|
protected |
The final diagram we're building.
Definition at line 385 of file incrementalGraphLearner.h.
|
protected |
Definition at line 389 of file incrementalGraphLearner.h.
|
protected |
Definition at line 390 of file incrementalGraphLearner.h.
|
protected |
Associates to any variable the list of all nodes associated to this variable.
Definition at line 367 of file incrementalGraphLearner.h.