class sklearn.kernel_approximation.AdditiveChi2Sampler(sample_steps=2, sample_interval=None)[source]

Approximate feature map for additive chi2 kernel.

Uses sampling the fourier transform of the kernel characteristic at regular intervals.

Since the kernel that is to be approximated is additive, the components of the input vectors can be treated separately. Each entry in the original space is transformed into 2*sample_steps+1 features, where sample_steps is a parameter of the method. Typical values of sample_steps include 1, 2 and 3.

Optimal choices for the sampling interval for certain data ranges can be computed (see the reference). The default values should be reasonable.

Read more in the User Guide.


sample_steps : int, optional

Gives the number of (complex) sampling points.

sample_interval : float, optional

Sampling interval. Must be specified when sample_steps not in {1,2,3}.

See also

A Fourier-approximation to a non-additive variant of the chi squared kernel.
The exact chi squared kernel.
The exact additive chi squared kernel.


This estimator approximates a slightly different version of the additive chi squared kernel then metric.additive_chi2 computes.


See “Efficient additive kernels via explicit feature maps” A. Vedaldi and A. Zisserman, Pattern Analysis and Machine Intelligence, 2011


fit(X[, y]) Set parameters.
fit_transform(X[, y]) Fit to data, then transform it.
get_params([deep]) Get parameters for this estimator.
set_params(**params) Set the parameters of this estimator.
transform(X[, y]) Apply approximate feature map to X.
__init__(sample_steps=2, sample_interval=None)[source]
fit(X, y=None)[source]

Set parameters.

fit_transform(X, y=None, **fit_params)[source]

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.


X : numpy array of shape [n_samples, n_features]

Training set.

y : numpy array of shape [n_samples]

Target values.


X_new : numpy array of shape [n_samples, n_features_new]

Transformed array.


Get parameters for this estimator.


deep: boolean, optional :

If True, will return the parameters for this estimator and contained subobjects that are estimators.


params : mapping of string to any

Parameter names mapped to their values.


Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as pipelines). The former have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Returns:self :
transform(X, y=None)[source]

Apply approximate feature map to X.


X : {array-like, sparse matrix}, shape = (n_samples, n_features)


X_new : {array, sparse matrix}, shape = (n_samples, n_features * (2*sample_steps + 1))

Whether the return value is an array of sparse matrix depends on the type of the input X.