|
cMHN 1.0
C++ library for learning MHNs with pRC
|
Namespaces | |
| namespace | nonTT |
| namespace | TT |
Classes | |
| class | KLepsScore |
| Class storing a KL-epsilon Score, specializes the Score class. More... | |
| class | KLScore |
| Class storing a KL Score, specializes the Score class. More... | |
| class | KLTHScore |
| Class storing a KL-Taylor-Hybrid Score, specializes the Score class. More... | |
| class | L1Regulator |
| Class storing an L1 Regulator, specializes the Regulator class. More... | |
| class | L2Regulator |
| Class storing an L2 Regulator, specializes the Regulator class. More... | |
| class | Regulator |
| Class storing all relevant information for a regulator. More... | |
| class | Score |
| Class storing all relevant information for a score. More... | |
Functions | |
| template<class T , class X , pRC::Size D> | |
| X | calculatePTheta (nonTT::MHNOperator< T, D > const &op, X const &pInit, T const &toleranceSolver) |
| Calculates the vector pTheta given a nonTT MHN Operator and a tolerance. More... | |
| template<class T , pRC::Size D> | |
| auto | calculatePTheta (nonTT::MHNOperator< T, D > const &op, T const &toleranceSolver) |
| Calculates the vector pTheta given a nonTT MHN Operator and a tolerance. More... | |
| template<pRC::Size R, class T , class X , pRC::Size D> | |
| X | calculatePTheta (TT::MHNOperator< T, D > const &op, X const &pInit, T const &toleranceSolver) |
| Calculates the vector pTheta (as a TT) given a TT MHN Operator and a tolerance. More... | |
| template<pRC::Size R, class T , pRC::Size D> | |
| auto | calculatePTheta (TT::MHNOperator< T, D > const &op, T const &toleranceSolver) |
| Calculates the vector pTheta (as a TT) given a TT MHN Operator and a tolerance. More... | |
| template<class T , pRC::Size D, class S > | |
| T | calculateScore (nonTT::MHNOperator< T, D > const &op, std::map< S, T > const &pD, cMHN::Score< T > const &Score, cMHN::Regulator< T, D > const &Regulator, T const &toleranceSolverP=1e-4) |
| Calculate score of a theta matrix given some data distribution pD. More... | |
| template<pRC::Size RP, class T , pRC::Size D, class S > | |
| T | calculateScore (TT::MHNOperator< T, D > const &op, std::map< S, T > const &pD, cMHN::Score< T > const &Score, cMHN::Regulator< T, D > const &Regulator, T const &toleranceSolverP=1e-4) |
| Calculate score of a theta matrix given some data distribution pD (using TTs) More... | |
| template<class T , pRC::Size D, class S > | |
| std::tuple< T, pRC::Tensor< T, D, D > > | calculateScoreAndGradient (nonTT::MHNOperator< T, D > const &op, std::map< S, T > const &pD, cMHN::Score< T > const &Score, cMHN::Regulator< T, D > const &Regulator, T const &toleranceSolverP=1e-4, T const &toleranceSolverQ=1e-4) |
| Calculate score and gradient of a theta matrix given some data distribution pD. More... | |
| template<pRC::Size RP, pRC::Size RQ, class T , pRC::Size D, class S > | |
| std::tuple< T, pRC::Tensor< T, D, D > > | calculateScoreAndGradient (TT::MHNOperator< T, D > const &op, std::map< S, T > const &pD, cMHN::Score< T > const &Score, cMHN::Regulator< T, D > const &Regulator, T const &toleranceSolverP=1e-4, T const &toleranceSolverQ=1e-4) |
| Calculate score and gradient of a theta matrix given some distribution pD (using TTs) More... | |
| template<class T , class S > | |
| static auto | learnIndependenceModel (std::map< S, T > const &pD) |
| Calculate the theta matrix corresponding to the independence model for a given data distribution. More... | |
| template<class T , class S > | |
| static auto | combinePDs (std::vector< std::map< S, T > > const &pDs, std::vector< pRC::Index > const &lengths) |
| Combines multiple data distributions into a single distribution. More... | |
| template<class T , pRC::Size D> | |
| static auto | generatePD (pRC::RandomEngine &rng, nonTT::MHNOperator< T, D > const &op, pRC::Size const &size, T const &toleranceSolverP) |
| Generates a data distribution from a given nonTT MHNOperator. More... | |
| template<class T , pRC::Size D> | |
| static auto | generatePD (nonTT::MHNOperator< T, D > const &op, pRC::Size const &size, T const &toleranceSolverP) |
| Generates a data distribution from a given nonTT MHNOperator. More... | |
| template<pRC::Size RP, class T , pRC::Size D> | |
| static auto | generatePD (pRC::RandomEngine &rng, TT::MHNOperator< T, D > const &op, pRC::Size const &size, T const &toleranceSolverP) |
| Generates a data distribution from a given TT MHNOperator. More... | |
| template<pRC::Size RP, class T , pRC::Size D> | |
| static auto | generatePD (TT::MHNOperator< T, D > const &op, pRC::Size const &size, T const &toleranceSolverP) |
| Generates a data distribution from a given TT MHNOperator. More... | |
| template<pRC::Size D, class T = pRC::Float<>> | |
| static auto | generateTheta (pRC::RandomEngine &rng, pRC::Float<> const &fullness=0.5, T const &diagonalMean=-2, T const &diagonalStd=2, T const &offDiagonalMean=0, T const &offDiagonalB=0.75) |
| Generates a random theta matrix according to given distributions, and with given fullness. More... | |
| template<pRC::Size D, class T = pRC::Float<>> | |
| static auto | generateTheta (pRC::Float<> const &fullness=0.5, T const &diagonalMean=-2, T const &diagonalStd=2, T const &offDiagonalMean=0, T const &offDiagonalB=0.75) |
| Generates a random theta matrix according to given distributions, and with given fullness. More... | |
| template<class T , pRC::Size D> | |
| static auto | getCrossValSplits (std::string const &filename, pRC::Index const &k) |
| Splits the samples in a dataset into <it>k</it> as equal as possible sized sets that can be used for <it>k</it>-fold cross-validated training. More... | |
| template<class T , pRC::Size D> | |
| static auto | readData (std::string const &filename) |
| Reads a dataset from file, where the first line is the header (containing event names) and all subsequent lines contain one sample, with entries separated by commas or spaces. More... | |
| static auto | readHeader (std::string const &filename) |
| Reads the header of a dataset from file. More... | |
| template<class T , pRC::Size D> | |
| static auto | readTheta (std::string const &filename) |
| Reads a theta matrix from file, discarding its header. More... | |
| template<class S > | |
| static auto | getRandomSubscripts () |
| Generates a uniformly distributed random Subscripts element for a Tensor or a TT. More... | |
| template<class T , pRC::Size D> | |
| static auto | writeTheta (std::string const &filename, std::string const &header, pRC::Tensor< T, D, D > const &theta, std::map< std::string, std::string > const &logInfoNames={}, std::map< std::string, double > const &logInfoNumbers={}) |
| Writes a theta matrix to file, including additional logging information at the bottom. More... | |
| auto cMHN::calculatePTheta | ( | nonTT::MHNOperator< T, D > const & | op, |
| T const & | toleranceSolver | ||
| ) |
Calculates the vector pTheta given a nonTT MHN Operator and a tolerance.
This solves the linear equation (1-Q)*pTheta = p0, where Q is an MHN Operator and p0 is the initial distribution, i.e. (100%, 0%, ..., 0%)
| T | type used for calculations (inferred) |
| D | number of events of the dataset (inferred) |
| op | nonTT MHN Operator constructed from a theta matrix |
| toleranceSolver | tolerance passed to the solver of the linear system |
| X cMHN::calculatePTheta | ( | nonTT::MHNOperator< T, D > const & | op, |
| X const & | pInit, | ||
| T const & | toleranceSolver | ||
| ) |
Calculates the vector pTheta given a nonTT MHN Operator and a tolerance.
This solves the linear equation (1-Q)*pTheta = p0, where Q is an MHN Operator and p0 is the initial distribution, i.e. (100%, 0%, ..., 0%)
| T | type used for calculations (inferred) |
| X | class of pTheta (inferred) |
| D | number of events of the dataset (inferred) |
| op | nonTT MHN Operator constructed from a theta matrix |
| pInit | initial value for linear equation |
| toleranceSolver | tolerance passed to the solver of the linear system |
| auto cMHN::calculatePTheta | ( | TT::MHNOperator< T, D > const & | op, |
| T const & | toleranceSolver | ||
| ) |
Calculates the vector pTheta (as a TT) given a TT MHN Operator and a tolerance.
This solves the linear equation (1-Q)*pTheta = p0, where Q is an MHN Operator and p0 is the initial distribution, i.e. (100%, 0%, ..., 0%)
| R | max TT rank of pTheta |
| T | type used for calculations (inferred) |
| D | number of events of the dataset (inferred) |
| op | TT MHN Operator constructed from a theta matrix |
| toleranceSolver | tolerance passed to the solver of the linear system |
| X cMHN::calculatePTheta | ( | TT::MHNOperator< T, D > const & | op, |
| X const & | pInit, | ||
| T const & | toleranceSolver | ||
| ) |
Calculates the vector pTheta (as a TT) given a TT MHN Operator and a tolerance.
This solves the linear equation (1-Q)*pTheta = p0, where Q is an MHN Operator and p0 is the initial distribution, i.e. (100%, 0%, ..., 0%)
| R | max TT rank of pTheta |
| T | type used for calculations (inferred) |
| X | class of pTheta (inferred) |
| D | number of events of the dataset (inferred) |
| op | TT MHN Operator constructed from a theta matrix |
| pInit | initial value for linear equation |
| toleranceSolver | tolerance passed to the solver of the linear system |
| T cMHN::calculateScore | ( | nonTT::MHNOperator< T, D > const & | op, |
| std::map< S, T > const & | pD, | ||
| cMHN::Score< T > const & | Score, | ||
| cMHN::Regulator< T, D > const & | Regulator, | ||
| T const & | toleranceSolverP = 1e-4 |
||
| ) |
Calculate score of a theta matrix given some data distribution pD.
| T | type used for calculations (inferred) |
| D | number of events of the dataset (inferred) |
| S | Subscripts type used as keys in data distributions (inferred) |
| T cMHN::calculateScore | ( | TT::MHNOperator< T, D > const & | op, |
| std::map< S, T > const & | pD, | ||
| cMHN::Score< T > const & | Score, | ||
| cMHN::Regulator< T, D > const & | Regulator, | ||
| T const & | toleranceSolverP = 1e-4 |
||
| ) |
Calculate score of a theta matrix given some data distribution pD (using TTs)
| RP | max TT rank of pTheta |
| T | type used for calculations (inferred) |
| D | number of events of the dataset (inferred) |
| S | Subscripts type used as keys in data distributions (inferred) |
| std::tuple< T, pRC::Tensor< T, D, D > > cMHN::calculateScoreAndGradient | ( | nonTT::MHNOperator< T, D > const & | op, |
| std::map< S, T > const & | pD, | ||
| cMHN::Score< T > const & | Score, | ||
| cMHN::Regulator< T, D > const & | Regulator, | ||
| T const & | toleranceSolverP = 1e-4, |
||
| T const & | toleranceSolverQ = 1e-4 |
||
| ) |
Calculate score and gradient of a theta matrix given some data distribution pD.
| T | type used for calculations (inferred) |
| D | number of events of the dataset (inferred) |
| S | Subscripts type used as keys in data distributions (inferred) |
| std::tuple< T, pRC::Tensor< T, D, D > > cMHN::calculateScoreAndGradient | ( | TT::MHNOperator< T, D > const & | op, |
| std::map< S, T > const & | pD, | ||
| cMHN::Score< T > const & | Score, | ||
| cMHN::Regulator< T, D > const & | Regulator, | ||
| T const & | toleranceSolverP = 1e-4, |
||
| T const & | toleranceSolverQ = 1e-4 |
||
| ) |
|
inlinestatic |
Combines multiple data distributions into a single distribution.
| T | type used for calculations (inferred) |
| S | Subscripts type used as keys in data distribution (inferred) |
| pDs | data distributions to combine |
|
inlinestatic |
Generates a data distribution from a given nonTT MHNOperator.
| T | type used for calculations (inferred) |
| D | number of events of the dataset (inferred) |
| op | MHNOperator to use as ground truth model |
| size | number of samples to take into account when constructing the data distribution |
| toleranceSolverP | tolerance passed to the solver calculating pTheta |
|
inlinestatic |
Generates a data distribution from a given nonTT MHNOperator.
| T | type used for calculations (inferred) |
| D | number of events of the dataset (inferred) |
| rng | RandomEngine to use for generating random numbers (needed not to get the same rng every time) |
| op | MHNOperator to use as ground truth model |
| size | number of samples to take into account when constructing the data distribution |
| toleranceSolverP | tolerance passed to the solver calculating pTheta |
|
inlinestatic |
Generates a data distribution from a given TT MHNOperator.
| RP | max TT rank of pTheta |
| T | type used for calculations (inferred) |
| D | number of events of the dataset (inferred) |
| rng | RandomEngine to use for generating random numbers (needed not to get the same rng every time) |
| op | MHNOperator to use as ground truth model |
| size | number of samples to take into account when constructing the data distribution |
| toleranceSolverP | tolerance passed to the solver calculating pTheta |
|
inlinestatic |
Generates a data distribution from a given TT MHNOperator.
| RP | max TT rank of pTheta |
| T | type used for calculations (inferred) |
| D | number of events of the dataset (inferred) |
| op | MHNOperator to use as ground truth model |
| size | number of samples to take into account when constructing the data distribution |
| toleranceSolverP | tolerance passed to the solver calculating pTheta |
|
inlinestatic |
Generates a random theta matrix according to given distributions, and with given fullness.
This function is used when no pRC::RandomEngine is passed.
Diagonal entries of the theta matrix (small thetas!) are generated using a Gaussian distribution, whose mean and standard deviation can be specified. Off diagonal entries are generated using a Laplace distribution, whose mean and b-parameter can be specified. The distribution's standard deviation is given by sqrt(2)*b.
| D | number of events of the dataset |
| T | type used for calculations (inferred) |
| rng | RandomEngine to use for generating random numbers (needed not to get the same rng every time) |
| fullness | Percentage of entries in theta matrix that are allowed to differ from 0 (stochastically) |
| diagonalMean | mean of the distribution generating the diagonal entries |
| diagonalStd | standard deviation of the distribution generating the diagonal entries |
| offDiagonalMean | mean of the distribution generating the off diagonal entries |
| offDiagonalB | B parameter of the distribution generating the off diagonal entries |
|
inlinestatic |
Generates a random theta matrix according to given distributions, and with given fullness.
Diagonal entries of the theta matrix (small thetas!) are generated using a Gaussian distribution, whose mean and standard deviation can be specified. Off diagonal entries are generated using a Laplace distribution, whose mean and b-parameter can be specified. The distribution's standard deviation is given by sqrt(2)*b.
| D | number of events of the dataset |
| T | type used for calculations (inferred) |
| rng | RandomEngine to use for generating random numbers (needed not to get the same rng every time) |
| fullness | Percentage of entries in theta matrix that are allowed to differ from 0 (stochastically) |
| diagonalMean | mean of the distribution generating the diagonal entries |
| diagonalStd | standard deviation of the distribution generating the diagonal entries |
| offDiagonalMean | mean of the distribution generating the off diagonal entries |
| offDiagonalB | B parameter of the distribution generating the off diagonal entries |
|
inlinestatic |
Splits the samples in a dataset into <it>k</it> as equal as possible sized sets that can be used for <it>k</it>-fold cross-validated training.
| T | type used for calculations (usually pRC::Float<>) |
| D | number of events of the dataset |
| filename | name of the file containing the dataset |
| k | number of equally sized sets to produce |
|
inlinestatic |
Generates a uniformly distributed random Subscripts element for a Tensor or a TT.
| S | Subscripts Class to generate random element of |
Calculate the theta matrix corresponding to the independence model for a given data distribution.
| T | type used for calculations (inferred) |
| S | Subscripts type used as keys in data distributions (inferred) |
| pD | data distribution |
|
inlinestatic |
Reads a dataset from file, where the first line is the header (containing event names) and all subsequent lines contain one sample, with entries separated by commas or spaces.
| T | type used for calculations (usually pRC::Float<>) |
| D | number of events of the dataset |
| filename | name of the file containing the dataset |
|
inlinestatic |
Reads the header of a dataset from file.
| filename | name of the file to read |
|
inlinestatic |
Reads a theta matrix from file, discarding its header.
| T | type used for calculations |
| D | number of events of the dataset |
| filename | name of the file to read from |
|
inlinestatic |
Writes a theta matrix to file, including additional logging information at the bottom.
| T | type used for calculations (inferred) |
| D | number of events of the dataset (inferred) |
| filename | name of the file to write to |
| header | header of the input file, i.e. event names |
| theta | theta matrix |
| logInfoNames | logging information as a map string -> string (usually used for score and regulator names) |
| logInfoNumbers | logging information as a map string -> double (usually used for score, time, etc.) |