ruckus.cv_wrappers module¶
- class ruckus.cv_wrappers.ConditionalMapWrapper(prod_rkhs, predictor_inds, response_inds, regressor=None, alpha=1.0, scoring=None)[source]¶
Bases:
sklearn.base.BaseEstimator
Cross-validation wrapper for constructing a
ProductRKHS
and conditioning some of its factor spaces on the others.For two systems \(X\) and \(Y\), embedded in Hilbert spaces \(H_1\) and \(H_2\) respectively, the conditional distribution embedding is a linear map \(C_{Y|X}:H_1\rightarrow H_2\) such that \(C_{Y|X}\phi_1(x)\) gives the kernel embedding of the distribution of \(Y\) conditioned on \(X=x\). This is typically determined by using a ridge regression, though we allow the user to pass a custom regressor for model selection purposes. See [1] for details.
- Parameters
prod_rkhs (
ProductRKHS
) – TheProductRKHS
instance to fit to the data.predictor_inds (
array
-like ofint
) – List of indices of the factors inprod_rkhs.factors
on which theresponse_inds
will be conditioned.response_inds – List of indices of the factors in
prod_rkhs.factors
which are to be conditioned on thepredictor_inds
.regressor (
sklearn.base.BaseEstimator
) – The regressor object to use to fit the conditional embedding. IfNone
, asklearn.linear_model.Ridge
instance is used withfit_intercept=False
andalpha
specified below.alpha (float) – The ridge parameter used in the default Ridge regressor.
scoring (callable) – The scoring function which will be applied to the
regressor
. IfNone
,joint_probs_hilbert_schmidt_scorer()
is used.
- Parameters
conditional_map (
sklearn.pipelines.Pipeline
) – A pipeline consisting of the marginal ofpredictor_inds
and the fittedregressor
.marginal_response (
ProductRKHS
) – The marginal ofresponse_inds
.
- fit(X, y=None)[source]¶
Fit the model from data in
X
.- Parameters
X (
numpy.ndarray
of shape(n_samples, n_features_1,...,n_features_d)
) – Training vector, wheren_samples
is the number of samples and(n_features_1,...,n_features_d)
is the shape of the input data. Must be consistent with preprocessing instructions infac.take
andfac.filter
for eachfac
inprod_rkhs.factors
.- Returns
The instance itself
- Return type
- score(X)[source]¶
Scores the model’s performance on data
X
using the specifiedscoring
function.- Parameters
X (
numpy.ndarray
of shape(n_samples, n_features_1,...,n_features_d)
) – Training vector, wheren_samples
is the number of samples and(n_features_1,...,n_features_d)
is the shape of the input data. Must be consistent with preprocessing instructions infac.take
andfac.filter
for eachfac
inprod_rkhs.factors
.- Returns
The score.
- Return type