FuseKernel
- class modeva.models.fusekernel.api.MoFuseKernelRegressor(name=None, use_xgb=True, use_rbf=False, use_spectral=True, tree_depths=None, spectral_params=None, fit_method='grid', solver='nystrom', backend='xgboost', gbdt_params=None, residual_nw=False, max_interaction_features=6, max_interactions=10, interpret_n_grid=30, interpret_ref_size=1000, random_state=0)[source]
fuseKernel fused kernel-ridge regressor for MoDeVa.
- Parameters:
- namestr, optional
- use_xgb, use_rbf, use_spectralbool
Which kernel channels to fuse (defaults: tree + spectral).
use_xgbturns on the tree co-membership channel regardless ofbackend.- tree_depthstuple of int, optional
One co-membership kernel per depth (multi-depth tree fusion).
- spectral_paramsdict, optional
MS-SKM kwargs (H / K / kernel / …). None -> the fuseKernel defaults (
kernel="laplace", H=4, K=8, solver="nystrom").- fit_method{“grid”, “adam”, “nlml”, “oof”, “gcv”, “sure”}, default=”grid”
Fusion-weight selection (grid/adam are leakage-free, query-scored).
- solver{“nystrom”, “auto”, “lanczos”, “matfree”}, default=”nystrom”
How the spectral channel decodes its kernel (only used when
use_spectral=True)."nystrom"is the linear-in-n low-rank decode and the fastest/most scalable default;"lanczos"is the exact dense decode (best for small data);"auto"uses dense below ~20k rows and switches to Nystrom above;"matfree"is a matrix-free CG solve. An explicit"solver"key inspectral_paramsoverrides this.- backend{“xgboost”, “lightgbm”, “catboost”}, default=”xgboost”
Gradient-boosted ensemble that defines the leaf co-membership partition.
- gbdt_paramsdict, optional
Native params for the chosen backend. None -> that backend’s defaults.
- residual_nwpassthrough fuseKernel option.
- max_interaction_features, max_interactionsinteraction screening for
interpret. - interpret_n_grid, interpret_ref_sizefANOVA grid / reference-sample size.
- random_stateint
- calibrate_interval(X, y, alpha=0.1, max_depth=5)[source]
fuseKernel’s intervals are the GP posterior – no fitting needed; just record alpha.
- channel_contributions(X)
Exact additive per-channel decomposition of the fused prediction (regression).
Returns a
ValidationResult:valueholds the per-channel contribution arrays and the intercept;tableis the mean absolute contribution per channel;plot()shows the bar.
- diagnose_weak_clusters(dataset, n_clusters: int = 5, **kw)
Per-cluster train/test performance breakdown of the fitted fused kernel.
Nyström spectral clustering of the model’s own kernel partitions the data into
n_clustersregions; the model metric is reported per region on train and test, so regions where the model underperforms (large train/test gap or low headline metric) are exposed. Works for both the classic two-channel and the general (spectral / multi-depth) paths.Returns a
ValidationResult:tableis the per-cluster metric breakdown (with anALLaggregate row);valueholds the cluster labels, spectral embeddings and the weakest-cluster ranking;plot()shows the per-cluster test metric as a bar.
- interpret(dataset)
Build the inherent FANOVA interpreter. Precomputes fuseKernel’s main-effect curves and pairwise-interaction surfaces over a reference sample, then exposes them through the standard
InterpretFANOVAsots.interpret_*work. Needs a spectral channel.
- predict(X)
Model predictions, calling the child class’s ‘_predict’ method.
- Parameters:
- Xnp.ndarray of shape (n_samples, n_features)
Feature matrix for prediction.
- Returns:
- np.ndarray: The (calibrated) final prediction
- predict_effect(fidx, X)
Raw prediction of one main effect (len-1 fidx) or pairwise interaction (len-2 fidx).
- predict_interaction(X)
Pairwise-interaction raw predictions, shape (n, n_interactions).
- predict_main_effect(X)
Per-feature main-effect raw predictions, shape (n, n_features).
- class modeva.models.fusekernel.api.MoFuseKernelClassifier(name=None, use_xgb=True, use_rbf=False, use_spectral=True, tree_depths=None, spectral_params=None, fit_method='grid', solver='nystrom', backend='xgboost', gbdt_params=None, max_interaction_features=6, max_interactions=10, interpret_n_grid=30, interpret_ref_size=1000, random_state=0)[source]
fuseKernel fused kernel-ridge classifier for MoDeVa (binary and multiclass).
The fused KRR decodes one-hot targets to per-class scores;
predict_probais a temperature-calibrated softmax. Same parameters asMoFuseKernelRegressor.- channel_contributions(X)
Exact additive per-channel decomposition of the fused prediction (regression).
Returns a
ValidationResult:valueholds the per-channel contribution arrays and the intercept;tableis the mean absolute contribution per channel;plot()shows the bar.
- decision_function(X)[source]
Computes the decision function for the given input data.
- Parameters:
- Xnp.ndarray of shape (n_samples, n_features)
Feature matrix for prediction.
- calibrationbool, default=True
If True, will use calibrated probability if calibration is done. Otherwise, will use raw probability.
- Returns:
- logit_predictionarray, shape (n_samples,) or (n_samples, n_classes)
Array of (calibrated) logit predictions.
- diagnose_weak_clusters(dataset, n_clusters: int = 5, **kw)
Per-cluster train/test performance breakdown of the fitted fused kernel.
Nyström spectral clustering of the model’s own kernel partitions the data into
n_clustersregions; the model metric is reported per region on train and test, so regions where the model underperforms (large train/test gap or low headline metric) are exposed. Works for both the classic two-channel and the general (spectral / multi-depth) paths.Returns a
ValidationResult:tableis the per-cluster metric breakdown (with anALLaggregate row);valueholds the cluster labels, spectral embeddings and the weakest-cluster ranking;plot()shows the per-cluster test metric as a bar.
- interpret(dataset)
Build the inherent FANOVA interpreter. Precomputes fuseKernel’s main-effect curves and pairwise-interaction surfaces over a reference sample, then exposes them through the standard
InterpretFANOVAsots.interpret_*work. Needs a spectral channel.
- predict(X)[source]
Model predictions, calling the child class’s ‘_predict’ method.
- Parameters:
- Xnp.ndarray of shape (n_samples, n_features)
Feature matrix for prediction.
- calibrationbool, default=True
If True, will use calibrated probability if calibration is done. Otherwise, will use raw probability.
- Returns:
- np.ndarray: The (calibrated) final prediction
- predict_effect(fidx, X)
Raw prediction of one main effect (len-1 fidx) or pairwise interaction (len-2 fidx).
- predict_interaction(X)
Pairwise-interaction raw predictions, shape (n, n_interactions).
- predict_main_effect(X)
Per-feature main-effect raw predictions, shape (n, n_features).
- predict_proba(X)[source]
Predict (calibrated) probabilities for X.
- Parameters:
- Xnp.ndarray of shape (n_samples, n_features)
Feature matrix for prediction.
- calibrationbool, default=True
If True, will return calibrated probability if calibration is done. Otherwise, will return raw probability.
- Returns:
- np.ndarray: The (calibrated) predicted probabilities