Class: SVR
Epsilon-Support Vector Regression.
The free parameters in the model are C and epsilon.
The implementation is based on libsvm. The fit time complexity is more than quadratic with the number of samples which makes it hard to scale to datasets with more than a couple of 10000 samples. For large datasets consider using LinearSVR
or SGDRegressor
instead, possibly after a Nystroem
transformer or other Kernel Approximation.
Read more in the User Guide.
Constructors
new SVR()
new SVR(
opts
?):SVR
Parameters
Parameter | Type | Description |
---|---|---|
opts ? | object | - |
opts.C ? | number | Regularization parameter. The strength of the regularization is inversely proportional to C. Must be strictly positive. The penalty is a squared l2. For an intuitive visualization of the effects of scaling the regularization parameter C, see Scaling the regularization parameter for SVCs. |
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.epsilon ? | number | Epsilon in the epsilon-SVR model. It specifies the epsilon-tube within which no penalty is associated in the training loss function with points predicted within a distance epsilon from the actual value. Must be non-negative. |
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.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 SVR
Defined in generated/svm/SVR.ts:27
Properties
Property | Type | Default value | Defined in |
---|---|---|---|
_isDisposed | boolean | false | generated/svm/SVR.ts:25 |
_isInitialized | boolean | false | generated/svm/SVR.ts:24 |
_py | PythonBridge | undefined | generated/svm/SVR.ts:23 |
id | string | undefined | generated/svm/SVR.ts:20 |
opts | any | undefined | generated/svm/SVR.ts:21 |
Accessors
dual_coef_
Get Signature
get dual_coef_():
Promise
<ArrayLike
[]>
Coefficients of the support vector in the decision function.
Returns Promise
<ArrayLike
[]>
Defined in generated/svm/SVR.ts:402
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/SVR.ts:492
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/SVR.ts:424
intercept_
Get Signature
get intercept_():
Promise
<ArrayLike
>
Constants in decision function.
Returns Promise
<ArrayLike
>
Defined in generated/svm/SVR.ts:447
n_features_in_
Get Signature
get n_features_in_():
Promise
<number
>
Number of features seen during fit.
Returns Promise
<number
>
Defined in generated/svm/SVR.ts:469
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/SVR.ts:515
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/SVR.ts:109
shape_fit_
Get Signature
get shape_fit_():
Promise
<any
[]>
Array dimensions of training vector X
.
Returns Promise
<any
[]>
Defined in generated/svm/SVR.ts:537
support_
Get Signature
get support_():
Promise
<ArrayLike
>
Indices of support vectors.
Returns Promise
<ArrayLike
>
Defined in generated/svm/SVR.ts:559
support_vectors_
Get Signature
get support_vectors_():
Promise
<ArrayLike
[]>
Support vectors.
Returns Promise
<ArrayLike
[]>
Defined in generated/svm/SVR.ts:581
Methods
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/SVR.ts:160
fit()
fit(
opts
):Promise
<any
>
Fit the SVM model according to the given training data.
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 | Training vectors, where n_samples is the number of samples and n_features is the number of features. For kernel=”precomputed”, the expected shape of X is (n_samples, n_samples). |
opts.y ? | ArrayLike | Target values (class labels in classification, real numbers in regression). |
Returns Promise
<any
>
Defined in generated/svm/SVR.ts:177
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/SVR.ts:220
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/SVR.ts:122
predict()
predict(
opts
):Promise
<ArrayLike
>
Perform regression on samples in X.
For an one-class model, +1 (inlier) or -1 (outlier) 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/SVR.ts:254
score()
score(
opts
):Promise
<number
>
Return the coefficient of determination of the prediction.
The coefficient of determination \(R^2\) is defined as \((1 - \frac{u}{v})\), where \(u\) is the residual sum of squares ((y_true \- y_pred)\*\* 2).sum()
and \(v\) is the total sum of squares ((y_true \- y_true.mean()) \*\* 2).sum()
. The best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse). A constant model that always predicts the expected value of y
, disregarding the input features, would get a \(R^2\) score of 0.0.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | ArrayLike | Sample weights. |
opts.X ? | ArrayLike [] | Test samples. For some estimators this may be a precomputed kernel matrix or a list of generic objects instead with shape (n_samples, n_samples_fitted) , where n_samples_fitted is the number of samples used in the fitting for the estimator. |
opts.y ? | ArrayLike | True values for X . |
Returns Promise
<number
>
Defined in generated/svm/SVR.ts:288
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/SVR.ts:334
set_score_request()
set_score_request(
opts
):Promise
<any
>
Request metadata passed to the score
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 score . |
Returns Promise
<any
>
Defined in generated/svm/SVR.ts:370