class kenchi.outlier_detection.classification_based.OCSVM(cache_size=200, gamma='scale', max_iter=-1, nu=0.5, shrinking=True, tol=0.001)[source]

Bases: kenchi.outlier_detection.base.BaseOutlierDetector

One Class Support Vector Machines (only RBF kernel).

Parameters:
  • cache_size (float, default 200) – Specify the size of the kernel cache (in MB).
  • gamma (float, default 'scale') – Kernel coefficient. If gamma is ‘scale’, 1 / (n_features * np.std(X)) will be used instead.
  • max_iter (int, optional default -1) – Maximum number of iterations.
  • nu (float, default 0.5) – An upper bound on the fraction of training errors and a lower bound of the fraction of support vectors. Should be in the interval (0, 1].
  • shrinking (bool, default True) – If True, use the shrinking heuristic.
  • tol (float, default 0.001) – Tolerance to declare convergence.
anomaly_score_

array-like of shape (n_samples,) – Anomaly score for each training data.

contamination_

float – Actual proportion of outliers in the data set.

threshold_

float – Threshold.

Examples

>>> import numpy as np
>>> from kenchi.outlier_detection import OCSVM
>>> X = np.array([
...     [0., 0.], [1., 1.], [2., 0.], [3., -1.], [4., 0.],
...     [5., 1.], [6., 0.], [7., -1.], [8., 0.], [1000., 1.]
... ])
>>> det = OCSVM(gamma=1e-03, nu=0.25)
>>> det.fit_predict(X)
array([ 1,  1,  1,  1,  1,  1,  1,  1,  1, -1])
dual_coef_

array-like of shape (1, n_SV) – Coefficients of the support vectors in the decision function.

intercept_

array-like of shape (1,) – Constant in the decision function.

support_

array-like of shape (n_SV) – Indices of support vectors.

support_vectors_

array-like of shape (n_SV, n_features) – Support vectors.