84 template < TESTNAME AttributeSelection,
bool isScalar >
86 double attributeSelectionThreshold,
107 template < TESTNAME AttributeSelection,
bool isScalar >
109 double attributeSelectionThreshold,
116 GUM_CONSTRUCTOR(
ITI);
130 template < TESTNAME AttributeSelection,
bool isScalar >
144 template < TESTNAME AttributeSelection,
bool isScalar >
160 template < TESTNAME AttributeSelection,
bool isScalar >
162 std::vector< NodeId > filo;
163 filo.push_back(this->
root_);
168 while (!filo.empty()) {
169 NodeId currentNodeId = filo.back();
176 for (
auto varIter = tensorVars[currentNodeId]->cbeginSafe();
177 varIter != tensorVars[currentNodeId]->
cendSafe();
180 double varValue = this->
nodeId2Database_[currentNodeId]->testValue(*varIter);
181 if (varValue >= bestValue) {
182 if (varValue > bestValue) {
183 bestValue = varValue;
186 bestVars.
insert(*varIter);
195 for (
Idx moda = 0; moda < this->
nodeVarMap_[currentNodeId]->domainSize(); moda++) {
200 filo.push_back(sonId);
201 tensorVars.
insert(sonId, itsTensorVars);
208 nodeIter != tensorVars.
endSafe();
210 delete nodeIter.val();
221 template < TESTNAME AttributeSelection,
bool isScalar >
237 template < TESTNAME AttributeSelection,
bool isScalar >
240 if (this->
nodeVarMap_[currentNodeId] != desiredVar) {
253 template < TESTNAME AttributeSelection,
bool isScalar >
266 template < TESTNAME AttributeSelection,
bool isScalar >
279 template < TESTNAME AttributeSelection,
bool isScalar >
286 if (!this->
target_->variablesSequence().exists(this->nodeVarMap_[currentNodeId])) {
291 for (
Idx moda = 0; moda < this->
nodeVarMap_[currentNodeId]->domainSize(); ++moda) {
293 this->
target_->manager()->setSon(nody, moda, son);
308 template < TESTNAME AttributeSelection,
bool isScalar >
311 if (!this->
target_->variablesSequence().exists(this->value_))
315 if (tot ==
Size(0))
return this->
target_->manager()->addTerminalNode(0.0);
319 for (
Idx modality = 0; modality < this->
value_->domainSize(); ++modality) {
322 sonsMap[modality] = this->
target_->manager()->addTerminalNode(newVal);
337 template < TESTNAME AttributeSelection,
bool isScalar >
344 value += (
double)valIter.key() * valIter.val();
348 NodeId nody = this->
target_->manager()->addTerminalNode(value);
352 template < TESTNAME AttributeSelection,
bool isScalar >
358 template < TESTNAME AttributeSelection,
bool isScalar >
363 template < TESTNAME AttributeSelection,
bool isScalar >
366 varIter != this->setOfVars_.endSafe();
Headers of the ChiSquare class.
Safe Iterators for hashtables.
Base class for discrete random variable.
The class for generic Hash Tables.
iterator_safe beginSafe()
Returns the safe iterator pointing to the beginning of 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 & endSafe() noexcept
Returns the safe iterator pointing to the end of the hashtable.
const const_iterator_safe & cendSafe() const noexcept
Returns the safe const_iterator pointing to the end of the hashtable.
void updateFunctionGraph() override
Updates target to currently learned graph structure.
NodeId _insertTerminalNode_(NodeId src)
Insert a terminal node in the target.
double _attributeSelectionThreshold_
The threshold above which we consider variables to be dependant.
void removeNode_(NodeId removedNodeId) override
Removes a node from the internal graph.
HashTable< NodeId, bool > _staleTable_
Hashtable indicating if given node has been modified (upon receiving new exemple or through a transpo...
void updateGraph() override
Updates the internal graph after a new observation has been added.
NodeId _insertNodeInFunctionGraph_(NodeId src)
Inserts an internal node in the target.
Idx _nbTotalObservation_
The total number of observation added to this tree.
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 va...
NodeId insertNode_(NodeDatabase< AttributeSelection, isScalar > *nDB, const DiscreteVariable *boundVar) override
inserts a new node in internal graph
void insertSetOfVars_(MultiDimFunctionGraph< double > *ret)
insertSetOfVars_
void addObservation(const Observation *obs) override
Inserts a new observation.
void chgNodeBoundVar_(NodeId chgedNodeId, const DiscreteVariable *desiredVar) override
Changes the associated variable of a node.
~ITI() override
Default destructor.
void updateNodeWithObservation_(const Observation *newObs, NodeId currentNodeId) override
Will update internal graph's NodeDatabase of given node with the new observation.
virtual void updateNodeWithObservation_(const Observation *newObs, NodeId currentNodeId)
Will update internal graph's NodeDatabase of given node with the new observation.
HashTable< NodeId, NodeId * > nodeSonsMap_
HashTable< NodeId, NodeDatabase< AttributeSelection, isScalar > * > nodeId2Database_
const DiscreteVariable * value_
virtual void addObservation(const Observation *obs)
Inserts a new observation.
void updateNode_(NodeId nody, gum::VariableSet &bestVars)
gum::VariableSet setOfVars_
virtual NodeId insertNode_(NodeDatabase< AttributeSelection, isScalar > *nDB, const DiscreteVariable *boundVar)
inserts a new node in internal graph
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 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.
void erase(const Key &k)
Erases an element from the set.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Size Idx
Type for indexes.
Size NodeId
Type for node ids.
Headers of the ITI 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.