Linear Support Vector Regression.
Similar to SVR with parameter kernel=’linear’, but implemented in terms of liblinear rather than libsvm, so it has more flexibility in the choice of penalties and loss functions and should scale better to large numbers of samples.
The main differences between LinearSVR
and SVR
lie in the loss function used by default, and in the handling of intercept regularization between those two implementations.
This class supports both dense and sparse input.
Read more in the User Guide.
new LinearSVR(opts?: object): LinearSVR;
Name | Type | Description |
---|---|---|
opts? |
object |
- |
opts.C? |
number |
Regularization parameter. The strength of the regularization is inversely proportional to C. Must be strictly positive. Default Value 1 |
opts.dual? |
boolean | "auto" |
Select the algorithm to either solve the dual or primal optimization problem. Prefer dual=false when n_samples > n_features. dual="auto" will choose the value of the parameter automatically, based on the values of n\_samples , n\_features and loss . If n\_samples < n\_features and optimizer supports chosen loss , then dual will be set to true , otherwise it will be set to false . Default Value true |
opts.epsilon? |
number |
Epsilon parameter in the epsilon-insensitive loss function. Note that the value of this parameter depends on the scale of the target variable y. If unsure, set epsilon=0 . Default Value 0 |
opts.fit_intercept? |
boolean |
Whether or not to fit an intercept. If set to true , the feature vector is extended to include an intercept term: \[x\_1, ..., x\_n, 1\] , where 1 corresponds to the intercept. If set to false , no intercept will be used in calculations (i.e. data is expected to be already centered). Default Value true |
opts.intercept_scaling? |
number |
When fit\_intercept is true , the instance vector x becomes \[x\_1, ..., x\_n, intercept\_scaling\] , i.e. a “synthetic” feature with a constant value equal to intercept\_scaling is appended to the instance vector. The intercept becomes intercept_scaling * synthetic feature weight. Note that liblinear internally penalizes the intercept, treating it like any other term in the feature vector. To reduce the impact of the regularization on the intercept, the intercept\_scaling parameter can be set to a value greater than 1; the higher the value of intercept\_scaling , the lower the impact of regularization on it. Then, the weights become \[w\_x\_1, ..., w\_x\_n, w\_intercept\*intercept\_scaling\] , where w\_x\_1, ..., w\_x\_n represent the feature weights and the intercept weight is scaled by intercept\_scaling . This scaling allows the intercept term to have a different regularization behavior compared to the other features. Default Value 1 |
opts.loss? |
"epsilon_insensitive" | "squared_epsilon_insensitive" |
Specifies the loss function. The epsilon-insensitive loss (standard SVR) is the L1 loss, while the squared epsilon-insensitive loss (‘squared_epsilon_insensitive’) is the L2 loss. Default Value 'epsilon_insensitive' |
opts.max_iter? |
number |
The maximum number of iterations to be run. Default Value 1000 |
opts.random_state? |
number |
Controls the pseudo random number generation for shuffling the data. Pass an int for reproducible output across multiple function calls. See Glossary. |
opts.tol? |
number |
Tolerance for stopping criteria. Default Value 0.0001 |
opts.verbose? |
number |
Enable verbose output. Note that this setting takes advantage of a per-process runtime setting in liblinear that, if enabled, may not work properly in a multithreaded context. Default Value 0 |
Defined in: generated/svm/LinearSVR.ts:29
Disposes of the underlying Python resources.
Once dispose()
is called, the instance is no longer usable.
dispose(): Promise<void>;
Promise
<void
>
Defined in: generated/svm/LinearSVR.ts:164
Fit the model according to the given training data.
fit(opts: object): Promise<any>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.X? |
ArrayLike |
Training vector, where n\_samples is the number of samples and n\_features is the number of features. |
opts.sample_weight? |
ArrayLike |
Array of weights that are assigned to individual samples. If not provided, then each sample is given unit weight. |
opts.y? |
ArrayLike |
Target vector relative to X. |
Promise
<any
>
Defined in: generated/svm/LinearSVR.ts:181
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
get_metadata_routing(opts: object): Promise<any>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.routing? |
any |
A MetadataRequest encapsulating routing information. |
Promise
<any
>
Defined in: generated/svm/LinearSVR.ts:230
Initializes the underlying Python resources.
This instance is not usable until the Promise
returned by init()
resolves.
init(py: PythonBridge): Promise<void>;
Name | Type |
---|---|
py |
PythonBridge |
Promise
<void
>
Defined in: generated/svm/LinearSVR.ts:115
Predict using the linear model.
predict(opts: object): Promise<any>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.X? |
any |
Samples. |
Promise
<any
>
Defined in: generated/svm/LinearSVR.ts:265
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.
score(opts: object): Promise<number>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
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? |
ArrayLike |
Sample weights. |
opts.y? |
ArrayLike |
True values for X . |
Promise
<number
>
Defined in: generated/svm/LinearSVR.ts:298
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:
set_fit_request(opts: object): Promise<any>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.sample_weight? |
string | boolean |
Metadata routing for sample\_weight parameter in fit . |
Promise
<any
>
Defined in: generated/svm/LinearSVR.ts:349
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:
set_score_request(opts: object): Promise<any>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.sample_weight? |
string | boolean |
Metadata routing for sample\_weight parameter in score . |
Promise
<any
>
Defined in: generated/svm/LinearSVR.ts:386
boolean
=false
Defined in: generated/svm/LinearSVR.ts:27
boolean
=false
Defined in: generated/svm/LinearSVR.ts:26
PythonBridge
Defined in: generated/svm/LinearSVR.ts:25
string
Defined in: generated/svm/LinearSVR.ts:22
any
Defined in: generated/svm/LinearSVR.ts:23
Weights assigned to the features (coefficients in the primal problem).
coef\_
is a readonly property derived from raw\_coef\_
that follows the internal memory layout of liblinear.
coef_(): Promise<ArrayLike[]>;
Promise
<ArrayLike
[]>
Defined in: generated/svm/LinearSVR.ts:421
Names of features seen during fit. Defined only when X
has feature names that are all strings.
feature_names_in_(): Promise<ArrayLike>;
Promise
<ArrayLike
>
Defined in: generated/svm/LinearSVR.ts:492
Constants in decision function.
intercept_(): Promise<ArrayLike>;
Promise
<ArrayLike
>
Defined in: generated/svm/LinearSVR.ts:444
Number of features seen during fit.
n_features_in_(): Promise<number>;
Promise
<number
>
Defined in: generated/svm/LinearSVR.ts:467
Maximum number of iterations run across all classes.
n_iter_(): Promise<number>;
Promise
<number
>
Defined in: generated/svm/LinearSVR.ts:517
py(): PythonBridge;
PythonBridge
Defined in: generated/svm/LinearSVR.ts:102
py(pythonBridge: PythonBridge): void;
Name | Type |
---|---|
pythonBridge |
PythonBridge |
void
Defined in: generated/svm/LinearSVR.ts:106