aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
gum::learning Namespace Reference

include the inlined functions if necessary More...

Namespaces

namespace  DBTranslators

Classes

class  CSVParser
 Class for fast parsing of CSV file (never more than one line in application memory). More...
class  DatabaseTable
 The class representing a tabular database as used by learning tasks. More...
class  DBCell
 The class representing the original values of the cells of databases. More...
class  DBHandler
 The base class for all database handlers. More...
class  DBInitializerFromCSV
 The class for initializing DatabaseTable and RawDatabaseTable instances from CSV files. More...
class  DBInitializerFromSQL
 The class for initializing DatabaseTable and RawDatabaseTable instances from SQL databases. More...
class  DBRow
 The class for storing a record in a database. More...
class  DBRowGenerator
 The base class for all DBRow generators. More...
class  DBRowGenerator4CompleteRows
 A DBRowGenerator class that returns the rows that are complete (fully observed) w.r.t. More...
class  DBRowGeneratorEM
 A DBRowGenerator class that returns incomplete rows as EM would do. More...
class  DBRowGeneratorIdentity
 A DBRowGenerator class that returns exactly the rows it gets in input. More...
class  DBRowGeneratorParser
 the class used to read a row in the database and to transform it into a set of DBRow instances that can be used for learning. More...
class  DBRowGeneratorSet
 The class used to pack sets of generators. More...
class  DBRowGeneratorWithBN
 Base class for DBRowGenerator classes that use a BN for computing their outputs. More...
union  DBTranslatedValue
 The union class for storing the translated values in learning databases. More...
class  DBTranslator
 The base class for all the tabular database cell translators. More...
class  DBTranslator4ContinuousVariable
 The databases' cell translators for continuous variables. More...
class  DBTranslator4DiscretizedVariable
 The databases' cell translators for discretized variables. More...
class  DBTranslator4IntegerVariable
 The databases' cell translators for integer variables. More...
class  DBTranslator4LabelizedVariable
 The databases' cell translators for labelized variables. More...
class  DBTranslator4NumericalDiscreteVariable
 The databases' cell translators for numerical Discrete variables. More...
class  DBTranslator4RangeVariable
 The databases' cell translators for range variables. More...
class  DBTranslatorSet
 the class for packing together the translators used to preprocess the datasets More...
struct  IDatabaseTableInsert4DBCell
struct  IDatabaseTableInsert4DBCell< true >
struct  IDatabaseTableInsert4DBCell< false >
class  IDatabaseTable
 The common class for the tabular database tables. More...
class  IDBInitializer
 The base class for initializing DatabaseTable and RawDatabaseTable instances from CSV files or SQL databases. More...
class  NanodbcParser
 Class for parsing SQL results using Nanodbc. More...
class  RawDatabaseTable
 The table containing the raw/original data of a database. More...
class  IdCondSetIterator
 The iterators for IdSets. More...
class  IdCondSet
 A class for storing a pair of sets of NodeIds, the second one corresponding to a conditional set. More...
class  IndependenceTest
 The base class for all the independence tests used for learning. More...
class  IndepTestChi2
 the class for computing Chi2 independence test scores More...
class  IndepTestG2
 the class for computing G2 independence test scores More...
class  KNML
 the class for computing the NML penalty used by MIIC More...
class  PseudoCount
 The class for giving access to pseudo count : count in the database + prior. More...
class  RecordCounter
 The class that computes counting of observations from the database. More...
class  ScoringCache
 a cache for caching scores and independence tests results More...
class  BNDatabaseGenerator
class  BNLearner
 A pack of learning algorithms that can easily be used. More...
class  BNLearnerListener
 A class that redirects gum_signal from algorithms to the listeners of BNLearn. More...
class  IBNLearner
 A pack of learning algorithms that can easily be used. More...
class  StructuralConstraintEmpty
 the base class for all structural constraints More...
class  StructuralConstraintDAG
 The base class for structural constraints imposed by DAGs. More...
class  StructuralConstraintDiGraph
 The base class for structural constraints used by learning algorithms that learn a directed graph structure. More...
class  StructuralConstraintForbiddenArcs
 the structural constraint for forbidding the creation of some arcs during structure learning More...
class  StructuralConstraintIndegree
 the class for structural constraints limiting the number of parents of nodes in a directed graph More...
class  StructuralConstraintMandatoryArcs
 the structural constraint indicating that some arcs shall never be removed or reversed More...
class  StructuralConstraintNoChildrenNodes
 the structural constraint for forbidding children for some nodes More...
class  StructuralConstraintNoParentNodes
 the structural constraint for forbidding parents for some nodes More...
class  StructuralConstraintPossibleEdges
 the structural constraint for forbidding the creation of some arcs except those defined in the class during structure learning More...
class  StructuralConstraintSetStatic
 the "meta-programming" class for storing structural constraints More...
class  StructuralConstraintSliceOrder
 the structural constraint imposing a partial order over nodes More...
class  StructuralConstraintTabuList
 The class imposing a N-sized tabu list as a structural constraints for learning algorithms. More...
class  StructuralConstraintUndiGraph
 The base class for structural constraints used by learning algorithms that learn an undirected graph structure. More...
class  CorrectedMutualInformation
 The class computing n times the corrected mutual information, as used in the MIIC algorithm. More...
class  GreedyHillClimbing
 The greedy hill climbing learning algorithm (for directed graphs). More...
class  K2
 The K2 algorithm. More...
class  LocalSearchWithTabuList
 The local search with tabu list learning algorithm (for directed graphs). More...
class  GreaterPairOn2nd
class  GreaterAbsPairOn2nd
class  GreaterTupleOnLast
class  Miic
 The Miic learning algorithm. More...
class  DAG2BNLearner
 A class that, given a structure and a parameter estimator returns a full Bayes net. More...
class  EMApproximationScheme
 A class for parameterizing EM's parameter learning approximations. More...
class  ParamEstimator
 The base class for estimating parameters of CPTs. More...
class  ParamEstimatorML
 The class for estimating parameters of CPTs using Maximum Likelihood. More...
class  BDeuPrior
 the internal prior for the BDeu score (N' / (r_i * q_i) More...
class  DirichletPriorFromBN
 A dirichlet priori: computes its N'_ijk from a database. More...
class  DirichletPriorFromDatabase
 A dirichlet priori: computes its N'_ijk from a database. More...
class  K2Prior
 the internal prior for the K2 score = Laplace Prior More...
class  NoPrior
 the no a priorclass: corresponds to 0 weight-sample More...
class  Prior
 the base class for all a priori More...
class  SmoothingPrior
 the smooth a priori: adds a weight w to all the counts More...
class  Score
 The base class for all the scores used for learning (BIC, BDeu, etc). More...
class  ScoreAIC
 the class for computing AIC scores More...
class  ScoreBD
 the class for computing Bayesian Dirichlet (BD) log2 scores More...
class  ScoreBDeu
 the class for computing BDeu scores More...
class  ScoreBIC
 the class for computing BIC scores More...
class  ScorefNML
 the class for computing fNML scores More...
class  ScoreK2
 the class for computing K2 scores (actually their log2 value) More...
class  ScoreLog2Likelihood
 the class for computing Log2-likelihood scores More...
class  SimpleMiic
 The miic learning algorithm. More...
class  GraphChange
class  ArcAddition
 The class for notifying learning algorithms of new arc additions. More...
class  ArcDeletion
 The class for notifying learning algorithms of arc removals. More...
class  ArcReversal
 The class for notifying learning algorithms of arc reversals. More...
class  EdgeAddition
 The class for notifying learning algorithms of new edge additions. More...
class  EdgeDeletion
 The class for notifying learning algorithms of edge removals. More...
class  GraphChangesGenerator4DiGraph
 The basic class for computing the next graph changes possible in a structure learning algorithm. More...
struct  _GraphChangesGenerator4K2_
class  GraphChangesGenerator4K2
 The basic class for computing the next graph changes possible in a structure learning algorithm. More...
class  GraphChangesGenerator4UndiGraph
 The basic class for computing the next graph changes possible in an undirected structure learning algorithm. More...
class  GraphChangesGeneratorOnSubDiGraph
 The basic class for computing the next graph changes possible in a structure learning algorithm. More...
class  GraphChangesSelector4DiGraph
 The mecanism to compute the next available graph changes for directed structure learning search algorithms. More...
class  IGraphChangesGenerator4DiGraph
class  IGraphChangesGenerator4UndiGraph

Typedefs

using CondThreePoints = std::tuple< NodeId, NodeId, NodeId, std::vector< NodeId > >
using CondRanking = std::pair< CondThreePoints*, double >
using ThreePoints = std::tuple< NodeId, NodeId, NodeId >
using Ranking = std::pair< ThreePoints*, double >
using ProbabilisticRanking = std::tuple< ThreePoints*, double, double, double >
using ScoreMDL = ScoreBIC

Enumerations

enum class  DBRowGeneratorGoal : char { DBRowGeneratorGoal::ONLY_REMOVE_MISSING_VALUES , DBRowGeneratorGoal::OTHER_THINGS_THAN_REMOVE_MISSING_VALUES }
 the type of things that a DBRowGenerator is designed for More...
enum class  DBTranslatedValueType : char { DBTranslatedValueType::DISCRETE , DBTranslatedValueType::CONTINUOUS }
 The nature of the elements handled by translators (discrete, continuous). More...
enum class  PriorType { DirichletPriorType , SmoothingPriorType , NoPriorType , BDeuPriorType }
enum  GraphChangeType {
  ARC_ADDITION , ARC_DELETION , ARC_REVERSAL , EDGE_ADDITION ,
  EDGE_DELETION
}
 the type of modification that can be applied to the graph More...

Functions

std::ostream & operator<< (std::ostream &stream, const IdCondSet &idset)
 the display operator
template<typename GUM_SCALAR>
std::ostream & operator<< (std::ostream &output, const BNLearner< GUM_SCALAR > &learner)
 Prints BNLearner's current features.
DatabaseTable readFile (const std::string &filename)
constexpr const char * priorTypeToString (PriorType e) noexcept
std::ostream & operator<< (std::ostream &stream, const GraphChange &change)
 a << operator for GraphChanges
std::ostream & operator<< (std::ostream &stream, const ArcAddition &change)
 a << operator for ArcAddition
std::ostream & operator<< (std::ostream &stream, const ArcDeletion &change)
 a << operator for ArcDeletion
std::ostream & operator<< (std::ostream &stream, const ArcReversal &change)
 a << operator for ArcReversal
std::ostream & operator<< (std::ostream &stream, const EdgeAddition &change)
 a << operator for EdgeAddition
std::ostream & operator<< (std::ostream &stream, const EdgeDeletion &change)
 a << operator for EdgeDeletion

Detailed Description

include the inlined functions if necessary

Typedef Documentation

◆ CondRanking

Definition at line 87 of file Miic.h.

◆ CondThreePoints

using gum::learning::CondThreePoints = std::tuple< NodeId, NodeId, NodeId, std::vector< NodeId > >

Definition at line 86 of file Miic.h.

◆ ProbabilisticRanking

Definition at line 92 of file Miic.h.

◆ Ranking

using gum::learning::Ranking = std::pair< ThreePoints*, double >

Definition at line 90 of file Miic.h.

◆ ScoreMDL

Definition at line 67 of file scoreMDL.h.

◆ ThreePoints

Definition at line 89 of file Miic.h.

Enumeration Type Documentation

◆ GraphChangeType

the type of modification that can be applied to the graph

Enumerator
ARC_ADDITION 
ARC_DELETION 
ARC_REVERSAL 
EDGE_ADDITION 
EDGE_DELETION 

Definition at line 66 of file graphChange.h.

◆ PriorType

enum class gum::learning::PriorType
strong
Enumerator
DirichletPriorType 
SmoothingPriorType 
NoPriorType 
BDeuPriorType 

Definition at line 61 of file prior.h.

Function Documentation

◆ operator<<() [1/8]

template<typename GUM_SCALAR>
std::ostream & gum::learning::operator<< ( std::ostream & output,
const BNLearner< GUM_SCALAR > & learner )

Prints BNLearner's current features.

◆ operator<<() [2/8]

std::ostream & gum::learning::operator<< ( std::ostream & stream,
const ArcAddition & change )

a << operator for ArcAddition

Definition at line 130 of file graphChange.cpp.

130 {
131 return stream << change.toString();
132 }
virtual std::string toString() const final
put the content of the ArcAddition into a string

References gum::learning::ArcAddition::toString().

Here is the call graph for this function:

◆ operator<<() [3/8]

std::ostream & gum::learning::operator<< ( std::ostream & stream,
const ArcDeletion & change )

a << operator for ArcDeletion

Definition at line 135 of file graphChange.cpp.

135 {
136 return stream << change.toString();
137 }
virtual std::string toString() const final
put the content of the ArcDeletion into a string

References gum::learning::ArcDeletion::toString().

Here is the call graph for this function:

◆ operator<<() [4/8]

std::ostream & gum::learning::operator<< ( std::ostream & stream,
const ArcReversal & change )

a << operator for ArcReversal

Definition at line 140 of file graphChange.cpp.

140 {
141 return stream << change.toString();
142 }
virtual std::string toString() const final
put the content of the ArcReversal into a string

References gum::learning::ArcReversal::toString().

Here is the call graph for this function:

◆ operator<<() [5/8]

std::ostream & gum::learning::operator<< ( std::ostream & stream,
const EdgeAddition & change )

a << operator for EdgeAddition

Definition at line 145 of file graphChange.cpp.

145 {
146 return stream << change.toString();
147 }
virtual std::string toString() const final
put the content of the EdgeAddition into a string

References gum::learning::EdgeAddition::toString().

Here is the call graph for this function:

◆ operator<<() [6/8]

std::ostream & gum::learning::operator<< ( std::ostream & stream,
const EdgeDeletion & change )

a << operator for EdgeDeletion

Definition at line 150 of file graphChange.cpp.

150 {
151 return stream << change.toString();
152 }
virtual std::string toString() const final
put the content of the EdgeDeletion into a string

References gum::learning::EdgeDeletion::toString().

Here is the call graph for this function:

◆ operator<<() [7/8]

std::ostream & gum::learning::operator<< ( std::ostream & stream,
const GraphChange & change )

a << operator for GraphChanges

Definition at line 125 of file graphChange.cpp.

125 {
126 return stream << change.toString();
127 }
virtual std::string toString() const
put the content of the graph change into a string

References gum::learning::GraphChange::toString().

Here is the call graph for this function:

◆ operator<<() [8/8]

std::ostream & gum::learning::operator<< ( std::ostream & stream,
const IdCondSet & idset )

the display operator

◆ priorTypeToString()

const char * gum::learning::priorTypeToString ( PriorType e)
constexprnoexcept

Definition at line 68 of file prior.h.

68 {
69 switch (e) {
70 case PriorType::NoPriorType : return "No prior";
71 case PriorType::DirichletPriorType : return "Dirichlet prior";
72 case PriorType::SmoothingPriorType : return "TriSmoothing prior";
73 case PriorType::BDeuPriorType : return "BDeu prior";
74 }
75 return "Error in prior";
76 }

References BDeuPriorType, DirichletPriorType, NoPriorType, and SmoothingPriorType.

◆ readFile()

DatabaseTable gum::learning::readFile ( const std::string & filename)

Definition at line 389 of file IBNLearner.cpp.

389 {
390 // get the extension of the file
391 if (auto filename_size = Size(filename.size()); filename_size < 4) {
393 "IBNLearner could not determine the "
394 "file type of the database '"
395 << filename << "'")
396 }
397
398 std::string extension = filename.substr(filename.size() - 4);
399 std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower);
400
401 if (extension != ".csv") {
403 "IBNLearner does not support yet this type ('" << extension
404 << "')"
405 "of database file")
406 }
407
408 DBInitializerFromCSV initializer(filename);
409
410 const auto& var_names = initializer.variableNames();
411 const std::size_t nb_vars = var_names.size();
412
413 DBTranslatorSet translator_set;
414 DBTranslator4LabelizedVariable translator;
415 for (std::size_t i = 0; i < nb_vars; ++i) {
416 translator_set.insertTranslator(translator, i);
417 }
418
419 DatabaseTable database(translator_set);
420 database.setVariableNames(initializer.variableNames());
421 initializer.fillDatabase(database);
422
423 return database;
424 }
Exception : a I/O format was not found.
Exception : operation not allowed.
The class representing a tabular database as used by learning tasks.
#define GUM_ERROR(type, msg)
Definition exceptions.h:72
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74

References gum::learning::IDBInitializer::fillDatabase(), GUM_ERROR, gum::learning::DBTranslatorSet::insertTranslator(), gum::learning::DatabaseTable::setVariableNames(), and gum::learning::IDBInitializer::variableNames().

Here is the call graph for this function: