73 template < TESTNAME AttributeSelection,
bool isScalar >
75 double attributeSelectionThreshold,
76 double pairSelectionThreshold,
82 GUM_CONSTRUCTOR(
IMDDI);
89 template < TESTNAME AttributeSelection,
bool isScalar >
91 double attributeSelectionThreshold,
92 double pairSelectionThreshold,
100 GUM_CONSTRUCTOR(
IMDDI);
107 template < TESTNAME AttributeSelection,
bool isScalar >
109 GUM_DESTRUCTOR(
IMDDI);
113 delete leafIter.val();
120 template < TESTNAME AttributeSelection,
bool isScalar >
126 template < TESTNAME AttributeSelection,
bool isScalar >
138 template < TESTNAME AttributeSelection,
bool isScalar >
166 nodeIter != currentNodeSet.
endSafe();
171 if (
_lg_.needsUpdate())
_lg_.update();
187 template < TESTNAME AttributeSelection,
bool isScalar >
199 template < TESTNAME AttributeSelection,
bool isScalar >
216 template < TESTNAME AttributeSelection,
bool isScalar >
223 nodeIter != oldNodeSet.
endSafe();
238 for (
Idx modality = 0; modality < this->
nodeVarMap_[*nodeIter]->domainSize(); ++modality) {
247 nodeSet << *nodeIter;
255 template < TESTNAME AttributeSelection,
bool isScalar >
267 return currentNodeId;
273 template < TESTNAME AttributeSelection,
bool isScalar >
287 template < TESTNAME AttributeSelection,
bool isScalar >
296 template < TESTNAME AttributeSelection,
bool isScalar >
309 template < TESTNAME AttributeSelection,
bool isScalar >
320 template < TESTNAME AttributeSelection,
bool isScalar >
331 template < TESTNAME AttributeSelection,
bool isScalar >
352 treeNodeIter != treeNode2leaf.
cendSafe();
354 if (!leaf2DGNode.
exists(treeNodeIter.val()))
355 leaf2DGNode.
insert(treeNodeIter.val(),
358 toTarget.
insert(treeNodeIter.key(), leaf2DGNode[treeNodeIter.val()]);
368 curNodeIter = curNodeIter->nextLink()) {
371 for (
Idx modality = 0; modality < (*varIter)->domainSize(); ++modality)
372 sonsMap[modality] = toTarget[this->
nodeSonsMap_[curNodeIter->element()][modality]];
373 toTarget.
insert(curNodeIter->element(),
374 this->target_->manager()->addInternalNode(*varIter, sonsMap));
380 this->
target_->manager()->setRootNode(toTarget[this->
root_]);
381 this->
target_->manager()->clean();
387 template < TESTNAME AttributeSelection,
bool isScalar >
391 for (
Idx moda = 0; moda < leaf->
nbModa(); moda++) {
395 return this->
target_->manager()->addTerminalNode(value);
401 template < TESTNAME AttributeSelection,
bool isScalar >
406 for (
Idx modality = 0; modality < this->
value_->domainSize(); ++modality) {
409 sonsMap[modality] = this->
target_->manager()->addTerminalNode(newVal);
411 return this->
target_->manager()->addInternalNode(this->
value_, sonsMap);
Headers of the ChiSquare class.
Safe Iterators for hashtables.
<agrum/FMDP/learning/datastructure/leaves/abstractLeaf.h>
virtual Idx nbModa() const =0
virtual double total() const =0
virtual double effectif(Idx) const =0
Gaves the leaf effectif for given modality.
<agrum/FMDP/learning/datastructure/leaves/concreteLeaf.h>
Base class for discrete random variable.
Safe Const Iterators for hashtables.
const const_iterator_safe & cendSafe() const noexcept
Returns the safe const_iterator pointing to the end of the hashtable.
bool exists(const Key &key) const
Checks whether there exists an element with a given key in the hashtable.
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
const_iterator_safe cbeginSafe() const
Returns the safe const_iterator pointing to the beginning of the hashtable.
void _addLeaf_(NodeId)
Adds a new observation to the structure.
NodeId _insertLeafInFunctionGraph_(AbstractLeaf *, Int2Type< true >)
Computes the score of the given variables for the given node.
void updateNodeWithObservation_(const Observation *newObs, NodeId currentNodeId)
Adds a new observation to the structure.
void updateFunctionGraph()
Computes the score of the given variables for the given node.
void _updateNodeSet_(Set< NodeId > &, const DiscreteVariable *, VariableSelector &)
For each node in the given set, this methods checks whether or not we should installed the given vari...
Idx _nbTotalObservation_
The total number of observation added to this tree.
IMDDI(MultiDimFunctionGraph< double > *target, double attributeSelectionThreshold, double pairSelectionThreshold, gum::VariableSet attributeListe, const DiscreteVariable *learnedValue)
Variable Learner constructor.
void _removeLeaf_(NodeId)
Adds a new observation to the structure.
~IMDDI()
Default destructor.
void _updateScore_(const DiscreteVariable *, NodeId, VariableSelector &vs)
Computes the score of the given variables for the given node.
void removeNode_(NodeId removedNodeId)
Adds a new observation to the structure.
Sequence< const DiscreteVariable * > _varOrder_
void _downdateScore_(const DiscreteVariable *, NodeId, VariableSelector &vs)
Computes the score of the given variables for the given node.
double _attributeSelectionThreshold_
The threshold above which we consider variables to be dependant.
void chgNodeBoundVar_(NodeId chgedNodeId, const DiscreteVariable *desiredVar)
Adds a new observation to the structure.
HashTable< NodeId, AbstractLeaf * > _leafMap_
void updateGraph()
Updates the tree after a new observation has been added.
void _rebuildFunctionGraph_()
Computes the score of the given variables for the given node.
NodeId insertLeafNode_(NodeDatabase< AttributeSelection, isScalar > *nDB, const DiscreteVariable *boundVar, Set< const Observation * > *sonsMap)
Adds a new observation to the structure.
void addObservation(const Observation *)
Adds a new observation to the structure.
virtual void transpose_(NodeId, const DiscreteVariable *)
virtual NodeId insertLeafNode_(NodeDatabase< AttributeSelection, isScalar > *nDB, const DiscreteVariable *boundVar, Set< const Observation * > *obsSet)
inserts a new leaf node in internal graohs
HashTable< const DiscreteVariable *, LinkedList< NodeId > * > var2Node_
HashTable< NodeId, NodeId * > nodeSonsMap_
HashTable< NodeId, NodeDatabase< AttributeSelection, isScalar > * > nodeId2Database_
const DiscreteVariable * value_
virtual void addObservation(const Observation *obs)
Inserts a new observation.
virtual void convertNode2Leaf_(NodeId)
gum::VariableSet setOfVars_
Sequence< ValueType > valueAssumed_
virtual void updateNodeWithObservation_(const Observation *newObs, NodeId currentNodeId)
Will update internal graph's NodeDatabase of given node with the new observation.
MultiDimFunctionGraph< double > * target_
HashTable< NodeId, const DiscreteVariable * > nodeVarMap_
IncrementalGraphLearner(MultiDimFunctionGraph< double > *target, gum::VariableSet attributesSet, const DiscreteVariable *learnVariable)
virtual void removeNode_(NodeId removedNodeId)
Removes a node from the internal graph.
virtual void chgNodeBoundVar_(NodeId chgedNodeId, const DiscreteVariable *desiredVar)
Changes the associated variable of a node.
<agrum/FMDP/learning/datastructure/nodeDatabase.h>
Safe iterators for Sequence.
Safe iterators for the Set class.
iterator_safe beginSafe() const
The usual safe begin iterator to parse the set.
const iterator_safe & endSafe() const noexcept
The usual safe end iterator to parse the set.
void insert(const Key &k)
Inserts a new element into the set.
void clear()
Removes all the elements, if any, from the set.
<agrum/FMDP/planning/FunctionGraph/variableselector.h>
void updateScore(const DiscreteVariable *var, double score, double secondaryscore)
The set of remaining vars to select among.
void next()
The set of remaining vars to select among.
void downdateScore(const DiscreteVariable *var, double score, double secondaryscore)
The set of remaining vars to select among.
bool isEmpty() const
The set of remaining vars to select among.
const DiscreteVariable * select()
Select the most relevant variable.
void begin()
The set of remaining vars to select among.
const DiscreteVariable * current() const
The set of remaining vars to select among.
bool hasNext() const
The set of remaining vars to select among.
Size Idx
Type for indexes.
Size NodeId
Type for node ids.
Headers of the IMDDI class.
Base class for labelized discrete random variables.
gum is the global namespace for all aGrUM entities
Set< const DiscreteVariable * > VariableSet
priority queues (in which an element cannot appear more than once)
Provides basic types used in aGrUM.