83 template < TESTNAME AttributeSelection,
bool isScalar >
85 double attributeSelectionThreshold,
106 template < TESTNAME AttributeSelection,
bool isScalar >
108 double attributeSelectionThreshold,
115 GUM_CONSTRUCTOR(
ITI);
129 template < TESTNAME AttributeSelection,
bool isScalar >
143 template < TESTNAME AttributeSelection,
bool isScalar >
159 template < TESTNAME AttributeSelection,
bool isScalar >
161 std::vector< NodeId > filo;
162 filo.push_back(this->
root_);
167 while (!filo.empty()) {
168 NodeId currentNodeId = filo.back();
175 for (
auto varIter = tensorVars[currentNodeId]->cbeginSafe();
176 varIter != tensorVars[currentNodeId]->
cendSafe();
179 double varValue = this->
nodeId2Database_[currentNodeId]->testValue(*varIter);
180 if (varValue >= bestValue) {
181 if (varValue > bestValue) {
182 bestValue = varValue;
185 bestVars.
insert(*varIter);
194 for (
Idx moda = 0; moda < this->
nodeVarMap_[currentNodeId]->domainSize(); moda++) {
199 filo.push_back(sonId);
200 tensorVars.
insert(sonId, itsTensorVars);
207 nodeIter != tensorVars.
endSafe();
209 delete nodeIter.val();
220 template < TESTNAME AttributeSelection,
bool isScalar >
236 template < TESTNAME AttributeSelection,
bool isScalar >
239 if (this->
nodeVarMap_[currentNodeId] != desiredVar) {
252 template < TESTNAME AttributeSelection,
bool isScalar >
265 template < TESTNAME AttributeSelection,
bool isScalar >
278 template < TESTNAME AttributeSelection,
bool isScalar >
285 if (!this->
target_->variablesSequence().exists(this->nodeVarMap_[currentNodeId])) {
290 for (
Idx moda = 0; moda < this->
nodeVarMap_[currentNodeId]->domainSize(); ++moda) {
292 this->
target_->manager()->setSon(nody, moda, son);
307 template < TESTNAME AttributeSelection,
bool isScalar >
310 if (!this->
target_->variablesSequence().exists(this->value_))
314 if (tot ==
Size(0))
return this->
target_->manager()->addTerminalNode(0.0);
318 for (
Idx modality = 0; modality < this->
value_->domainSize(); ++modality) {
321 sonsMap[modality] = this->
target_->manager()->addTerminalNode(newVal);
336 template < TESTNAME AttributeSelection,
bool isScalar >
343 value += (
double)valIter.key() * valIter.val();
347 NodeId nody = this->
target_->manager()->addTerminalNode(value);
Headers of the ChiSquare class.
Safe Iterators for hashtables.
Base class for discrete random variable.
The class for generic Hash Tables.
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.
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
iterator_safe beginSafe()
Returns the safe iterator pointing to the beginning of the hashtable.
void chgNodeBoundVar_(NodeId chgedNodeId, const DiscreteVariable *desiredVar)
Changes the associated variable of a node.
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)
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...
NodeId insertNode_(NodeDatabase< AttributeSelection, isScalar > *nDB, const DiscreteVariable *boundVar)
inserts a new node in internal graph
NodeId _insertNodeInFunctionGraph_(NodeId src)
Inserts an internal node in the target.
void updateGraph()
Updates the internal graph after a new observation has been added.
void updateFunctionGraph()
Updates target to currently learned graph structure.
Idx _nbTotalObservation_
The total number of observation added to this tree.
void updateNodeWithObservation_(const Observation *newObs, NodeId currentNodeId)
Will update internal graph's NodeDatabase of given node with the new observation.
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...
void addObservation(const Observation *obs)
Inserts a 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
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>
void insert(const Key &k)
Inserts a new element into the set.
void erase(const Key &k)
Erases an element from the set.
void clear()
Removes all the elements, if any, 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.