Class KernelMarginalLikelihoodScore
- All Implemented Interfaces:
Score, EffectiveSampleSizeSettable
KML: Kernel Marginal Likelihood score for mixed (continuous + discrete) parents
This is the exact-kernel analogue of FfMl. It extends the exact Gaussian-process
marginal-likelihood KML score (see KernelMarginalLikelihoodScoreContinuous) to parent
sets containing both continuous and discrete variables, using the same modelling recipe as FFML:
a product kernel between a continuous RBF kernel and a categorical kernel.
Product-kernel model
For a parent vector Z = (Z_c, Z_d) with continuous part Z_c and discrete part
Z_d, the kernel is
k((z_c, z_d), (z'_c, z'_d)) = k_cont(z_c, z'_c) · k_cat(z_d, z'_d)
k_contis the exact RBF kernel over the continuous parents (median-heuristic bandwidth), reusingKernelMarginalLikelihoodScoreContinuous.rbfGramContinuous(int[], int[], int). Unlike FFML this uses the fulln×nGram matrix rather than a random-feature approximation, so there is no random basis, no seeding, and no bandwidth grid-search.k_catis the same positive-semidefinite categorical kernel used by FFML: it returns1on a level match andρon a mismatch (0 ≤ ρ < 1); over several discrete parents it multiplies, givingρ^(#mismatches).
The two kernels are combined as a Hadamard (elementwise) product K = K_cont ⊙ K_cat, which
is positive semidefinite by the Schur product theorem, and the marginal covariance is
C = K + σ² I. The local score is the GP log marginal likelihood
-0.5·yᵀC⁻¹y - 0.5·log|C|, matching Tetrad's score convention (additive constants omitted).
Routing
- Continuous target with no discrete parents (including the no-parent case): delegated
directly to
KernelMarginalLikelihoodScoreContinuous. This is the "KML calls KML-Continuous for continuous variables only" path and reproduces the original continuous KML behaviour exactly. - Continuous target with at least one discrete parent: the exact product kernel is built here and scored as a single-output GP marginal likelihood.
- Discrete target: handled via a Gaussian multi-output surrogate (identical in spirit to
FFML). The target is expanded into centered one-hot columns and each column is scored under
the same product kernel; because the kernel is independent of the output column, the
n×ncovariance is Cholesky-factorized once and reused across all one-hot columns. With no parents this reduces to the closed-formC = σ² Isigma-only case.
Notes
- The discrete-target score is a Gaussian multi-output surrogate, not a true multinomial likelihood, but (as in FFML) it is effective for structure scoring.
- When there are continuous parents present alongside discrete parents, the RBF bandwidth is estimated on the continuous parents only, over the rows actually used for scoring.
- Cost is
O(n³)from the single Cholesky factorization (small to moderaten), the same regime as the continuous KML.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionKernelMarginalLikelihoodScore(DataSet dataSet) Constructs a mixed KML score for the given dataset. -
Method Summary
Modifier and TypeMethodDescriptionint[]append(int[] z, int x) Appends an integer to an int array, returning a new array.booleandetermines(List<Node> z, Node y) Returns true iff the score determines the edge between x and y.doubleRetrieves the categorical similarity rho.Retrieves the data model used for scoring.intReturns the effective sample size.intReturns the max degree, by default 1000.intThe sample size of the data.The variables of the score.booleanisEffectEdge(double bump) Returns true iff the edge between x and y is an effect edge.doublelocalScore(int i, int... parents) The score of a node given its parents.doublelocalScoreDiff(int x, int y, int[] z) Returns the score difference of the graph.voidsetBandwidthMultiplier(double bandwidthMultiplier) Sets the bandwidth multiplier and forwards it to the continuous engine.voidsetBwMaxRows(int bwMaxRows) Sets the maximum number of rows for bandwidth estimation (min 50) and forwards it.voidsetCatRho(double rho) Sets the categorical similarity rho in [0, 1).voidsetEffectiveSampleSize(int nEff) Sets the effective sample size, or -1 if the actual sample size should be used.voidsetJitter(double jitter) Sets the Cholesky jitter base and forwards it to the continuous engine.voidsetLambda(double lambda) Sets the lambda (sigma^2) hyperparameter and forwards it to the continuous engine.toString()A string representation of the score.Methods inherited from interface Score
getMissingValueSupport, getVariable, localScore, localScore, localScoreDiff
-
Constructor Details
-
KernelMarginalLikelihoodScore
Constructs a mixed KML score for the given dataset. Continuous columns are z-scored (NaNs preserved) and discrete columns are read as integer codes, mirroring FFML. A continuous engine is constructed over the same dataset to handle purely continuous local scores.- Parameters:
dataSet- the dataset. Must not be null.- Throws:
NullPointerException- if the dataset is null.
-
-
Method Details
-
localScoreDiff
public double localScoreDiff(int x, int y, int[] z) Description copied from interface:ScoreReturns the score difference of the graph.- Specified by:
localScoreDiffin interfaceScore- Parameters:
x- A node.y- TAhe node.z- A set of nodes.- Returns:
- The score difference.
-
localScore
public double localScore(int i, int... parents) Description copied from interface:ScoreThe score of a node given its parents.- Specified by:
localScorein interfaceScore- Parameters:
i- The node.parents- The parents.- Returns:
- The score.
-
getVariables
Description copied from interface:ScoreThe variables of the score.- Specified by:
getVariablesin interfaceScore- Returns:
- This list.
-
getSampleSize
public int getSampleSize()Description copied from interface:ScoreThe sample size of the data.- Specified by:
getSampleSizein interfaceScore- Returns:
- This size.
-
getMaxDegree
public int getMaxDegree()Description copied from interface:ScoreReturns the max degree, by default 1000.- Specified by:
getMaxDegreein interfaceScore- Returns:
- The max degree.
-
determines
Description copied from interface:ScoreReturns true iff the score determines the edge between x and y.- Specified by:
determinesin interfaceScore- Parameters:
z- The set of nodes.y- The node.- Returns:
- True iff the score determines the edge between x and y.
-
isEffectEdge
public boolean isEffectEdge(double bump) Description copied from interface:ScoreReturns true iff the edge between x and y is an effect edge.- Specified by:
isEffectEdgein interfaceScore- Parameters:
bump- The bump.- Returns:
- True iff the edge between x and y is an effect edge.
-
getDataModel
-
getEffectiveSampleSize
public int getEffectiveSampleSize()Description copied from interface:EffectiveSampleSizeSettableReturns the effective sample size.- Specified by:
getEffectiveSampleSizein interfaceEffectiveSampleSizeSettable- Returns:
- the effective sample size
-
setEffectiveSampleSize
public void setEffectiveSampleSize(int nEff) Description copied from interface:EffectiveSampleSizeSettableSets the effective sample size, or -1 if the actual sample size should be used.- Specified by:
setEffectiveSampleSizein interfaceEffectiveSampleSizeSettable- Parameters:
nEff- the effective sample size
-
toString
-
setLambda
public void setLambda(double lambda) Sets the lambda (sigma^2) hyperparameter and forwards it to the continuous engine.- Parameters:
lambda- the noise variance; must be > 0.
-
setJitter
public void setJitter(double jitter) Sets the Cholesky jitter base and forwards it to the continuous engine.- Parameters:
jitter- the jitter base; must be > 0.
-
setBandwidthMultiplier
public void setBandwidthMultiplier(double bandwidthMultiplier) Sets the bandwidth multiplier and forwards it to the continuous engine.- Parameters:
bandwidthMultiplier- the multiplier; must be > 0 and finite.
-
setBwMaxRows
public void setBwMaxRows(int bwMaxRows) Sets the maximum number of rows for bandwidth estimation (min 50) and forwards it.- Parameters:
bwMaxRows- the maximum number of rows.
-
getCatRho
public double getCatRho()Retrieves the categorical similarity rho.- Returns:
- catRho in [0, 1).
-
setCatRho
public void setCatRho(double rho) Sets the categorical similarity rho in [0, 1). k_cat(c,c)=1, k_cat(c,c')=rho.- Parameters:
rho- the categorical similarity; must be in [0, 1).
-
append
-