Documentation
Classes
SVR

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.

Python Reference (opens in a new tab)

Constructors

constructor()

Signature

new SVR(opts?: object): SVR;

Parameters

NameTypeDescription
opts?object-
opts.C?numberRegularization parameter. The strength of the regularization is inversely proportional to C. Must be strictly positive. The penalty is a squared l2 penalty. Default Value 1
opts.cache_size?numberSpecify the size of the kernel cache (in MB). Default Value 200
opts.coef0?numberIndependent term in kernel function. It is only significant in ‘poly’ and ‘sigmoid’. Default Value 0
opts.degree?numberDegree of the polynomial kernel function (‘poly’). Must be non-negative. Ignored by all other kernels. Default Value 3
opts.epsilon?numberEpsilon 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. Default Value 0.1
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?numberHard limit on iterations within solver, or -1 for no limit. Default Value -1
opts.shrinking?booleanWhether to use the shrinking heuristic. See the User Guide. Default Value true
opts.tol?numberTolerance for stopping criterion. Default Value 0.001
opts.verbose?booleanEnable 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

SVR

Defined in: generated/svm/SVR.ts:27 (opens in a new tab)

Methods

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/SVR.ts:171 (opens in a new tab)

fit()

Fit the SVM model according to the given training data.

Signature

fit(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLikeTraining 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.sample_weight?ArrayLikePer-sample weights. Rescale C per sample. Higher weights force the classifier to put more emphasis on these points.
opts.y?ArrayLikeTarget values (class labels in classification, real numbers in regression).

Returns

Promise<any>

Defined in: generated/svm/SVR.ts:188 (opens in a new tab)

get_metadata_routing()

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Signature

get_metadata_routing(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.routing?anyA MetadataRequest encapsulating routing information.

Returns

Promise<any>

Defined in: generated/svm/SVR.ts:236 (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

NameType
pyPythonBridge

Returns

Promise<void>

Defined in: generated/svm/SVR.ts:122 (opens in a new tab)

predict()

Perform regression on samples in X.

For an one-class model, +1 (inlier) or -1 (outlier) is returned.

Signature

predict(opts: object): Promise<ArrayLike>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLikeFor kernel=”precomputed”, the expected shape of X is (n_samples_test, n_samples_train).

Returns

Promise<ArrayLike>

Defined in: generated/svm/SVR.ts:271 (opens in a new tab)

score()

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.

Signature

score(opts: object): Promise<number>;

Parameters

NameTypeDescription
optsobject-
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.sample_weight?ArrayLikeSample weights.
opts.y?ArrayLikeTrue values for X.

Returns

Promise<number>

Defined in: generated/svm/SVR.ts:306 (opens in a new tab)

set_fit_request()

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:

Signature

set_fit_request(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.sample_weight?string | booleanMetadata routing for sample\_weight parameter in fit.

Returns

Promise<any>

Defined in: generated/svm/SVR.ts:357 (opens in a new tab)

set_score_request()

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:

Signature

set_score_request(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.sample_weight?string | booleanMetadata routing for sample\_weight parameter in score.

Returns

Promise<any>

Defined in: generated/svm/SVR.ts:394 (opens in a new tab)

Properties

_isDisposed

boolean = false

Defined in: generated/svm/SVR.ts:25 (opens in a new tab)

_isInitialized

boolean = false

Defined in: generated/svm/SVR.ts:24 (opens in a new tab)

_py

PythonBridge

Defined in: generated/svm/SVR.ts:23 (opens in a new tab)

id

string

Defined in: generated/svm/SVR.ts:20 (opens in a new tab)

opts

any

Defined in: generated/svm/SVR.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/SVR.ts:427 (opens in a new tab)

dual_coef_

Coefficients of the support vector in the decision function.

Signature

dual_coef_(): Promise<ArrayLike[]>;

Returns

Promise<ArrayLike[]>

Defined in: generated/svm/SVR.ts:450 (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/SVR.ts:540 (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/SVR.ts:472 (opens in a new tab)

intercept_

Constants in decision function.

Signature

intercept_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/svm/SVR.ts:495 (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/SVR.ts:517 (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/SVR.ts:563 (opens in a new tab)

py

Signature

py(): PythonBridge;

Returns

PythonBridge

Defined in: generated/svm/SVR.ts:109 (opens in a new tab)

Signature

py(pythonBridge: PythonBridge): void;

Parameters

NameType
pythonBridgePythonBridge

Returns

void

Defined in: generated/svm/SVR.ts:113 (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/SVR.ts:585 (opens in a new tab)

support_

Indices of support vectors.

Signature

support_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/svm/SVR.ts:607 (opens in a new tab)

support_vectors_

Support vectors.

Signature

support_vectors_(): Promise<ArrayLike[]>;

Returns

Promise<ArrayLike[]>

Defined in: generated/svm/SVR.ts:629 (opens in a new tab)