Class: OneClassSVM
Unsupervised Outlier Detection.
Estimate the support of a high-dimensional distribution.
The implementation is based on libsvm.
Read more in the User Guide.
Constructors
new OneClassSVM()
new OneClassSVM(
opts
?):OneClassSVM
Parameters
Parameter | Type | Description |
---|---|---|
opts ? | object | - |
opts.cache_size ? | number | Specify the size of the kernel cache (in MB). |
opts.coef0 ? | number | Independent term in kernel function. It is only significant in ‘poly’ and ‘sigmoid’. |
opts.degree ? | number | Degree of the polynomial kernel function (‘poly’). Must be non-negative. Ignored by all other kernels. |
opts.gamma ? | number | "auto" | "scale" | Kernel coefficient for ‘rbf’, ‘poly’ and ‘sigmoid’. |
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. |
opts.max_iter ? | number | Hard limit on iterations within solver, or -1 for no limit. |
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. |
opts.shrinking ? | boolean | Whether to use the shrinking heuristic. See the User Guide. |
opts.tol ? | number | Tolerance for stopping criterion. |
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. |
Returns OneClassSVM
Defined in generated/svm/OneClassSVM.ts:27
Properties
Property | Type | Default value | Defined in |
---|---|---|---|
_isDisposed | boolean | false | generated/svm/OneClassSVM.ts:25 |
_isInitialized | boolean | false | generated/svm/OneClassSVM.ts:24 |
_py | PythonBridge | undefined | generated/svm/OneClassSVM.ts:23 |
id | string | undefined | generated/svm/OneClassSVM.ts:20 |
opts | any | undefined | generated/svm/OneClassSVM.ts:21 |
Accessors
dual_coef_
Get Signature
get dual_coef_():
Promise
<ArrayLike
[]>
Coefficients of the support vectors in the decision function.
Returns Promise
<ArrayLike
[]>
Defined in generated/svm/OneClassSVM.ts:429
feature_names_in_
Get Signature
get feature_names_in_():
Promise
<ArrayLike
>
Names of features seen during fit. Defined only when X
has feature names that are all strings.
Returns Promise
<ArrayLike
>
Defined in generated/svm/OneClassSVM.ts:529
fit_status_
Get Signature
get fit_status_():
Promise
<number
>
0 if correctly fitted, 1 otherwise (will raise warning)
Returns Promise
<number
>
Defined in generated/svm/OneClassSVM.ts:454
intercept_
Get Signature
get intercept_():
Promise
<ArrayLike
>
Constant in the decision function.
Returns Promise
<ArrayLike
>
Defined in generated/svm/OneClassSVM.ts:479
n_features_in_
Get Signature
get n_features_in_():
Promise
<number
>
Number of features seen during fit.
Returns Promise
<number
>
Defined in generated/svm/OneClassSVM.ts:504
n_iter_
Get Signature
get n_iter_():
Promise
<number
>
Number of iterations run by the optimization routine to fit the model.
Returns Promise
<number
>
Defined in generated/svm/OneClassSVM.ts:554
offset_
Get Signature
get offset_():
Promise
<number
>
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.
Returns Promise
<number
>
Defined in generated/svm/OneClassSVM.ts:577
py
Get Signature
get py():
PythonBridge
Returns PythonBridge
Set Signature
set py(
pythonBridge
):void
Parameters
Parameter | Type |
---|---|
pythonBridge | PythonBridge |
Returns void
Defined in generated/svm/OneClassSVM.ts:102
shape_fit_
Get Signature
get shape_fit_():
Promise
<any
[]>
Array dimensions of training vector X
.
Returns Promise
<any
[]>
Defined in generated/svm/OneClassSVM.ts:600
support_
Get Signature
get support_():
Promise
<ArrayLike
>
Indices of support vectors.
Returns Promise
<ArrayLike
>
Defined in generated/svm/OneClassSVM.ts:625
support_vectors_
Get Signature
get support_vectors_():
Promise
<ArrayLike
[]>
Support vectors.
Returns Promise
<ArrayLike
[]>
Defined in generated/svm/OneClassSVM.ts:648
Methods
decision_function()
decision_function(
opts
):Promise
<ArrayLike
>
Signed distance to the separating hyperplane.
Signed distance is positive for an inlier and negative for an outlier.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike [] | The data matrix. |
Returns Promise
<ArrayLike
>
Defined in generated/svm/OneClassSVM.ts:173
dispose()
dispose():
Promise
<void
>
Disposes of the underlying Python resources.
Once dispose()
is called, the instance is no longer usable.
Returns Promise
<void
>
Defined in generated/svm/OneClassSVM.ts:154
fit()
fit(
opts
):Promise
<any
>
Detect the soft boundary of the set of samples X.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | ArrayLike | Per-sample weights. Rescale C per sample. Higher weights force the classifier to put more emphasis on these points. |
opts.X ? | ArrayLike | Set of samples, where n_samples is the number of samples and n_features is the number of features. |
opts.y ? | any | Not used, present for API consistency by convention. |
Returns Promise
<any
>
Defined in generated/svm/OneClassSVM.ts:205
fit_predict()
fit_predict(
opts
):Promise
<ArrayLike
>
Perform fit on X and returns labels for X.
Returns -1 for outliers and 1 for inliers.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.kwargs ? | any | Arguments to be passed to fit . |
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:249
get_metadata_routing()
get_metadata_routing(
opts
):Promise
<any
>
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.routing ? | any | A MetadataRequest encapsulating routing information. |
Returns Promise
<any
>
Defined in generated/svm/OneClassSVM.ts:293
init()
init(
py
):Promise
<void
>
Initializes the underlying Python resources.
This instance is not usable until the Promise
returned by init()
resolves.
Parameters
Parameter | Type |
---|---|
py | PythonBridge |
Returns Promise
<void
>
Defined in generated/svm/OneClassSVM.ts:115
predict()
predict(
opts
):Promise
<ArrayLike
>
Perform classification on samples in X.
For a one-class model, +1 or -1 is returned.
Parameters
Parameter | 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:329
score_samples()
score_samples(
opts
):Promise
<ArrayLike
>
Raw scoring function of the samples.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike [] | The data matrix. |
Returns Promise
<ArrayLike
>
Defined in generated/svm/OneClassSVM.ts:361
set_fit_request()
set_fit_request(
opts
):Promise
<any
>
Request metadata passed to the fit
method.
Note that this method is only relevant if enable_metadata_routing=True
(see sklearn.set_config
). Please see User Guide on how the routing mechanism works.
The options for each parameter are:
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | string | boolean | Metadata routing for sample_weight parameter in fit . |
Returns Promise
<any
>
Defined in generated/svm/OneClassSVM.ts:397