sklearn.kernel_approximation
.RBFSampler¶
-
class
sklearn.kernel_approximation.
RBFSampler
(gamma=1.0, n_components=100, random_state=None)[源代码]¶ Approximates feature map of an RBF kernel by Monte Carlo approximation of its Fourier transform.
It implements a variant of Random Kitchen Sinks.[1]
Read more in the User Guide.
Parameters: gamma : float
Parameter of RBF kernel: exp(-gamma * x^2)
n_components : int
Number of Monte Carlo samples per original feature. Equals the dimensionality of the computed feature space.
random_state : {int, RandomState}, optional
If int, random_state is the seed used by the random number generator; if RandomState instance, random_state is the random number generator.
Notes
See “Random Features for Large-Scale Kernel Machines” by A. Rahimi and Benjamin Recht.
[1] “Weighted Sums of Random Kitchen Sinks: Replacing minimization with randomization in learning” by A. Rahimi and Benjamin Recht. (http://www.eecs.berkeley.edu/~brecht/papers/08.rah.rec.nips.pdf)
Methods
fit
(X[, y])Fit the model with X. 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 the approximate feature map to X. -
fit
(X, y=None)[源代码]¶ Fit the model with X.
Samples random projection according to n_features.
Parameters: X : {array-like, sparse matrix}, shape (n_samples, n_features)
Training data, where n_samples in the number of samples and n_features is the number of features.
Returns: self : object
Returns the transformer.
-
fit_transform
(X, y=None, **fit_params)[源代码]¶ Fit to data, then transform it.
Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.
Parameters: X : numpy array of shape [n_samples, n_features]
Training set.
y : numpy array of shape [n_samples]
Target values.
Returns: X_new : numpy array of shape [n_samples, n_features_new]
Transformed array.
-
get_params
(deep=True)[源代码]¶ Get parameters for this estimator.
Parameters: deep: boolean, optional :
If True, will return the parameters for this estimator and contained subobjects that are estimators.
Returns: params : mapping of string to any
Parameter names mapped to their values.
-