class sklearn.kernel_approximation.Nystroem(kernel=’rbf’, gamma=None, coef0=None, degree=None, kernel_params=None, n_components=100, random_state=None) [source]
Approximate a kernel map using a subset of the training data.
Constructs an approximate feature map for an arbitrary kernel using a subset of the data as basis.
Read more in the User Guide.
| Parameters: |
|
|---|---|
| Attributes: |
|
See also
RBFSampler
sklearn.metrics.pairwise.kernel_metrics
>>> from sklearn import datasets, svm
>>> from sklearn.kernel_approximation import Nystroem
>>> digits = datasets.load_digits(n_class=9)
>>> data = digits.data / 16.
>>> clf = svm.LinearSVC()
>>> feature_map_nystroem = Nystroem(gamma=.2,
... random_state=1,
... n_components=300)
>>> data_transformed = feature_map_nystroem.fit_transform(data)
>>> clf.fit(data_transformed, digits.target)
...
LinearSVC(C=1.0, class_weight=None, dual=True, fit_intercept=True,
intercept_scaling=1, loss='squared_hinge', max_iter=1000,
multi_class='ovr', penalty='l2', random_state=None, tol=0.0001,
verbose=0)
>>> clf.score(data_transformed, digits.target)
0.9987...
fit(X[, y]) | Fit estimator to data. |
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) | Apply feature map to X. |
__init__(kernel=’rbf’, gamma=None, coef0=None, degree=None, kernel_params=None, n_components=100, random_state=None) [source]
fit(X, y=None) [source]
Fit estimator to data.
Samples a subset of training points, computes kernel on these and computes normalization matrix.
| 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.
| Parameters: |
|
|---|---|
| Returns: |
|
get_params(deep=True) [source]
Get parameters for this estimator.
| Parameters: |
|
|---|---|
| Returns: |
|
set_params(**params) [source]
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.
| Returns: |
|
|---|
transform(X) [source]
Apply feature map to X.
Computes an approximate feature map using the kernel between some training points and X.
| Parameters: |
|
|---|---|
| Returns: |
|
sklearn.kernel_approximation.Nystroem
© 2007–2018 The scikit-learn developers
Licensed under the 3-clause BSD License.
http://scikit-learn.org/stable/modules/generated/sklearn.kernel_approximation.Nystroem.html