INGOR
|
The BNDC score function. More...
#include <BNDC.h>
Public Member Functions | |
void * | BNDC_init (ytData *data, ytKeyValues *args) |
Initializes the BNDC score. | |
void | BNDC_reinit (void *buff, ytData *data) |
Re-initializes the score function. | |
double | BNDC_score (void *buff, const int j, const int *parents, const int q) |
BNDC score function. | |
int | BDE_count (const BNRC_Data *D, int j, int n, const int *parents, int q, int R, BDE_Data *B) |
void | BNDC_prepare (const BNRC_Data *D, const BDE_Data *B, int j, const int *parents, int q, int R, int lv, BNRC_Data *DD, int **offset, int **nn, const double *Yd, double *YYd) |
Prepares for discrete parent and child value pattern specific modeling. | |
void | BNDC_partialResidual (void *buff, const int j, const int *parents, const int q, FILE **fp, double *llar) |
Calculates partial residuals. | |
void | BNDC_setEdgeProp (void *buff, const int j, const int *parents, const int q, const int k, const ytEdge *edge) |
Sets parameters from ytEdge. | |
void | BNDC_calcEdgeContrib (void *buff, ytNetwork *network, int j, const int *parents, int q, int mode, double *ar) |
Calculates edge contribution for edges connected to a node. | |
The BNDC score function.
The BNDC score function allows the calculation of the network scores for discrete and continuous mixed data.
See document of BNDC_init() for the available arguments of the score function.
After the network estimation and/or score calculation, followng node and edge properties are added. These are included in a network output file.
bndc.parents.continuous
bndc.parents.discrete
bndc.categories
bndc.r
mean
variance
bndc.cpd
bndc.bspline
bndc.cpd
above for the details of the order of the parent pattern. bndc.means
bndc.bspline
. bndc.vars
bndc.means
about the length and the order of the array. bspline
int BDE_count | ( | const BNRC_Data * | D, |
int | j, | ||
int | n, | ||
const int * | parents, | ||
int | q, | ||
int | R, | ||
BDE_Data * | B | ||
) |
brief Counts samples with respect to parent patterns.
This counts up the number of samples with respect to parent value patterns.
The number of samples with pattern 'm' is stored in B->Njm[m]. If R != 1, the number of samples with the parent pattern and the value of the target variable 'j' (D->Y) is stored in B->Njmr[r + m * R], where R represents the number of categories of the target variable 'j', 'm' the parent pattern, and 'r' the target value.
If R == 1, it means that the j -th variable is continous. If so, B->Njmr[m * R] would be idential to B->Njm[m].
Thus, The order of memory for B->Njmr would be: INDEX 0 1 2 3 4 5 m 0 0 0 1 1 1 r 0 1 2 0 1 2
y | Whether or not this counts up Njmr. |
void BNDC_calcEdgeContrib | ( | void * | buff, |
ytNetwork * | network, | ||
int | j, | ||
const int * | parents, | ||
int | q, | ||
int | mode, | ||
double * | ar | ||
) |
Calculates edge contribution for edges connected to a node.
gamma[0]
needs to be set before calling this.
ar | (n x q) matrix where q is the number of parents of the j-th variable. ar[i + k * n] represents the value for the k-th parent of the j-th variable at the i-th sample. |
mode | 0: RC, 1: RCr, 2: ECv |
void * BNDC_init | ( | ytData * | data, |
ytKeyValues * | args | ||
) |
Initializes the BNDC score.
prop=
n Property output type. This changes properties to be stored in edges and nodes after the estimation.
0
: standard.
1
: less information (simple) for the contitous or discrete only variable data set.
hyper_bg=
x hb=
x 10
hb and then decreases the value such as β = 10
hb − (i × hi ), where i = 1, 2, ...., hn. (default: x = 2.0) hyper_inc=
x hi=
x hyper_bg
. (default: x = 0.4) hyper_n=
n hn=
n hyper_bg
. (default: n = 21) linear
hb=2.0,hi=1.0,hn=2
". lv=
n outer=
x ecv_clip=
x nan
". max_loops=
n stop
verbose=
n v=
n The following keys are used internally.
max_parents=
n mp=
n Maximum parents. Basically, this is set automatically by the structure search algorithm.
max_cont_parents=
n Maximum continuous parents
max_disc_parents=
n Maximum discrete parents
xl
xr
DoubleArray instance that defines the maximum (right-most) values of the value ranges for modeling with B-splines.
max_mem
size_t
value of the maximum memory. data | |
args |
void BNDC_partialResidual | ( | void * | buff, |
const int | j, | ||
const int * | parents, | ||
const int | q, | ||
FILE ** | fp, | ||
double * | llar | ||
) |
Calculates partial residuals.
This assumes BNDCBuff::gamma (bf->gamma
) to be set already by BNDC_score() with the same j
-th node and its parents.
This uses (breaks) following working variables.
Outputs input, target and partial residuals.
buff | pointer to the score buffer (BNDCBuff instance). |
llar | pointer to the array to store log likelihoods for particular primary IDs. This is not applicable if the dataset does not have primary id. NULL acceptable. If so, it does not calculate primary id specific log likelihoods. |
void BNDC_prepare | ( | const BNRC_Data * | D, |
const BDE_Data * | B, | ||
int | j, | ||
const int * | parents, | ||
int | q, | ||
int | R, | ||
int | lv, | ||
BNRC_Data * | DD, | ||
int ** | offset, | ||
int ** | nn, | ||
const double * | Yd, | ||
double * | YYd | ||
) |
Prepares for discrete parent and child value pattern specific modeling.
Call BDE_count() before calling this.
D | original data matrices. |
DD | resultant displaced data matrices. |
nn | work area for displacing samples. |
void BNDC_reinit | ( | void * | buff, |
ytData * | data | ||
) |
Re-initializes the score function.
This is only applicable if only the values in data are changed.
buff | pointer to the buffere returned by BNDC_init(). |
data | Only ytData::X and ytData::Y are used. |
double BNDC_score | ( | void * | buff, |
const int | j, | ||
const int * | parents, | ||
const int | q | ||
) |
BNDC score function.
This is thread-safe with OpenMP multi-threading. Thread-dependent working memory is allocated in buff returned by BNDC_init(). Therefore, you do not need to initialize and obtain the score buffer for different threads.
buff | score buffer returned by BNDC_init(). |
j | target node. |
parents | parent indices. |
q | length of parents. |
void BNDC_setEdgeProp | ( | void * | buff, |
const int | j, | ||
const int * | parents, | ||
const int | q, | ||
const int | k, | ||
const ytEdge * | edge | ||
) |
Sets parameters from ytEdge.
BNDC_setNodeProp() should be called before calling this.
Sets coefficients (gamma
) from "bspline" properties, and calculates B gamma (B_gamma
) where B represents the design matrix.
By calling this, BNDC_partialResidual() can calcualtes valid partial residuals without the score calculation.