libsvm
. That’s the reason
LinearSVR
has more flexibility in the choice of
penalties and loss functions. It also scales better to large number of samples.
If we talk about its parameters and attributes then it does not support
‘kernel’
because
it is assumed to be linear and it also lacks some of the attributes like
support_,
support_vectors_, n_support_, fit_status_
and,
dual_coef_
.
However, it supports ‘loss’ parameters as follows:
loss:
string, optional, default = ‘epsilon_insensitive’
It represents the loss function where epsilon_insensitive loss is the L1 loss and the squared
epsilon-insensitive loss is the L2 loss.
Implementation Example
Following Python script uses
sklearn.svm.LinearSVR
class
:
from sklearn.svm import LinearSVR
from sklearn.datasets import make_regression
X, y = make_regression(n_features=4, random_state=0)
LSVRReg = LinearSVR(dual = False, random_state=0,
loss='squared_epsilon_insensitive',tol=1e-5)
Scikit-Learn
74
LSVRReg.fit(X, y)
Output
LinearSVR(C=1.0, dual=False, epsilon=0.0, fit_intercept=True,
intercept_scaling=1.0, loss='squared_epsilon_insensitive',
max_iter=1000, random_state=0, tol=1e-05, verbose=0)
Now, once fitted, the model can predict new values as follows:
LSRReg.predict([[0,0,0,0]])
Output
array([-0.01041416])
For the above example, we can get the weight vector with the help of following python
script:
LSRReg.coef_
Output
array([20.47354746, 34.08619401, 67.23189022, 87.47017787])
Similarly, we can get the value of intercept with the help of following python script:
LSRReg.intercept_
Output
array([-0.01041416])
Scikit-Learn
75
Here, we will learn about what is anomaly detection in Sklearn and how it is used in
identification of the data points.
Anomaly detection is a technique used to identify data points in dataset that does not fit
well with the rest of the data. It has many applications in business such as fraud detection,
intrusion detection, system health monitoring, surveillance, and predictive maintenance.
Anomalies, which are also called outlier, can be divided into following three categories:
Dostları ilə paylaş: |