optiml.ml.svm.kernels module
- class optiml.ml.svm.kernels.Kernel[source]
Bases:
BaseEstimator,ABCBase abstract class for all kernel functions. A kernel computes the pairwise similarities (i.e., the Gram matrix) between two sets of samples.
Subclasses must implement
__call__.- get_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
routing – A
MetadataRequestencapsulating routing information.- Return type:
MetadataRequest
- get_params(deep=True)
Get parameters for this estimator.
- set_params(**params)
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as
Pipeline). The latter have parameters of the form<component>__<parameter>so that it’s possible to update each component of a nested object.- Parameters:
**params (dict) – Estimator parameters.
- Returns:
self – Estimator instance.
- Return type:
estimator instance
- class optiml.ml.svm.kernels.LinearKernel[source]
Bases:
KernelCompute the linear kernel between X and Y:
\[K(X, Y) = \langle X, Y \rangle\]- get_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
routing – A
MetadataRequestencapsulating routing information.- Return type:
MetadataRequest
- get_params(deep=True)
Get parameters for this estimator.
- set_params(**params)
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as
Pipeline). The latter have parameters of the form<component>__<parameter>so that it’s possible to update each component of a nested object.- Parameters:
**params (dict) – Estimator parameters.
- Returns:
self – Estimator instance.
- Return type:
estimator instance
- class optiml.ml.svm.kernels.PolyKernel(degree=3, gamma='scale', coef0=0.0)[source]
Bases:
KernelCompute the polynomial kernel between X and Y:
\[K(X, Y) = (\gamma \langle X, Y \rangle + coef_0)^{degree}\]- Parameters:
degree (int, default=3) – Degree of the polynomial kernel function.
gamma ({'scale', 'auto'} or float, default='scale') –
Kernel coefficient for kernel function.
if gamma=’scale’ (default) is passed then it uses 1 / (n_features * X.var()) as value of gamma,
if gamma=’auto’, uses 1 / n_features.
coef0 (float, default=0.0) – Independent term in kernel function.
- get_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
routing – A
MetadataRequestencapsulating routing information.- Return type:
MetadataRequest
- get_params(deep=True)
Get parameters for this estimator.
- set_params(**params)
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as
Pipeline). The latter have parameters of the form<component>__<parameter>so that it’s possible to update each component of a nested object.- Parameters:
**params (dict) – Estimator parameters.
- Returns:
self – Estimator instance.
- Return type:
estimator instance
- class optiml.ml.svm.kernels.GaussianKernel(gamma='scale')[source]
Bases:
KernelCompute the gaussian RBF kernel between X and Y:
\[K(X, Y) = e^{-\gamma \lVert X - Y \rVert_2^2}\]- Parameters:
gamma ({'scale', 'auto'} or float, default='scale') –
Kernel coefficient for kernel function.
if gamma=’scale’ (default) is passed then it uses 1 / (n_features * X.var()) as value of gamma,
if gamma=’auto’, uses 1 / n_features.
- get_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
routing – A
MetadataRequestencapsulating routing information.- Return type:
MetadataRequest
- get_params(deep=True)
Get parameters for this estimator.
- set_params(**params)
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as
Pipeline). The latter have parameters of the form<component>__<parameter>so that it’s possible to update each component of a nested object.- Parameters:
**params (dict) – Estimator parameters.
- Returns:
self – Estimator instance.
- Return type:
estimator instance
- class optiml.ml.svm.kernels.LaplacianKernel(gamma='scale')[source]
Bases:
KernelCompute the laplacian RBF kernel between X and Y:
\[K(X, Y) = e^{-\gamma \lVert X - Y \rVert_1}\]- Parameters:
gamma ({'scale', 'auto'} or float, default='scale') –
Kernel coefficient for kernel function.
if gamma=’scale’ (default) is passed then it uses 1 / (n_features * X.var()) as value of gamma,
if gamma=’auto’, uses 1 / n_features.
- get_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
routing – A
MetadataRequestencapsulating routing information.- Return type:
MetadataRequest
- get_params(deep=True)
Get parameters for this estimator.
- set_params(**params)
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as
Pipeline). The latter have parameters of the form<component>__<parameter>so that it’s possible to update each component of a nested object.- Parameters:
**params (dict) – Estimator parameters.
- Returns:
self – Estimator instance.
- Return type:
estimator instance
- class optiml.ml.svm.kernels.SigmoidKernel(gamma='scale', coef0=0.0)[source]
Bases:
KernelCompute the sigmoid kernel between X and Y:
\[K(X, Y) = \tanh(\gamma \langle X, Y \rangle + coef_0)\]- Parameters:
- get_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
routing – A
MetadataRequestencapsulating routing information.- Return type:
MetadataRequest
- get_params(deep=True)
Get parameters for this estimator.
- set_params(**params)
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as
Pipeline). The latter have parameters of the form<component>__<parameter>so that it’s possible to update each component of a nested object.- Parameters:
**params (dict) – Estimator parameters.
- Returns:
self – Estimator instance.
- Return type:
estimator instance