OneClassSVM
Unsupervised Outlier Detection.
Estimate the support of a high-dimensional distribution.
The implementation is based on libsvm.
Read more in the User Guide.
Python Reference (opens in a new tab)
Constructors
constructor()
Signature
new OneClassSVM(opts?: object): OneClassSVM;
Parameters
Name | Type | Description |
---|---|---|
opts? | object | - |
opts.cache_size? | number | Specify the size of the kernel cache (in MB). Default Value 200 |
opts.coef0? | number | Independent term in kernel function. It is only significant in ‘poly’ and ‘sigmoid’. Default Value 0 |
opts.degree? | number | Degree of the polynomial kernel function (‘poly’). Must be non-negative. Ignored by all other kernels. Default Value 3 |
opts.gamma? | number | "auto" | "scale" | Kernel coefficient for ‘rbf’, ‘poly’ and ‘sigmoid’. Default Value 'scale' |
opts.kernel? | "sigmoid" | "precomputed" | "linear" | "poly" | "rbf" | Specifies the kernel type to be used in the algorithm. If none is given, ‘rbf’ will be used. If a callable is given it is used to precompute the kernel matrix. Default Value 'rbf' |
opts.max_iter? | number | Hard limit on iterations within solver, or -1 for no limit. Default Value -1 |
opts.nu? | number | 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]. By default 0.5 will be taken. Default Value 0.5 |
opts.shrinking? | boolean | Whether to use the shrinking heuristic. See the User Guide. Default Value true |
opts.tol? | number | Tolerance for stopping criterion. Default Value 0.001 |
opts.verbose? | boolean | Enable verbose output. Note that this setting takes advantage of a per-process runtime setting in libsvm that, if enabled, may not work properly in a multithreaded context. Default Value false |
Returns
Defined in: generated/svm/OneClassSVM.ts:27 (opens in a new tab)
Properties
_isDisposed
boolean
=false
Defined in: generated/svm/OneClassSVM.ts:25 (opens in a new tab)
_isInitialized
boolean
=false
Defined in: generated/svm/OneClassSVM.ts:24 (opens in a new tab)
_py
PythonBridge
Defined in: generated/svm/OneClassSVM.ts:23 (opens in a new tab)
id
string
Defined in: generated/svm/OneClassSVM.ts:20 (opens in a new tab)
opts
any
Defined in: generated/svm/OneClassSVM.ts:21 (opens in a new tab)
Accessors
class_weight_
Multipliers of parameter C for each class. Computed based on the class\_weight
parameter.
Signature
class_weight_(): Promise<ArrayLike>;
Returns
Promise
<ArrayLike
>
Defined in: generated/svm/OneClassSVM.ts:370 (opens in a new tab)
dual_coef_
Coefficients of the support vectors in the decision function.
Signature
dual_coef_(): Promise<ArrayLike[]>;
Returns
Promise
<ArrayLike
[]>
Defined in: generated/svm/OneClassSVM.ts:395 (opens in a new tab)
feature_names_in_
Names of features seen during fit. Defined only when X
has feature names that are all strings.
Signature
feature_names_in_(): Promise<ArrayLike>;
Returns
Promise
<ArrayLike
>
Defined in: generated/svm/OneClassSVM.ts:495 (opens in a new tab)
fit_status_
0 if correctly fitted, 1 otherwise (will raise warning)
Signature
fit_status_(): Promise<number>;
Returns
Promise
<number
>
Defined in: generated/svm/OneClassSVM.ts:420 (opens in a new tab)
intercept_
Constant in the decision function.
Signature
intercept_(): Promise<ArrayLike>;
Returns
Promise
<ArrayLike
>
Defined in: generated/svm/OneClassSVM.ts:445 (opens in a new tab)
n_features_in_
Number of features seen during fit.
Signature
n_features_in_(): Promise<number>;
Returns
Promise
<number
>
Defined in: generated/svm/OneClassSVM.ts:470 (opens in a new tab)
n_iter_
Number of iterations run by the optimization routine to fit the model.
Signature
n_iter_(): Promise<number>;
Returns
Promise
<number
>
Defined in: generated/svm/OneClassSVM.ts:520 (opens in a new tab)
offset_
Offset used to define the decision function from the raw scores. We have the relation: decision_function = score_samples - offset\_
. The offset is the opposite of intercept\_
and is provided for consistency with other outlier detection algorithms.
Signature
offset_(): Promise<number>;
Returns
Promise
<number
>
Defined in: generated/svm/OneClassSVM.ts:543 (opens in a new tab)
py
Signature
py(): PythonBridge;
Returns
PythonBridge
Defined in: generated/svm/OneClassSVM.ts:102 (opens in a new tab)
Signature
py(pythonBridge: PythonBridge): void;
Parameters
Name | Type |
---|---|
pythonBridge | PythonBridge |
Returns
void
Defined in: generated/svm/OneClassSVM.ts:106 (opens in a new tab)
shape_fit_
Array dimensions of training vector X
.
Signature
shape_fit_(): Promise<any[]>;
Returns
Promise
<any
[]>
Defined in: generated/svm/OneClassSVM.ts:566 (opens in a new tab)
support_
Indices of support vectors.
Signature
support_(): Promise<ArrayLike>;
Returns
Promise
<ArrayLike
>
Defined in: generated/svm/OneClassSVM.ts:591 (opens in a new tab)
support_vectors_
Support vectors.
Signature
support_vectors_(): Promise<ArrayLike[]>;
Returns
Promise
<ArrayLike
[]>
Defined in: generated/svm/OneClassSVM.ts:614 (opens in a new tab)
Methods
decision_function()
Signed distance to the separating hyperplane.
Signed distance is positive for an inlier and negative for an outlier.
Signature
decision_function(opts: object): Promise<ArrayLike>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike [] | The data matrix. |
Returns
Promise
<ArrayLike
>
Defined in: generated/svm/OneClassSVM.ts:182 (opens in a new tab)
dispose()
Disposes of the underlying Python resources.
Once dispose()
is called, the instance is no longer usable.
Signature
dispose(): Promise<void>;
Returns
Promise
<void
>
Defined in: generated/svm/OneClassSVM.ts:163 (opens in a new tab)
fit()
Detect the soft boundary of the set of samples X.
Signature
fit(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike | Set of samples, where n\_samples is the number of samples and n\_features is the number of features. |
opts.sample_weight? | ArrayLike | Per-sample weights. Rescale C per sample. Higher weights force the classifier to put more emphasis on these points. |
opts.y? | any | Not used, present for API consistency by convention. |
Returns
Promise
<any
>
Defined in: generated/svm/OneClassSVM.ts:215 (opens in a new tab)
fit_predict()
Perform fit on X and returns labels for X.
Returns -1 for outliers and 1 for inliers.
Signature
fit_predict(opts: object): Promise<ArrayLike>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike | The input samples. |
opts.y? | any | Not used, present for API consistency by convention. |
Returns
Promise
<ArrayLike
>
Defined in: generated/svm/OneClassSVM.ts:264 (opens in a new tab)
init()
Initializes the underlying Python resources.
This instance is not usable until the Promise
returned by init()
resolves.
Signature
init(py: PythonBridge): Promise<void>;
Parameters
Name | Type |
---|---|
py | PythonBridge |
Returns
Promise
<void
>
Defined in: generated/svm/OneClassSVM.ts:115 (opens in a new tab)
predict()
Perform classification on samples in X.
For a one-class model, +1 or -1 is returned.
Signature
predict(opts: object): Promise<ArrayLike>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike | For kernel=”precomputed”, the expected shape of X is (n_samples_test, n_samples_train). |
Returns
Promise
<ArrayLike
>
Defined in: generated/svm/OneClassSVM.ts:304 (opens in a new tab)
score_samples()
Raw scoring function of the samples.
Signature
score_samples(opts: object): Promise<ArrayLike>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike [] | The data matrix. |
Returns
Promise
<ArrayLike
>
Defined in: generated/svm/OneClassSVM.ts:337 (opens in a new tab)