74 template < TESTNAME AttributeSelection,
bool isScalar >
76 double attributeSelectionThreshold,
77 double pairSelectionThreshold,
83 GUM_CONSTRUCTOR(
IMDDI);
90 template < TESTNAME AttributeSelection,
bool isScalar >
92 double attributeSelectionThreshold,
93 double pairSelectionThreshold,
101 GUM_CONSTRUCTOR(
IMDDI);
108 template < TESTNAME AttributeSelection,
bool isScalar >
110 GUM_DESTRUCTOR(
IMDDI);
114 delete leafIter.val();
121 template < TESTNAME AttributeSelection,
bool isScalar >
127 template < TESTNAME AttributeSelection,
bool isScalar >
139 template < TESTNAME AttributeSelection,
bool isScalar >
167 nodeIter != currentNodeSet.
endSafe();
172 if (
_lg_.needsUpdate())
_lg_.update();
188 template < TESTNAME AttributeSelection,
bool isScalar >
200 template < TESTNAME AttributeSelection,
bool isScalar >
217 template < TESTNAME AttributeSelection,
bool isScalar >
224 nodeIter != oldNodeSet.
endSafe();
239 for (
Idx modality = 0; modality < this->
nodeVarMap_[*nodeIter]->domainSize(); ++modality) {
248 nodeSet << *nodeIter;
256 template < TESTNAME AttributeSelection,
bool isScalar >
268 return currentNodeId;
274 template < TESTNAME AttributeSelection,
bool isScalar >
288 template < TESTNAME AttributeSelection,
bool isScalar >
297 template < TESTNAME AttributeSelection,
bool isScalar >
310 template < TESTNAME AttributeSelection,
bool isScalar >
321 template < TESTNAME AttributeSelection,
bool isScalar >
332 template < TESTNAME AttributeSelection,
bool isScalar >
353 treeNodeIter != treeNode2leaf.
cendSafe();
355 if (!leaf2DGNode.
exists(treeNodeIter.val()))
356 leaf2DGNode.
insert(treeNodeIter.val(),
359 toTarget.
insert(treeNodeIter.key(), leaf2DGNode[treeNodeIter.val()]);
369 curNodeIter = curNodeIter->nextLink()) {
372 for (
Idx modality = 0; modality < (*varIter)->domainSize(); ++modality)
373 sonsMap[modality] = toTarget[this->
nodeSonsMap_[curNodeIter->element()][modality]];
374 toTarget.
insert(curNodeIter->element(),
375 this->target_->manager()->addInternalNode(*varIter, sonsMap));
381 this->
target_->manager()->setRootNode(toTarget[this->
root_]);
382 this->
target_->manager()->clean();
388 template < TESTNAME AttributeSelection,
bool isScalar >
392 for (
Idx moda = 0; moda < leaf->
nbModa(); moda++) {
396 return this->
target_->manager()->addTerminalNode(value);
402 template < TESTNAME AttributeSelection,
bool isScalar >
407 for (
Idx modality = 0; modality < this->
value_->domainSize(); ++modality) {
410 sonsMap[modality] = this->
target_->manager()->addTerminalNode(newVal);
412 return this->
target_->manager()->addInternalNode(this->
value_, sonsMap);
415 template < TESTNAME AttributeSelection,
bool isScalar >
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.
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.
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.
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 _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.
void addObservation(const Observation *) override
Adds a new observation to the structure.
void _updateScore_(const DiscreteVariable *, NodeId, VariableSelector &vs)
Computes the score of the given variables for the given node.
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) override
Adds a new observation to the structure.
NodeId insertLeafNode_(NodeDatabase< AttributeSelection, isScalar > *nDB, const DiscreteVariable *boundVar, Set< const Observation * > *sonsMap) override
Adds a new observation to the structure.
void removeNode_(NodeId removedNodeId) override
Adds a new observation to the structure.
HashTable< NodeId, AbstractLeaf * > _leafMap_
void insertSetOfVars(MultiDimFunctionGraph< double > *ret) const override
~IMDDI() override
Default destructor.
void _rebuildFunctionGraph_()
Computes the score of the given variables for the given node.
void updateNodeWithObservation_(const Observation *newObs, NodeId currentNodeId) override
Adds a new observation to the structure.
void updateGraph() override
Updates the tree after a new observation has been added.
void updateFunctionGraph() override
Computes the score of the given variables for the given node.
virtual void updateNodeWithObservation_(const Observation *newObs, NodeId currentNodeId)
Will update internal graph's NodeDatabase of given node with the new observation.
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_
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.
void add(const DiscreteVariable &v) override
Adds a new var to the variables of the multidimensional matrix.
<agrum/FMDP/learning/datastructure/nodeDatabase.h>
Safe iterators for Sequence.
Safe iterators for the Set class.
void clear()
Removes all the elements, if any, from the set.
void insert(const Key &k)
Inserts a new element into the set.
iterator_safe beginSafe() const
The usual safe begin iterator to parse the set.
static const iterator_safe & endSafe() noexcept
The usual safe end iterator to parse 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 downdateScore(const DiscreteVariable *var, double score, double secondaryscore)
The set of remaining vars to select among.
bool hasNext() const
The set of remaining vars to select among.
void begin()
The set of remaining vars to select among.
const DiscreteVariable * select()
Select the most relevant variable.
void next()
The set of remaining vars to select among.
bool isEmpty() const
The set of remaining vars to select among.
const DiscreteVariable * current() 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.