![]() |
aGrUM 3.2.0
a C++ library for (probabilistic) graphical models
|
Learns a k-TBN (structure and/or parameters) from trajectory CSVs. More...
#include <agrum/KTBN/learning/KTBNLearner.h>
Public Member Functions | |
Constructors / Destructors | |
| KTBNLearner (std::string_view dirPath, std::string_view csvBaseName, Size nbSamples, Size k, const std::unordered_set< std::string > &atemporalVars, const std::vector< std::string > &missingSymbols={"?"}, bool induceTypes=true, bool ignoreMissingSymbols=false) | |
| Structure-learning constructor — variable roles supplied explicitly. | |
| KTBNLearner (std::string_view dirPath, std::string_view csvBaseName, Size nbSamples, Size k, const std::vector< std::string > &missingSymbols={"?"}, bool induceTypes=true, bool ignoreMissingSymbols=false) | |
| Structure-learning constructor — atemporal variables inferred from the CSVs. | |
| KTBNLearner (std::string_view dirPath, std::string_view csvBaseName, Size nbSamples, Size k, const BayesNet< GUM_SCALAR > &bn, const std::unordered_set< std::string > &atemporalVars={}, const std::vector< std::string > &missingSymbols={"?"}, bool ignoreMissingSymbols=false) | |
| Variable-schema constructor — types and domains supplied via a BN. | |
| ~KTBNLearner () | |
| destructor | |
Main learning methods | |
| KTBN< GUM_SCALAR > | learnKTBN () override |
| Full learning (structure + CPTs). Mirrors BNLearner::learnBN(). | |
| KTBN< GUM_SCALAR > | learnParameters (const KTBN< GUM_SCALAR > &structure, bool takeIntoAccountScore=true) |
CPTs only, using the arc structure of structure. structure must have the same base variables (names and domains) as those used to construct this learner; mismatches throw at learn time. | |
Score selection (applied to all internal learners) | |
| KTBNLearner< GUM_SCALAR > & | useScoreAIC () override |
| Returns a warning string if the current score and prior are incompatible, empty string otherwise. | |
| KTBNLearner< GUM_SCALAR > & | useScoreBD () override |
| Returns a warning string if the current score and prior are incompatible, empty string otherwise. | |
| KTBNLearner< GUM_SCALAR > & | useScoreBDeu () override |
| Returns a warning string if the current score and prior are incompatible, empty string otherwise. | |
| KTBNLearner< GUM_SCALAR > & | useScoreBIC () override |
| Returns a warning string if the current score and prior are incompatible, empty string otherwise. | |
| KTBNLearner< GUM_SCALAR > & | useScoreLog2Likelihood () override |
| Returns a warning string if the current score and prior are incompatible, empty string otherwise. | |
| KTBNLearner< GUM_SCALAR > & | useScoreMDL () override |
| Returns a warning string if the current score and prior are incompatible, empty string otherwise. | |
| void | useScorefNML () override |
| Returns a warning string if the current score and prior are incompatible, empty string otherwise. | |
| std::string | checkScorePriorCompatibility () const |
| Returns a warning string if the current score and prior are incompatible, empty string otherwise. | |
Algorithm selection (applied to all internal learners) | |
| KTBNLearner< GUM_SCALAR > & | useGreedyHillClimbing () override |
| KTBNLearner< GUM_SCALAR > & | useExtendedGreedyHillClimbing () override |
| KTBNLearner< GUM_SCALAR > & | useLocalSearchWithTabuList (Size tabu_size=100, Size nb_decrease=2) override |
| KTBNLearner< GUM_SCALAR > & | useMIIC () override |
MIIC correction (applied to all internal learners) | |
| KTBNLearner< GUM_SCALAR > & | useNMLCorrection () override |
| Engine-name pairs (tail, head) of arcs flagged as hiding a latent variable by MIIC (merged from all internal learners). Returned as names rather than Arc/NodeId pairs because the internal learners live in independent NodeId spaces, so a bare NodeId would be ambiguous. | |
| KTBNLearner< GUM_SCALAR > & | useMDLCorrection () override |
| Engine-name pairs (tail, head) of arcs flagged as hiding a latent variable by MIIC (merged from all internal learners). Returned as names rather than Arc/NodeId pairs because the internal learners live in independent NodeId spaces, so a bare NodeId would be ambiguous. | |
| KTBNLearner< GUM_SCALAR > & | useNoCorrection () override |
| Engine-name pairs (tail, head) of arcs flagged as hiding a latent variable by MIIC (merged from all internal learners). Returned as names rather than Arc/NodeId pairs because the internal learners live in independent NodeId spaces, so a bare NodeId would be ambiguous. | |
| std::vector< std::pair< std::string, std::string > > | latentVariables () const |
| Engine-name pairs (tail, head) of arcs flagged as hiding a latent variable by MIIC (merged from all internal learners). Returned as names rather than Arc/NodeId pairs because the internal learners live in independent NodeId spaces, so a bare NodeId would be ambiguous. | |
Prior selection (applied to all internal learners) | |
| KTBNLearner< GUM_SCALAR > & | useSmoothingPrior (double weight=1.0) override |
Structural constraints (base names, translated to the relevant internal learner(s)) | |
| KTBNLearner< GUM_SCALAR > & | addForbiddenArc (std::string_view tailNode, std::string_view headNode) override |
Forbid tailNode from ever parenting headNode (engine names, e.g. "X[1]", "C"). | |
| KTBNLearner< GUM_SCALAR > & | addForbiddenArc (std::string_view tailBase, int tailSlice, std::string_view headBase, int headSlice) override |
Forbid one (base, slice) -> (base, slice) arc (KTBN::ATEMPORAL for static). A backward arc (tailSlice > headSlice) is accepted but has no effect: such an arc is already impossible, so forbidding it is a harmless no-op. | |
| KTBNLearner< GUM_SCALAR > & | eraseForbiddenArc (std::string_view tailNode, std::string_view headNode) override |
| Undo a previous addForbiddenArc (engine names, e.g. "X[1]", "C"). | |
| KTBNLearner< GUM_SCALAR > & | eraseForbiddenArc (std::string_view tailBase, int tailSlice, std::string_view headBase, int headSlice) override |
| Undo a previous addForbiddenArc for a specific (base, slice) pair. | |
| KTBNLearner< GUM_SCALAR > & | addMandatoryArc (std::string_view tailNode, std::string_view headNode) override |
Force tailNode to be a parent of headNode (engine names, e.g. "X[1]", "C"). | |
| KTBNLearner< GUM_SCALAR > & | addMandatoryArc (std::string_view tailBase, int tailSlice, std::string_view headBase, int headSlice) override |
| Force one arc, lag stated explicitly via slices (KTBN::ATEMPORAL for static). | |
| KTBNLearner< GUM_SCALAR > & | eraseMandatoryArc (std::string_view tailNode, std::string_view headNode) override |
| Undo a previous addMandatoryArc (engine names, e.g. "X[1]", "C"). | |
| KTBNLearner< GUM_SCALAR > & | eraseMandatoryArc (std::string_view tailBase, int tailSlice, std::string_view headBase, int headSlice) override |
| Undo a previous addMandatoryArc. | |
| KTBNLearner< GUM_SCALAR > & | addForbiddenIntraSliceArc (std::string_view tailBase, std::string_view headBase) override |
Forbid tailBase -> headBase at every intra-slice position (i.e. tailBase[t] -> headBase[t] for all t in [0, k-1]). | |
| KTBNLearner< GUM_SCALAR > & | eraseForbiddenIntraSliceArc (std::string_view tailBase, std::string_view headBase) override |
| Undo a previous addForbiddenIntraSliceArc. | |
| KTBNLearner< GUM_SCALAR > & | addForbiddenArcAllSlices (std::string_view tailBase, std::string_view headBase) override |
Forbid tailBase -> headBase at every causally-possible slice pair (every lag, not just matching slices): tailBase can never be an ancestor of headBase in the learned k-TBN. A temporal->atemporal pair is a no-op (already structurally impossible). | |
| KTBNLearner< GUM_SCALAR > & | eraseForbiddenArcAllSlices (std::string_view tailBase, std::string_view headBase) override |
| Undo a previous addForbiddenArcAllSlices. | |
| KTBNLearner< GUM_SCALAR > & | addNoParentNode (std::string_view base, int slice) override |
| Declare a single (base, slice) node as a root (no parents). | |
| KTBNLearner< GUM_SCALAR > & | addNoParentNode (std::string_view name) override |
| Declare a single node (bracket notation, e.g. "X[2]" or "C") as a root. | |
| KTBNLearner< GUM_SCALAR > & | eraseNoParentNode (std::string_view base, int slice) override |
| Undo a previous addNoParentNode for a single (base, slice) node. | |
| KTBNLearner< GUM_SCALAR > & | eraseNoParentNode (std::string_view name) override |
| Undo addNoParentNode for a node given by bracket notation. | |
| KTBNLearner< GUM_SCALAR > & | addNoChildrenNode (std::string_view base, int slice) override |
| Declare a single (base, slice) node as a leaf (no children). | |
| KTBNLearner< GUM_SCALAR > & | addNoChildrenNode (std::string_view name) override |
| Declare a single node (bracket notation, e.g. "X[2]" or "C") as a leaf. | |
| KTBNLearner< GUM_SCALAR > & | eraseNoChildrenNode (std::string_view base, int slice) override |
| Undo a previous addNoChildrenNode for a single (base, slice) node. | |
| KTBNLearner< GUM_SCALAR > & | eraseNoChildrenNode (std::string_view name) override |
| Undo addNoChildrenNode for a node given by bracket notation. | |
| KTBNLearner< GUM_SCALAR > & | addPossibleEdge (std::string_view tailBase, int tailSlice, std::string_view headBase, int headSlice) override |
| Add a candidate edge for MIIC (only edges explicitly listed are explored). | |
| KTBNLearner< GUM_SCALAR > & | addPossibleEdge (std::string_view tail, std::string_view head) override |
| Add a candidate edge for MIIC using engine names (e.g. "X[1]", "C"). | |
| KTBNLearner< GUM_SCALAR > & | erasePossibleEdge (std::string_view tailBase, int tailSlice, std::string_view headBase, int headSlice) override |
| Undo a previous addPossibleEdge. | |
| KTBNLearner< GUM_SCALAR > & | erasePossibleEdge (std::string_view tail, std::string_view head) override |
| Undo a previous addPossibleEdge using engine names (e.g. "X[1]", "C"). | |
| KTBNLearner< GUM_SCALAR > & | allowArcAdditions (bool allow=true) override |
| Allow or forbid arc additions during structure search. | |
| KTBNLearner< GUM_SCALAR > & | allowArcDeletions (bool allow=true) override |
| Allow or forbid arc deletions during structure search. | |
| KTBNLearner< GUM_SCALAR > & | allowArcReversals (bool allow=true) override |
| Allow or forbid arc reversals during structure search. | |
| KTBNLearner< GUM_SCALAR > & | setMaxIndegree (Size max_indegree) override |
| Cap the number of parents of any single node. | |
Diagnostics | |
| Size | k () const |
| Order \(k\) of the k-TBN being learned. | |
| Size | nbCols () const |
| Number of columns in each CSV, i.e. of base variables (temporal + atemporal). | |
| std::vector< Size > | nbRows () const |
Number of time steps in each trajectory CSV (one entry per sample, in load order). This is the raw trajectory length; the transition table's sliding-window row count for trajectory i is nbRows()[i] - k + 1. | |
| bool | isConstraintBased () const |
| True if the current structure-learning algorithm is constraint-based (e.g. MIIC). | |
| bool | isScoreBased () const |
| True if the current structure-learning algorithm is score-based (e.g. BIC, AIC). | |
| std::string | toString () const |
| Human-readable summary of the learner's current configuration. | |
| std::vector< std::tuple< std::string, std::string, std::string > > | state () const |
| Settings as a vector of (key, value, comment) tuples (mirrors BNLearner::state()). | |
| void | copyState (const KTBNLearner< GUM_SCALAR > &learner) |
| Copy all score/algorithm/prior/constraint settings from another KTBNLearner (does not copy the database). | |
Database accessors | |
| Size | nbSamples () const |
Number of trajectory CSV files loaded (the constructor's nbSamples). | |
| bool | hasMissingValues () const |
| True if any internal database contains missing values. | |
| Size | nbDroppedRows () const |
| Number of rows dropped from the internal databases because they carried a missing symbol. | |
| bool | isIgnoringMissingSymbols () const |
| Whether build() drops the rows carrying a missing symbol. | |
| std::vector< std::string > | names () const |
| Base names (no slice suffix), one entry per base variable (temporal or atemporal), in the original CSV header order. | |
| std::vector< std::size_t > | domainSizes () const |
| Domain sizes of the base variables, in the same column order as names(). | |
| Size | domainSize (std::string_view base) const |
Domain size of the base variable base (e.g. "X", "C"). Engine names (e.g. "X[1]") are also accepted. | |
Private Member Functions | |
| template<class F> | |
| void | _forEachLearner_ (F &&f) |
Apply f to each present internal learner (the atemporal one only when it exists). Factors out the fan-out shared by every score / algorithm / prior / correction / graph-change setter. | |
| template<class F> | |
| void | _forOwningLearner_ (std::string_view tail, std::string_view head, F &&f) |
Apply f to the ONE internal learner that can learn the arc tail -> head, chosen by its head: a slice-(k-1) head belongs to the transition learner, an atemporal->atemporal arc to the atemporal learner, any other head (a past temporal slice) to the initial learner. The three cases are exclusive because build() forces every other node root in the learners that do not own it, so no arc is ever learnable in two of them. | |
| template<class F> | |
| void | _forEachAllSlicesPair_ (std::string_view tailBase, std::string_view headBase, F &&f) const |
Apply f(tailSlice, headSlice) to every causally-possible slice pair of an all-slices constraint between tailBase and headBase. Four shapes: atemporal->atemporal is one pair; an atemporal tail reaches every slice of the head; a temporal tail into an atemporal head is structurally impossible and yields none; two temporal bases give every pair with tailSlice <= headSlice, i.e. every lag. | |
| void | _build_ (std::string_view dirPath, std::string_view csvBaseName, Size nbSamples, const std::vector< std::string > &missingSymbols) |
| reads every trajectory, builds the three DatabaseTables (sliding window, initial-slice flattening, atemporal columns), constructs the BNLearners from them and applies the automatic temporal constraints (slice order, root past slices, temporal->atemporal forbids). Relies solely on prior_ktbn (already fully populated by the time it runs): the column order is read from the first trajectory's header and the atemporal columns are derived from prior_ktbn.atemporalVarNames(). Shared by both constructors. | |
| const std::unordered_set< std::string > & | _atemporalVarNames_ () const override |
| atemporal base names for IKTBNLearner's shared encode/_determineNode_; read straight from the prior k-TBN (the single source of truth). | |
| bool | _isKnownBase_ (std::string_view base) const override |
whether base is one of this learner's variables; read straight from the prior k-TBN, like atemporalVarNames() above. | |
| KTBN< GUM_SCALAR > | _assemble_ (const BayesNet< GUM_SCALAR > &transitionBN, const BayesNet< GUM_SCALAR > &initialBN, const BayesNet< GUM_SCALAR > &atemporalBN) const |
| glues the three parameter-learned BNs into a single k-TBN | |
| KTBNLearner (const KTBNLearner< GUM_SCALAR > &)=delete | |
| KTBNLearner (KTBNLearner< GUM_SCALAR > &&)=delete | |
| KTBNLearner< GUM_SCALAR > & | operator= (const KTBNLearner< GUM_SCALAR > &)=delete |
| KTBNLearner< GUM_SCALAR > & | operator= (KTBNLearner< GUM_SCALAR > &&)=delete |
Static Private Member Functions | |
| static std::unordered_set< std::string > | _inferAtemporalVars_ (std::string_view dirPath, std::string_view csvBaseName, Size nbSamples, Size k, const std::vector< std::string > &missingSymbols) |
checks k >= 2, then delegates the actual scan to the shared IKTBNLearner::scanConstantColumns() (also used by KTBNAdaptiveLearner, hence not duplicated here). The check happens first and here, not inside the shared scan: called once, in the member-initialiser list of the atemporal-inferring constructor, before prior_ktbn exists — before that constructor's body runs the equivalent check in buildPriorFromCSV — so without it here too, a bad k would only be caught after a wasted scan of every trajectory. | |
| static KTBN< GUM_SCALAR > | _buildPriorFromCSV_ (std::string_view dirPath, std::string_view csvBaseName, Size k, const std::unordered_set< std::string > &atemporalVars, const std::vector< std::string > &missingSymbols, bool induceTypes) |
| called in the member-initialiser list of the k-CSV constructor: opens the first trajectory CSV, uses a temporary BNLearner to type the base variables (induceTypes promotes numeric columns to range/integer), builds and returns a KTBN with the right temporal/atemporal classification. Must be static because it is called before the object exists. | |
| static KTBN< GUM_SCALAR > | _buildPriorFromBN_ (Size k, const BayesNet< GUM_SCALAR > &bn, const std::unordered_set< std::string > &atemporalVars) |
called in the member-initialiser list of the BN constructor: builds and returns a KTBN whose variables are copied from bn (one node per base variable, right types/domains) and classified as temporal/atemporal according to atemporalVars. Must be static because it is called before the object exists. | |
Private Attributes | |
| std::unique_ptr< BNLearner< GUM_SCALAR > > | _transitionLearner_ |
| learns the transition kernel (arcs arriving at slice k-1) | |
| std::unique_ptr< BNLearner< GUM_SCALAR > > | _initialLearner_ |
| learns the initial slices 0..k-2 | |
| std::unique_ptr< BNLearner< GUM_SCALAR > > | _atemporalLearner_ |
| learns the atemporal variables (arcs atemporal -> atemporal) | |
| bool | _ignoreMissingSymbols_ {false} |
| prior k-TBN: the single source of truth for k, variable domains, temporal/atemporal classification and engine names. Everything else (base lists, column names) is derived from it on demand. Analogous to the prior BayesNet stored in BNLearner when a reference BN is given. whether build() drops incomplete rows rather than refusing the data | |
| KTBN< GUM_SCALAR > | _prior_ktbn_ |
| Size | _nbDroppedRows_ {0} |
| number of time steps (rows) in each trajectory CSV, in load order. rows build() dropped because they carried a missing symbol | |
| std::vector< Size > | _nbTimeSlices_ |
| Captured once by build() and exposed by nbRows(). This is the raw trajectory length, not the sliding-window row count of the transition table (which is nbTimeSlices[i] - k + 1 summed over trajectories). | |
| Size | _nbTemporalPossibleEdges_ = 0 |
| counts of currently-active possible edges, split by kind: edges with at least one temporal endpoint, and edges between two atemporal variables. Maintained by add/erasePossibleEdge(). When a whitelist is active (temporal count > 0) but no atemporal->atemporal edge is whitelisted, the atemporal learner would otherwise stay unrestricted; learnKTBN() then suppresses it so the whitelist is honoured (no atemporal arc is produced). | |
| Size | _nbAtemporalPossibleEdges_ = 0 |
Name encoding: (base, slice) <-> engine name | |
| std::string | _encode_ (std::string_view base, int slice) const |
| (base, slice) -> engine name ("A[1]" / atemporal engine name). Pure function, shared by every learner. | |
| std::pair< std::string, int > | _determineNode_ (const std::string &name) const |
| engine name -> (base, slice); atemporal names map to KTBN::ATEMPORAL. Shared by every learner; only the atemporal test varies (via atemporalVarNames()). | |
| void | _checkArcTemporallyFeasible_ (std::string_view tail, std::string_view head, std::string_view action) const |
Reject an arc the k-TBN definition can never contain, so eraseForbiddenArc and addMandatoryArc both fail early (before any internal learner is touched) with a uniform message. action is the verb phrase completing "cannot <action> <tail> -> <head>: ..." (e.g. "force the mandatory arc", "un-forbid the arc"). Two arcs are refused: a temporal -> atemporal arc (a time-varying variable can never parent a static one) and a backward-in-time arc (head strictly before tail). | |
| void | _checkBaseIsTemporal_ (std::string_view base, std::string_view context) const |
Throw InvalidArgument unless base is a known temporal base. context completes "cannot appear in <context>" (e.g. "an
intra-slice constraint", "a kernel-relative arc"): every caller rejects an atemporal base for the same underlying reason – it has no per-slice instance – so they share the sentence and vary the setting. | |
| static void | _checkMinimalOrder_ (Size order, std::string_view label) |
Throw InvalidArgument unless order is at least 2, label naming the offending parameter ("k" for the fixed-k learner, "kMax" for the adaptive one). | |
| static std::unordered_set< std::string > | _scanConstantColumns_ (std::string_view dirPath, std::string_view csvBaseName, Size nbSamples, const std::vector< std::string > &missingSymbols) |
| Scans every trajectory and returns the base names classified atemporal: those whose value never changes across the rows of a single trajectory (checked independently per trajectory, so the value may still differ between trajectories). Shared by every atemporal-inferring CSV constructor (KTBNLearner, KTBNAdaptiveLearner): identical scanning logic regardless of which subclass calls it, so duplicating it per subclass would only invite the two copies to drift. Callers are responsible for validating their own arguments (e.g. k/kMax >= 2) before calling this — it does no such check itself, only opens files, so a bad argument would otherwise only be caught after a wasted scan. | |
Learns a k-TBN (structure and/or parameters) from trajectory CSVs.
Implements gum::learning::IKTBNLearner, the configuration interface shared with gum::learning::KTBNAdaptiveLearner (which learns k as well): here the setters apply each setting to the internal learners immediately, since k is fixed at construction.
Definition at line 115 of file KTBNLearner.h.
| gum::learning::KTBNLearner< GUM_SCALAR >::KTBNLearner | ( | std::string_view | dirPath, |
| std::string_view | csvBaseName, | ||
| Size | nbSamples, | ||
| Size | k, | ||
| const std::unordered_set< std::string > & | atemporalVars, | ||
| const std::vector< std::string > & | missingSymbols = {"?"}, | ||
| bool | induceTypes = true, | ||
| bool | ignoreMissingSymbols = false ) |
Structure-learning constructor — variable roles supplied explicitly.
Use this constructor when you want to learn the k-TBN structure from the data. The order \(k\) and the atemporal variable list must be given because they cannot be reliably inferred from the CSVs alone. Variable domains (modality counts) are read from the CSV data.
Internally calls _buildPriorFromCSV_() then _build_().
| dirPath | Directory holding the trajectory CSV files. |
| csvBaseName | Stem of each file name (1-based index and .csv appended, e.g. "traj" -> "traj1.csv", "traj2.csv", ...). |
| nbSamples | Number of CSV files to read. |
| k | Order of the k-TBN. Must be \(\geq 2\). |
| atemporalVars | Base names of the atemporal (static) variables. All other variables found in the CSV header are treated as temporal. Pass an empty set for "every variable is temporal"; it has no default, since omitting it selects the inferring overload below. |
| missingSymbols | Symbols in the CSVs to interpret as missing values. |
| induceTypes | When true (default), columns whose values are all numeric are retyped (integer/range/continuous) instead of being treated as plain labels — same semantics as gum::learning::BNLearner. |
| ignoreMissingSymbols | When true, a row carrying a missing symbol is dropped rather than handed to the internal learners, which cannot cope with one (see nbDroppedRows() and its warning on the distortion this introduces). When false (the default), such data is refused outright. |
std::unordered_set<std::string>{"C","D"} — or pass a named variable. Definition at line 131 of file KTBNLearner_tpl.h.
References KTBNLearner(), _build_(), _buildPriorFromCSV_(), _ignoreMissingSymbols_, _prior_ktbn_, GUM_ERROR, k(), and nbSamples().
Referenced by KTBNLearner(), KTBNLearner(), KTBNLearner(), KTBNLearner(), KTBNLearner(), ~KTBNLearner(), addForbiddenArc(), addForbiddenArc(), addMandatoryArc(), addMandatoryArc(), addNoChildrenNode(), addNoChildrenNode(), addNoParentNode(), addNoParentNode(), addPossibleEdge(), addPossibleEdge(), allowArcAdditions(), allowArcDeletions(), allowArcReversals(), copyState(), eraseForbiddenArc(), eraseMandatoryArc(), eraseNoChildrenNode(), eraseNoChildrenNode(), eraseNoParentNode(), eraseNoParentNode(), erasePossibleEdge(), erasePossibleEdge(), operator=(), operator=(), setMaxIndegree(), useExtendedGreedyHillClimbing(), useGreedyHillClimbing(), useMDLCorrection(), useMIIC(), useNMLCorrection(), useNoCorrection(), useScoreAIC(), useScoreBD(), useScoreBDeu(), useScoreBIC(), useScoreLog2Likelihood(), useScoreMDL(), and useSmoothingPrior().
| gum::learning::KTBNLearner< GUM_SCALAR >::KTBNLearner | ( | std::string_view | dirPath, |
| std::string_view | csvBaseName, | ||
| Size | nbSamples, | ||
| Size | k, | ||
| const std::vector< std::string > & | missingSymbols = {"?"}, | ||
| bool | induceTypes = true, | ||
| bool | ignoreMissingSymbols = false ) |
Structure-learning constructor — atemporal variables inferred from the CSVs.
Same as the explicit-atemporalVars constructor, except the temporal/atemporal classification is inferred instead of supplied: a base variable is classified atemporal iff its value never changes across the rows of any single trajectory. It may still differ between trajectories — this matches the model's actual semantics (constant through time, not constant across samples) rather than requiring one global value, e.g. a per-individual static covariate such as an age or a site identifier. A column with too few non-missing values to ever witness a change is optimistically classified atemporal.
This is a heuristic, not a guarantee: a genuinely temporal variable that happens to hold one value throughout every sampled trajectory (a very short horizon, or a near-deterministic process) will be misclassified as atemporal. Prefer the explicit-atemporalVars constructor whenever the classification is already known.
atemporalVars constructor). An inferred atemporal variable is, by construction, one whose value may vary between trajectories — exactly the case most likely to reveal only one of several modalities in trajectory 1 and later throw UnknownLabelInDatabase. Use the BN-schema constructor if the full domain cannot be guaranteed present in the first trajectory.| dirPath | Directory holding the trajectory CSV files. |
| csvBaseName | Stem of each file name (1-based index and .csv appended, e.g. "traj" -> "traj1.csv", "traj2.csv", ...). |
| nbSamples | Number of CSV files to read. |
| k | Order of the k-TBN. Must be \(\geq 2\). |
| missingSymbols | Symbols in the CSVs to interpret as missing values. |
| induceTypes | When true (default), columns whose values are all numeric are retyped (integer/range/continuous) instead of being treated as plain labels. |
| ignoreMissingSymbols | When true, a row carrying a missing symbol is dropped rather than handed to the internal learners, which cannot cope with one (see nbDroppedRows() and its warning on the distortion this introduces). When false (the default), such data is refused outright. |
Definition at line 173 of file KTBNLearner_tpl.h.
References KTBNLearner(), _inferAtemporalVars_(), k(), and nbSamples().
| gum::learning::KTBNLearner< GUM_SCALAR >::KTBNLearner | ( | std::string_view | dirPath, |
| std::string_view | csvBaseName, | ||
| Size | nbSamples, | ||
| Size | k, | ||
| const BayesNet< GUM_SCALAR > & | bn, | ||
| const std::unordered_set< std::string > & | atemporalVars = {}, | ||
| const std::vector< std::string > & | missingSymbols = {"?"}, | ||
| bool | ignoreMissingSymbols = false ) |
Variable-schema constructor — types and domains supplied via a BN.
Use this constructor when the variable types and domains are already known (e.g. from a reference BN). The BN must contain exactly one node per base variable (temporal or atemporal), with the correct DiscreteVariable type and domain. Arcs in bn are ignored.
Internally calls _buildPriorFromBN_() then _build_().
| dirPath | Directory holding the trajectory CSV files. |
| csvBaseName | Stem of each file name. |
| nbSamples | Number of CSV files to read. |
| k | Order of the k-TBN. Must be \(\geq 2\). |
| bn | A BayesNet with one node per base variable providing variable types and domains. Atemporal variables are identified by atemporalVars. |
| atemporalVars | Base names of the atemporal (static) variables present in bn. |
| missingSymbols | Symbols in the CSVs to interpret as missing values. |
| ignoreMissingSymbols | When true, a row carrying a missing symbol is dropped rather than handed to the internal learners, which cannot cope with one (see nbDroppedRows() and its warning on the distortion this introduces). When false (the default), such data is refused outright. |
Definition at line 198 of file KTBNLearner_tpl.h.
References KTBNLearner(), _build_(), _buildPriorFromBN_(), _ignoreMissingSymbols_, _prior_ktbn_, GUM_ERROR, k(), and nbSamples().
| gum::learning::KTBNLearner< GUM_SCALAR >::~KTBNLearner | ( | ) |
destructor
Definition at line 220 of file KTBNLearner_tpl.h.
References KTBNLearner().
|
privatedelete |
|
privatedelete |
|
private |
glues the three parameter-learned BNs into a single k-TBN
Definition at line 1311 of file KTBNLearner_tpl.h.
References gum::learning::IKTBNLearner< GUM_SCALAR >::_encode_(), _prior_ktbn_, gum::KTBN< GUM_SCALAR >::fromBN(), and k().
Referenced by learnKTBN(), and learnParameters().
|
overrideprivatevirtual |
atemporal base names for IKTBNLearner's shared encode/_determineNode_; read straight from the prior k-TBN (the single source of truth).
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 1298 of file KTBNLearner_tpl.h.
References _prior_ktbn_.
|
private |
reads every trajectory, builds the three DatabaseTables (sliding window, initial-slice flattening, atemporal columns), constructs the BNLearners from them and applies the automatic temporal constraints (slice order, root past slices, temporal->atemporal forbids). Relies solely on prior_ktbn (already fully populated by the time it runs): the column order is read from the first trajectory's header and the atemporal columns are derived from prior_ktbn.atemporalVarNames(). Shared by both constructors.
Definition at line 994 of file KTBNLearner_tpl.h.
References _atemporalLearner_, gum::learning::IKTBNLearner< GUM_SCALAR >::_encode_(), _ignoreMissingSymbols_, _initialLearner_, _nbDroppedRows_, _nbTimeSlices_, _prior_ktbn_, _transitionLearner_, gum::KTBN< GUM_SCALAR >::ATEMPORAL, gum::learning::CSVParser::current(), GUM_ERROR, gum::learning::DatabaseTable::insertRow(), gum::learning::DatabaseTable::insertTranslator(), k(), gum::learning::CSVParser::nbLine(), gum::learning::IDatabaseTable< T_DATA >::nbRows(), nbSamples(), gum::learning::CSVParser::next(), gum::learning::DatabaseTable::reorder(), and gum::learning::DatabaseTable::setVariableNames().
Referenced by KTBNLearner(), and KTBNLearner().
|
staticprivate |
called in the member-initialiser list of the BN constructor: builds and returns a KTBN whose variables are copied from bn (one node per base variable, right types/domains) and classified as temporal/atemporal according to atemporalVars. Must be static because it is called before the object exists.
Definition at line 974 of file KTBNLearner_tpl.h.
References gum::learning::IKTBNLearner< GUM_SCALAR >::_checkMinimalOrder_(), GUM_ERROR, k(), and gum::Variable::name().
Referenced by KTBNLearner().
|
staticprivate |
called in the member-initialiser list of the k-CSV constructor: opens the first trajectory CSV, uses a temporary BNLearner to type the base variables (induceTypes promotes numeric columns to range/integer), builds and returns a KTBN with the right temporal/atemporal classification. Must be static because it is called before the object exists.
Definition at line 933 of file KTBNLearner_tpl.h.
References gum::learning::IKTBNLearner< GUM_SCALAR >::_checkMinimalOrder_(), GUM_ERROR, k(), names(), gum::learning::DBTranslatorSet::translatorSafe(), and gum::learning::DBTranslator::variable().
Referenced by KTBNLearner().
|
protectedinherited |
Reject an arc the k-TBN definition can never contain, so eraseForbiddenArc and addMandatoryArc both fail early (before any internal learner is touched) with a uniform message. action is the verb phrase completing "cannot <action> <tail> -> <head>: ..." (e.g. "force the mandatory arc", "un-forbid the arc"). Two arcs are refused: a temporal -> atemporal arc (a time-varying variable can never parent a static one) and a backward-in-time arc (head strictly before tail).
Definition at line 95 of file IKTBNLearner_tpl.h.
References _determineNode_(), gum::KTBN< GUM_SCALAR >::ATEMPORAL, and GUM_ERROR.
Referenced by _isKnownBase_(), gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::addMandatoryArc(), gum::learning::KTBNLearner< GUM_SCALAR >::addMandatoryArc(), gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::eraseForbiddenArc(), and gum::learning::KTBNLearner< GUM_SCALAR >::eraseForbiddenArc().
|
protectedinherited |
Throw InvalidArgument unless base is a known temporal base. context completes "cannot appear in <context>" (e.g. "an
intra-slice constraint", "a kernel-relative arc"): every caller rejects an atemporal base for the same underlying reason – it has no per-slice instance – so they share the sentence and vary the setting.
Definition at line 196 of file IKTBNLearner_tpl.h.
References _atemporalVarNames_(), _isKnownBase_(), gum::contains(), and GUM_ERROR.
Referenced by _isKnownBase_(), gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::_verifyKernelArc_(), gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::addForbiddenIntraSliceArc(), gum::learning::KTBNLearner< GUM_SCALAR >::addForbiddenIntraSliceArc(), gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::eraseForbiddenIntraSliceArc(), and gum::learning::KTBNLearner< GUM_SCALAR >::eraseForbiddenIntraSliceArc().
|
staticprotectedinherited |
Throw InvalidArgument unless order is at least 2, label naming the offending parameter ("k" for the fixed-k learner, "kMax" for the adaptive one).
This is a learner constraint, not a model one – gum::KTBN, gum::KTBNGenerator and gum::KTBNInference all accept k = 1 – which is why it lives here rather than on the model. Static because four of its call sites are themselves static helpers invoked from member-initialiser lists, before any object exists.
Definition at line 210 of file IKTBNLearner_tpl.h.
References GUM_ERROR.
Referenced by gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::KTBNAdaptiveLearner(), gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::KTBNAdaptiveLearner(), gum::learning::KTBNLearner< GUM_SCALAR >::_buildPriorFromBN_(), gum::learning::KTBNLearner< GUM_SCALAR >::_buildPriorFromCSV_(), gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::_inferAtemporalVars_(), gum::learning::KTBNLearner< GUM_SCALAR >::_inferAtemporalVars_(), and _isKnownBase_().
|
protectedinherited |
engine name -> (base, slice); atemporal names map to KTBN::ATEMPORAL. Shared by every learner; only the atemporal test varies (via atemporalVarNames()).
Definition at line 64 of file IKTBNLearner_tpl.h.
References _atemporalVarNames_(), gum::KTBN< GUM_SCALAR >::ATEMPORAL, gum::contains(), and GUM_ERROR.
Referenced by gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::_applyConstraints_(), _checkArcTemporallyFeasible_(), gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::_forEachScoredNode_(), gum::learning::KTBNLearner< GUM_SCALAR >::_forOwningLearner_(), _isKnownBase_(), gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::_recomputeKMin_(), gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::addForbiddenArc(), gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::addMandatoryArc(), gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::addNoChildrenNode(), gum::learning::KTBNLearner< GUM_SCALAR >::addNoChildrenNode(), gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::addNoParentNode(), gum::learning::KTBNLearner< GUM_SCALAR >::addNoParentNode(), gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::addPossibleEdge(), gum::learning::KTBNLearner< GUM_SCALAR >::addPossibleEdge(), gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::eraseForbiddenArc(), gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::eraseMandatoryArc(), gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::eraseNoChildrenNode(), gum::learning::KTBNLearner< GUM_SCALAR >::eraseNoChildrenNode(), gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::eraseNoParentNode(), gum::learning::KTBNLearner< GUM_SCALAR >::eraseNoParentNode(), gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::erasePossibleEdge(), gum::learning::KTBNLearner< GUM_SCALAR >::erasePossibleEdge(), and gum::learning::KTBNLearner< GUM_SCALAR >::names().
|
protectedinherited |
(base, slice) -> engine name ("A[1]" / atemporal engine name). Pure function, shared by every learner.
Definition at line 57 of file IKTBNLearner_tpl.h.
References gum::KTBN< GUM_SCALAR >::ATEMPORAL.
Referenced by gum::learning::KTBNLearner< GUM_SCALAR >::_assemble_(), gum::learning::KTBNLearner< GUM_SCALAR >::_build_(), _isKnownBase_(), gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::addForbiddenArc(), gum::learning::KTBNLearner< GUM_SCALAR >::addForbiddenArc(), gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::addMandatoryArc(), gum::learning::KTBNLearner< GUM_SCALAR >::addMandatoryArc(), gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::addNoChildrenNode(), gum::learning::KTBNLearner< GUM_SCALAR >::addNoChildrenNode(), gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::addNoParentNode(), gum::learning::KTBNLearner< GUM_SCALAR >::addNoParentNode(), gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::addPossibleEdge(), gum::learning::KTBNLearner< GUM_SCALAR >::addPossibleEdge(), gum::learning::KTBNLearner< GUM_SCALAR >::domainSize(), gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::eraseForbiddenArc(), gum::learning::KTBNLearner< GUM_SCALAR >::eraseForbiddenArc(), gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::eraseMandatoryArc(), gum::learning::KTBNLearner< GUM_SCALAR >::eraseMandatoryArc(), gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::eraseNoChildrenNode(), gum::learning::KTBNLearner< GUM_SCALAR >::eraseNoChildrenNode(), gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::eraseNoParentNode(), gum::learning::KTBNLearner< GUM_SCALAR >::eraseNoParentNode(), gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::erasePossibleEdge(), gum::learning::KTBNLearner< GUM_SCALAR >::erasePossibleEdge(), and gum::learning::KTBNLearner< GUM_SCALAR >::learnParameters().
|
private |
Apply f(tailSlice, headSlice) to every causally-possible slice pair of an all-slices constraint between tailBase and headBase. Four shapes: atemporal->atemporal is one pair; an atemporal tail reaches every slice of the head; a temporal tail into an atemporal head is structurally impossible and yields none; two temporal bases give every pair with tailSlice <= headSlice, i.e. every lag.
Validates that both bases exist – which the two callers used not to do, letting an unknown name reach a BNLearner as an opaque MissingVariableInDatabase – but deliberately NOT that they are temporal: an atemporal tail is one of the four shapes above.
Definition at line 95 of file KTBNLearner_tpl.h.
References _isKnownBase_(), _prior_ktbn_, gum::KTBN< GUM_SCALAR >::ATEMPORAL, GUM_ERROR, and k().
Referenced by addForbiddenArcAllSlices(), and eraseForbiddenArcAllSlices().
|
private |
Apply f to each present internal learner (the atemporal one only when it exists). Factors out the fan-out shared by every score / algorithm / prior / correction / graph-change setter.
Definition at line 67 of file KTBNLearner_tpl.h.
References _atemporalLearner_, _initialLearner_, and _transitionLearner_.
Referenced by allowArcAdditions(), allowArcDeletions(), allowArcReversals(), setMaxIndegree(), useExtendedGreedyHillClimbing(), useGreedyHillClimbing(), useLocalSearchWithTabuList(), useMDLCorrection(), useMIIC(), useNMLCorrection(), useNoCorrection(), useScoreAIC(), useScoreBD(), useScoreBDeu(), useScoreBIC(), useScorefNML(), useScoreLog2Likelihood(), useScoreMDL(), and useSmoothingPrior().
|
private |
Apply f to the ONE internal learner that can learn the arc tail -> head, chosen by its head: a slice-(k-1) head belongs to the transition learner, an atemporal->atemporal arc to the atemporal learner, any other head (a past temporal slice) to the initial learner. The three cases are exclusive because build() forces every other node root in the learners that do not own it, so no arc is ever learnable in two of them.
The bothAtemp guard matters: without it an "X[0] -> C" arc would be routed to the atemporal learner, whose table has no X[0] column, and surface as MissingVariableInDatabase. It falls to the initial learner instead, where both endpoints exist and the arc is a harmless no-op.
Callers keep their own checkArcTemporallyFeasible call, which is deliberately asymmetric – forbidding an impossible arc is harmless while UN-forbidding it lifts an invariant, and forcing one must be refused while erasing a never-forced one is harmless – so it cannot be folded in here without flattening that asymmetry.
Definition at line 75 of file KTBNLearner_tpl.h.
References _atemporalLearner_, gum::learning::IKTBNLearner< GUM_SCALAR >::_determineNode_(), _initialLearner_, _prior_ktbn_, _transitionLearner_, and gum::KTBN< GUM_SCALAR >::ATEMPORAL.
Referenced by addForbiddenArc(), addMandatoryArc(), eraseForbiddenArc(), and eraseMandatoryArc().
|
staticprivate |
checks k >= 2, then delegates the actual scan to the shared IKTBNLearner::scanConstantColumns() (also used by KTBNAdaptiveLearner, hence not duplicated here). The check happens first and here, not inside the shared scan: called once, in the member-initialiser list of the atemporal-inferring constructor, before prior_ktbn exists — before that constructor's body runs the equivalent check in buildPriorFromCSV — so without it here too, a bad k would only be caught after a wasted scan of every trajectory.
Definition at line 919 of file KTBNLearner_tpl.h.
References gum::learning::IKTBNLearner< GUM_SCALAR >::_checkMinimalOrder_(), gum::learning::IKTBNLearner< GUM_SCALAR >::_scanConstantColumns_(), k(), and nbSamples().
Referenced by KTBNLearner().
|
overrideprivatevirtual |
whether base is one of this learner's variables; read straight from the prior k-TBN, like atemporalVarNames() above.
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 1303 of file KTBNLearner_tpl.h.
References _prior_ktbn_.
Referenced by _forEachAllSlicesPair_().
|
staticprotectedinherited |
Scans every trajectory and returns the base names classified atemporal: those whose value never changes across the rows of a single trajectory (checked independently per trajectory, so the value may still differ between trajectories). Shared by every atemporal-inferring CSV constructor (KTBNLearner, KTBNAdaptiveLearner): identical scanning logic regardless of which subclass calls it, so duplicating it per subclass would only invite the two copies to drift. Callers are responsible for validating their own arguments (e.g. k/kMax >= 2) before calling this — it does no such check itself, only opens files, so a bad argument would otherwise only be caught after a wasted scan.
Column indices still "live" (not yet proven non-constant) are tracked as a shrinking list rather than rescanned from scratch, and scanning stops opening further trajectories once that list is empty — falsification is one-way, so nothing left to test can ever become atemporal again.
Definition at line 113 of file IKTBNLearner_tpl.h.
References gum::learning::CSVParser::current(), GUM_ERROR, gum::learning::CSVParser::nbLine(), and gum::learning::CSVParser::next().
Referenced by gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::_inferAtemporalVars_(), gum::learning::KTBNLearner< GUM_SCALAR >::_inferAtemporalVars_(), and _isKnownBase_().
|
overridevirtual |
Forbid one (base, slice) -> (base, slice) arc (KTBN::ATEMPORAL for static). A backward arc (tailSlice > headSlice) is accepted but has no effect: such an arc is already impossible, so forbidding it is a harmless no-op.
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 465 of file KTBNLearner_tpl.h.
References KTBNLearner(), gum::learning::IKTBNLearner< GUM_SCALAR >::_encode_(), and addForbiddenArc().
|
overridevirtual |
Forbid tailNode from ever parenting headNode (engine names, e.g. "X[1]", "C").
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 456 of file KTBNLearner_tpl.h.
References KTBNLearner(), and _forOwningLearner_().
Referenced by gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::_applyConstraints_(), addForbiddenArc(), addForbiddenArcAllSlices(), and addForbiddenIntraSliceArc().
|
overridevirtual |
Forbid tailBase -> headBase at every causally-possible slice pair (every lag, not just matching slices): tailBase can never be an ancestor of headBase in the learned k-TBN. A temporal->atemporal pair is a no-op (already structurally impossible).
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 567 of file KTBNLearner_tpl.h.
References _forEachAllSlicesPair_(), and addForbiddenArc().
Referenced by gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::_applyConstraints_().
|
overridevirtual |
Forbid tailBase -> headBase at every intra-slice position (i.e. tailBase[t] -> headBase[t] for all t in [0, k-1]).
| InvalidArgument | if either endpoint is unknown or atemporal (an atemporal variable has no intra-slice position). |
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 541 of file KTBNLearner_tpl.h.
References gum::learning::IKTBNLearner< GUM_SCALAR >::_checkBaseIsTemporal_(), _prior_ktbn_, addForbiddenArc(), and k().
Referenced by gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::_applyConstraints_().
|
overridevirtual |
Force one arc, lag stated explicitly via slices (KTBN::ATEMPORAL for static).
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 511 of file KTBNLearner_tpl.h.
References KTBNLearner(), gum::learning::IKTBNLearner< GUM_SCALAR >::_encode_(), and addMandatoryArc().
|
overridevirtual |
Force tailNode to be a parent of headNode (engine names, e.g. "X[1]", "C").
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 495 of file KTBNLearner_tpl.h.
References KTBNLearner(), gum::learning::IKTBNLearner< GUM_SCALAR >::_checkArcTemporallyFeasible_(), and _forOwningLearner_().
Referenced by gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::_applyConstraints_(), and addMandatoryArc().
|
overridevirtual |
Declare a single (base, slice) node as a leaf (no children).
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 627 of file KTBNLearner_tpl.h.
References KTBNLearner(), gum::learning::IKTBNLearner< GUM_SCALAR >::_encode_(), and addNoChildrenNode().
Referenced by gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::_applyConstraints_(), and addNoChildrenNode().
|
overridevirtual |
Declare a single node (bracket notation, e.g. "X[2]" or "C") as a leaf.
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 633 of file KTBNLearner_tpl.h.
References KTBNLearner(), _atemporalLearner_, gum::learning::IKTBNLearner< GUM_SCALAR >::_determineNode_(), _initialLearner_, _prior_ktbn_, _transitionLearner_, and gum::KTBN< GUM_SCALAR >::ATEMPORAL.
|
overridevirtual |
Declare a single (base, slice) node as a root (no parents).
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 586 of file KTBNLearner_tpl.h.
References KTBNLearner(), gum::learning::IKTBNLearner< GUM_SCALAR >::_encode_(), and addNoParentNode().
Referenced by gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::_applyConstraints_(), and addNoParentNode().
|
overridevirtual |
Declare a single node (bracket notation, e.g. "X[2]" or "C") as a root.
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 592 of file KTBNLearner_tpl.h.
References KTBNLearner(), _atemporalLearner_, gum::learning::IKTBNLearner< GUM_SCALAR >::_determineNode_(), _initialLearner_, _prior_ktbn_, _transitionLearner_, and gum::KTBN< GUM_SCALAR >::ATEMPORAL.
|
overridevirtual |
Add a candidate edge for MIIC using engine names (e.g. "X[1]", "C").
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 677 of file KTBNLearner_tpl.h.
References KTBNLearner(), _atemporalLearner_, gum::learning::IKTBNLearner< GUM_SCALAR >::_determineNode_(), _initialLearner_, _nbAtemporalPossibleEdges_, _nbTemporalPossibleEdges_, _prior_ktbn_, _transitionLearner_, and gum::KTBN< GUM_SCALAR >::ATEMPORAL.
|
overridevirtual |
Add a candidate edge for MIIC (only edges explicitly listed are explored).
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 659 of file KTBNLearner_tpl.h.
References KTBNLearner(), gum::learning::IKTBNLearner< GUM_SCALAR >::_encode_(), and addPossibleEdge().
Referenced by gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::_applyConstraints_(), and addPossibleEdge().
|
overridevirtual |
Allow or forbid arc additions during structure search.
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 722 of file KTBNLearner_tpl.h.
References KTBNLearner(), and _forEachLearner_().
Referenced by gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::_applyConstraints_().
|
overridevirtual |
Allow or forbid arc deletions during structure search.
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 728 of file KTBNLearner_tpl.h.
References KTBNLearner(), and _forEachLearner_().
Referenced by gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::_applyConstraints_().
|
overridevirtual |
Allow or forbid arc reversals during structure search.
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 734 of file KTBNLearner_tpl.h.
References KTBNLearner(), and _forEachLearner_().
Referenced by gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::_applyConstraints_().
| std::string gum::learning::KTBNLearner< GUM_SCALAR >::checkScorePriorCompatibility | ( | ) | const |
Returns a warning string if the current score and prior are incompatible, empty string otherwise.
Definition at line 356 of file KTBNLearner_tpl.h.
References _transitionLearner_.
| void gum::learning::KTBNLearner< GUM_SCALAR >::copyState | ( | const KTBNLearner< GUM_SCALAR > & | learner | ) |
Copy all score/algorithm/prior/constraint settings from another KTBNLearner (does not copy the database).
Definition at line 834 of file KTBNLearner_tpl.h.
References KTBNLearner(), _atemporalLearner_, _initialLearner_, _nbAtemporalPossibleEdges_, _nbTemporalPossibleEdges_, and _transitionLearner_.
| Size gum::learning::KTBNLearner< GUM_SCALAR >::domainSize | ( | std::string_view | base | ) | const |
Domain size of the base variable base (e.g. "X", "C"). Engine names (e.g. "X[1]") are also accepted.
Definition at line 902 of file KTBNLearner_tpl.h.
References gum::learning::IKTBNLearner< GUM_SCALAR >::_encode_(), _prior_ktbn_, _transitionLearner_, and gum::KTBN< GUM_SCALAR >::ATEMPORAL.
| std::vector< Size > gum::learning::KTBNLearner< GUM_SCALAR >::domainSizes | ( | ) | const |
Domain sizes of the base variables, in the same column order as names().
Definition at line 894 of file KTBNLearner_tpl.h.
References _transitionLearner_, and nbCols().
|
overridevirtual |
Undo a previous addForbiddenArc for a specific (base, slice) pair.
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 487 of file KTBNLearner_tpl.h.
References KTBNLearner(), gum::learning::IKTBNLearner< GUM_SCALAR >::_encode_(), and eraseForbiddenArc().
|
overridevirtual |
Undo a previous addForbiddenArc (engine names, e.g. "X[1]", "C").
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 475 of file KTBNLearner_tpl.h.
References gum::learning::IKTBNLearner< GUM_SCALAR >::_checkArcTemporallyFeasible_(), and _forOwningLearner_().
Referenced by eraseForbiddenArc(), eraseForbiddenArcAllSlices(), and eraseForbiddenIntraSliceArc().
|
overridevirtual |
Undo a previous addForbiddenArcAllSlices.
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 577 of file KTBNLearner_tpl.h.
References _forEachAllSlicesPair_(), and eraseForbiddenArc().
|
overridevirtual |
Undo a previous addForbiddenIntraSliceArc.
| InvalidArgument | under the same conditions as addForbiddenIntraSliceArc. |
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 555 of file KTBNLearner_tpl.h.
References gum::learning::IKTBNLearner< GUM_SCALAR >::_checkBaseIsTemporal_(), _prior_ktbn_, eraseForbiddenArc(), and k().
|
overridevirtual |
Undo a previous addMandatoryArc.
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 532 of file KTBNLearner_tpl.h.
References KTBNLearner(), gum::learning::IKTBNLearner< GUM_SCALAR >::_encode_(), and eraseMandatoryArc().
|
overridevirtual |
Undo a previous addMandatoryArc (engine names, e.g. "X[1]", "C").
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 521 of file KTBNLearner_tpl.h.
References _forOwningLearner_().
Referenced by eraseMandatoryArc().
|
overridevirtual |
Undo a previous addNoChildrenNode for a single (base, slice) node.
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 643 of file KTBNLearner_tpl.h.
References KTBNLearner(), gum::learning::IKTBNLearner< GUM_SCALAR >::_encode_(), and eraseNoChildrenNode().
Referenced by eraseNoChildrenNode().
|
overridevirtual |
Undo addNoChildrenNode for a node given by bracket notation.
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 649 of file KTBNLearner_tpl.h.
References KTBNLearner(), _atemporalLearner_, gum::learning::IKTBNLearner< GUM_SCALAR >::_determineNode_(), _initialLearner_, _prior_ktbn_, _transitionLearner_, and gum::KTBN< GUM_SCALAR >::ATEMPORAL.
|
overridevirtual |
Undo a previous addNoParentNode for a single (base, slice) node.
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 607 of file KTBNLearner_tpl.h.
References KTBNLearner(), gum::learning::IKTBNLearner< GUM_SCALAR >::_encode_(), and eraseNoParentNode().
Referenced by eraseNoParentNode().
|
overridevirtual |
Undo addNoParentNode for a node given by bracket notation.
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 613 of file KTBNLearner_tpl.h.
References KTBNLearner(), _atemporalLearner_, gum::learning::IKTBNLearner< GUM_SCALAR >::_determineNode_(), _initialLearner_, _prior_ktbn_, _transitionLearner_, and gum::KTBN< GUM_SCALAR >::ATEMPORAL.
|
overridevirtual |
Undo a previous addPossibleEdge using engine names (e.g. "X[1]", "C").
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 703 of file KTBNLearner_tpl.h.
References KTBNLearner(), _atemporalLearner_, gum::learning::IKTBNLearner< GUM_SCALAR >::_determineNode_(), _initialLearner_, _nbAtemporalPossibleEdges_, _nbTemporalPossibleEdges_, _prior_ktbn_, _transitionLearner_, and gum::KTBN< GUM_SCALAR >::ATEMPORAL.
|
overridevirtual |
Undo a previous addPossibleEdge.
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 669 of file KTBNLearner_tpl.h.
References KTBNLearner(), gum::learning::IKTBNLearner< GUM_SCALAR >::_encode_(), and erasePossibleEdge().
Referenced by erasePossibleEdge().
| bool gum::learning::KTBNLearner< GUM_SCALAR >::hasMissingValues | ( | ) | const |
True if any internal database contains missing values.
false since build() performs complete-case selection: a row carrying a missing symbol is never inserted, so the databases hold no gap by construction. To learn whether the CSVs actually had any, read nbDroppedRows() instead. Definition at line 873 of file KTBNLearner_tpl.h.
References _atemporalLearner_, _initialLearner_, and _transitionLearner_.
| bool gum::learning::KTBNLearner< GUM_SCALAR >::isConstraintBased | ( | ) | const |
True if the current structure-learning algorithm is constraint-based (e.g. MIIC).
Definition at line 768 of file KTBNLearner_tpl.h.
References _transitionLearner_.
| INLINE bool gum::learning::KTBNLearner< GUM_SCALAR >::isIgnoringMissingSymbols | ( | ) | const |
Whether build() drops the rows carrying a missing symbol.
Definition at line 863 of file KTBNLearner_tpl.h.
References _ignoreMissingSymbols_.
| bool gum::learning::KTBNLearner< GUM_SCALAR >::isScoreBased | ( | ) | const |
True if the current structure-learning algorithm is score-based (e.g. BIC, AIC).
Definition at line 773 of file KTBNLearner_tpl.h.
References _transitionLearner_.
| Size gum::learning::KTBNLearner< GUM_SCALAR >::k | ( | ) | const |
Order \(k\) of the k-TBN being learned.
Definition at line 750 of file KTBNLearner_tpl.h.
References _prior_ktbn_.
Referenced by KTBNLearner(), KTBNLearner(), KTBNLearner(), _assemble_(), _build_(), _buildPriorFromBN_(), _buildPriorFromCSV_(), _forEachAllSlicesPair_(), _inferAtemporalVars_(), addForbiddenIntraSliceArc(), eraseForbiddenIntraSliceArc(), learnParameters(), and toString().
| std::vector< std::pair< std::string, std::string > > gum::learning::KTBNLearner< GUM_SCALAR >::latentVariables | ( | ) | const |
Engine-name pairs (tail, head) of arcs flagged as hiding a latent variable by MIIC (merged from all internal learners). Returned as names rather than Arc/NodeId pairs because the internal learners live in independent NodeId spaces, so a bare NodeId would be ambiguous.
Definition at line 417 of file KTBNLearner_tpl.h.
References _atemporalLearner_, _initialLearner_, and _transitionLearner_.
|
overridevirtual |
Full learning (structure + CPTs). Mirrors BNLearner::learnBN().
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 229 of file KTBNLearner_tpl.h.
References _assemble_(), _atemporalLearner_, _initialLearner_, _nbAtemporalPossibleEdges_, _nbTemporalPossibleEdges_, and _transitionLearner_.
| KTBN< GUM_SCALAR > gum::learning::KTBNLearner< GUM_SCALAR >::learnParameters | ( | const KTBN< GUM_SCALAR > & | structure, |
| bool | takeIntoAccountScore = true ) |
CPTs only, using the arc structure of structure. structure must have the same base variables (names and domains) as those used to construct this learner; mismatches throw at learn time.
Definition at line 246 of file KTBNLearner_tpl.h.
References _assemble_(), _atemporalLearner_, gum::learning::IKTBNLearner< GUM_SCALAR >::_encode_(), _initialLearner_, _prior_ktbn_, _transitionLearner_, gum::DAG::addArc(), gum::NodeGraphPart::addNodeWithId(), gum::KTBN< GUM_SCALAR >::ATEMPORAL, GUM_ERROR, and k().
| std::vector< std::string > gum::learning::KTBNLearner< GUM_SCALAR >::names | ( | ) | const |
Base names (no slice suffix), one entry per base variable (temporal or atemporal), in the original CSV header order.
Definition at line 879 of file KTBNLearner_tpl.h.
References gum::learning::IKTBNLearner< GUM_SCALAR >::_determineNode_(), _transitionLearner_, and nbCols().
Referenced by _buildPriorFromCSV_().
| Size gum::learning::KTBNLearner< GUM_SCALAR >::nbCols | ( | ) | const |
Number of columns in each CSV, i.e. of base variables (temporal + atemporal).
Definition at line 755 of file KTBNLearner_tpl.h.
References _prior_ktbn_.
Referenced by domainSizes(), names(), and toString().
| INLINE Size gum::learning::KTBNLearner< GUM_SCALAR >::nbDroppedRows | ( | ) | const |
Number of rows dropped from the internal databases because they carried a missing symbol.
aGrUM's structure learning refuses a database holding any missing value (gum::learning::IBNLearner::learnDag_), so build() performs complete-case selection: a row is inserted only if every cell it needs is observed. This mirrors the cross-k score, which likewise skips any instance whose family is incomplete, so both layers agree on which data counts. hasMissingValues() is consequently always false.
The unit differs per table: a transition row is a whole width-k window, so one gap costs up to \(k\) of them; an initial or atemporal row is a whole trajectory's contribution.
A row is dropped as soon as one cell of the window it feeds is missing, so a single gap costs up to \(k\) transition rows. A larger \(k\) spans more rows per window and therefore loses proportionally more of them.
That matters because \(\log_2 L\) is a sum of per-instance terms, every one of which is \(\leq 0\). Scoring fewer instances removes negative terms, so it raises the total — a model does not fit better, it is simply charged for less. Two consequences:
The effect grows with the missing-value rate. Read bestK() and scorePerCandidateK() with that in mind, and prefer complete trajectories whenever the order itself is the question being asked.
Definition at line 868 of file KTBNLearner_tpl.h.
References _nbDroppedRows_.
| std::vector< Size > gum::learning::KTBNLearner< GUM_SCALAR >::nbRows | ( | ) | const |
Number of time steps in each trajectory CSV (one entry per sample, in load order). This is the raw trajectory length; the transition table's sliding-window row count for trajectory i is nbRows()[i] - k + 1.
Definition at line 760 of file KTBNLearner_tpl.h.
References _nbTimeSlices_.
| Size gum::learning::KTBNLearner< GUM_SCALAR >::nbSamples | ( | ) | const |
Number of trajectory CSV files loaded (the constructor's nbSamples).
Definition at line 856 of file KTBNLearner_tpl.h.
References _initialLearner_.
Referenced by KTBNLearner(), KTBNLearner(), KTBNLearner(), _build_(), and _inferAtemporalVars_().
|
privatedelete |
|
privatedelete |
|
overridevirtual |
Cap the number of parents of any single node.
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 740 of file KTBNLearner_tpl.h.
References KTBNLearner(), and _forEachLearner_().
Referenced by gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::_applyConstraints_().
| std::vector< std::tuple< std::string, std::string, std::string > > gum::learning::KTBNLearner< GUM_SCALAR >::state | ( | ) | const |
Settings as a vector of (key, value, comment) tuples (mirrors BNLearner::state()).
Definition at line 803 of file KTBNLearner_tpl.h.
References _prior_ktbn_, _transitionLearner_, and gum::KTBN< GUM_SCALAR >::ATEMPORAL.
| std::string gum::learning::KTBNLearner< GUM_SCALAR >::toString | ( | ) | const |
Human-readable summary of the learner's current configuration.
Definition at line 778 of file KTBNLearner_tpl.h.
References _atemporalLearner_, _initialLearner_, _prior_ktbn_, _transitionLearner_, k(), and nbCols().
|
overridevirtual |
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 374 of file KTBNLearner_tpl.h.
References KTBNLearner(), and _forEachLearner_().
Referenced by gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::_applyConfig_().
|
overridevirtual |
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 368 of file KTBNLearner_tpl.h.
References KTBNLearner(), and _forEachLearner_().
Referenced by gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::_applyConfig_().
|
overridevirtual |
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 381 of file KTBNLearner_tpl.h.
References _forEachLearner_().
Referenced by gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::_applyConfig_().
|
overridevirtual |
Engine-name pairs (tail, head) of arcs flagged as hiding a latent variable by MIIC (merged from all internal learners). Returned as names rather than Arc/NodeId pairs because the internal learners live in independent NodeId spaces, so a bare NodeId would be ambiguous.
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 404 of file KTBNLearner_tpl.h.
References KTBNLearner(), and _forEachLearner_().
|
overridevirtual |
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 388 of file KTBNLearner_tpl.h.
References KTBNLearner(), and _forEachLearner_().
|
overridevirtual |
Engine-name pairs (tail, head) of arcs flagged as hiding a latent variable by MIIC (merged from all internal learners). Returned as names rather than Arc/NodeId pairs because the internal learners live in independent NodeId spaces, so a bare NodeId would be ambiguous.
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 398 of file KTBNLearner_tpl.h.
References KTBNLearner(), and _forEachLearner_().
Referenced by gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::_applyConfig_().
|
overridevirtual |
Engine-name pairs (tail, head) of arcs flagged as hiding a latent variable by MIIC (merged from all internal learners). Returned as names rather than Arc/NodeId pairs because the internal learners live in independent NodeId spaces, so a bare NodeId would be ambiguous.
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 410 of file KTBNLearner_tpl.h.
References KTBNLearner(), and _forEachLearner_().
Referenced by gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::_applyConfig_().
|
overridevirtual |
Returns a warning string if the current score and prior are incompatible, empty string otherwise.
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 315 of file KTBNLearner_tpl.h.
References KTBNLearner(), and _forEachLearner_().
Referenced by gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::_applyConfig_().
|
overridevirtual |
Returns a warning string if the current score and prior are incompatible, empty string otherwise.
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 321 of file KTBNLearner_tpl.h.
References KTBNLearner(), and _forEachLearner_().
Referenced by gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::_applyConfig_().
|
overridevirtual |
Returns a warning string if the current score and prior are incompatible, empty string otherwise.
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 327 of file KTBNLearner_tpl.h.
References KTBNLearner(), and _forEachLearner_().
|
overridevirtual |
Returns a warning string if the current score and prior are incompatible, empty string otherwise.
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 333 of file KTBNLearner_tpl.h.
References KTBNLearner(), and _forEachLearner_().
Referenced by gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::_applyConfig_().
|
overridevirtual |
Returns a warning string if the current score and prior are incompatible, empty string otherwise.
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 351 of file KTBNLearner_tpl.h.
References _forEachLearner_().
Referenced by gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::_applyConfig_().
|
overridevirtual |
Returns a warning string if the current score and prior are incompatible, empty string otherwise.
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 339 of file KTBNLearner_tpl.h.
References KTBNLearner(), and _forEachLearner_().
Referenced by gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::_applyConfig_().
|
overridevirtual |
Returns a warning string if the current score and prior are incompatible, empty string otherwise.
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 345 of file KTBNLearner_tpl.h.
References KTBNLearner(), and _forEachLearner_().
Referenced by gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::_applyConfig_().
|
overridevirtual |
Implements gum::learning::IKTBNLearner< GUM_SCALAR >.
Definition at line 446 of file KTBNLearner_tpl.h.
References KTBNLearner(), and _forEachLearner_().
Referenced by gum::learning::KTBNAdaptiveLearner< GUM_SCALAR >::_applyConfig_().
|
private |
learns the atemporal variables (arcs atemporal -> atemporal)
Definition at line 580 of file KTBNLearner.h.
Referenced by _build_(), _forEachLearner_(), _forOwningLearner_(), addNoChildrenNode(), addNoParentNode(), addPossibleEdge(), copyState(), eraseNoChildrenNode(), eraseNoParentNode(), erasePossibleEdge(), hasMissingValues(), latentVariables(), learnKTBN(), learnParameters(), and toString().
|
private |
prior k-TBN: the single source of truth for k, variable domains, temporal/atemporal classification and engine names. Everything else (base lists, column names) is derived from it on demand. Analogous to the prior BayesNet stored in BNLearner when a reference BN is given. whether build() drops incomplete rows rather than refusing the data
Definition at line 587 of file KTBNLearner.h.
Referenced by KTBNLearner(), KTBNLearner(), _build_(), and isIgnoringMissingSymbols().
|
private |
learns the initial slices 0..k-2
Definition at line 577 of file KTBNLearner.h.
Referenced by _build_(), _forEachLearner_(), _forOwningLearner_(), addNoChildrenNode(), addNoParentNode(), addPossibleEdge(), copyState(), eraseNoChildrenNode(), eraseNoParentNode(), erasePossibleEdge(), hasMissingValues(), latentVariables(), learnKTBN(), learnParameters(), nbSamples(), and toString().
|
private |
Definition at line 607 of file KTBNLearner.h.
Referenced by addPossibleEdge(), copyState(), erasePossibleEdge(), and learnKTBN().
|
private |
number of time steps (rows) in each trajectory CSV, in load order. rows build() dropped because they carried a missing symbol
Definition at line 593 of file KTBNLearner.h.
Referenced by _build_(), and nbDroppedRows().
|
private |
counts of currently-active possible edges, split by kind: edges with at least one temporal endpoint, and edges between two atemporal variables. Maintained by add/erasePossibleEdge(). When a whitelist is active (temporal count > 0) but no atemporal->atemporal edge is whitelisted, the atemporal learner would otherwise stay unrestricted; learnKTBN() then suppresses it so the whitelist is honoured (no atemporal arc is produced).
Definition at line 606 of file KTBNLearner.h.
Referenced by addPossibleEdge(), copyState(), erasePossibleEdge(), and learnKTBN().
|
private |
Captured once by build() and exposed by nbRows(). This is the raw trajectory length, not the sliding-window row count of the transition table (which is nbTimeSlices[i] - k + 1 summed over trajectories).
Definition at line 598 of file KTBNLearner.h.
|
private |
Definition at line 589 of file KTBNLearner.h.
Referenced by KTBNLearner(), KTBNLearner(), _assemble_(), _atemporalVarNames_(), _build_(), _forEachAllSlicesPair_(), _forOwningLearner_(), _isKnownBase_(), addForbiddenIntraSliceArc(), addNoChildrenNode(), addNoParentNode(), addPossibleEdge(), domainSize(), eraseForbiddenIntraSliceArc(), eraseNoChildrenNode(), eraseNoParentNode(), erasePossibleEdge(), k(), learnParameters(), nbCols(), state(), and toString().
|
private |
learns the transition kernel (arcs arriving at slice k-1)
Definition at line 574 of file KTBNLearner.h.
Referenced by _build_(), _forEachLearner_(), _forOwningLearner_(), addNoChildrenNode(), addNoParentNode(), addPossibleEdge(), checkScorePriorCompatibility(), copyState(), domainSize(), domainSizes(), eraseNoChildrenNode(), eraseNoParentNode(), erasePossibleEdge(), hasMissingValues(), isConstraintBased(), isScoreBased(), latentVariables(), learnKTBN(), learnParameters(), names(), state(), and toString().