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.BaseEstimatorCross-validation wrapper for constructing a
ProductRKHSand 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) – TheProductRKHSinstance to fit to the data.predictor_inds (
array-like ofint) – List of indices of the factors inprod_rkhs.factorson which theresponse_indswill be conditioned.response_inds – List of indices of the factors in
prod_rkhs.factorswhich 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.Ridgeinstance is used withfit_intercept=Falseandalphaspecified 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_indsand the fittedregressor.marginal_response (
ProductRKHS) – The marginal ofresponse_inds.
- fit(X, y=None)[source]¶
Fit the model from data in
X.- Parameters
X (
numpy.ndarrayof shape(n_samples, n_features_1,...,n_features_d)) – Training vector, wheren_samplesis 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.takeandfac.filterfor eachfacinprod_rkhs.factors.- Returns
The instance itself
- Return type
- score(X)[source]¶
Scores the model’s performance on data
Xusing the specifiedscoringfunction.- Parameters
X (
numpy.ndarrayof shape(n_samples, n_features_1,...,n_features_d)) – Training vector, wheren_samplesis 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.takeandfac.filterfor eachfacinprod_rkhs.factors.- Returns
The score.
- Return type