Scikit-Learn
37
coef_
:
array,
shape(n_features,)
or
(n_classes, n_features)
It is used to estimate
the coefficients of the
features in the decision function. When the given
problem
is binary, it is of the shape (1,
n_features).
Intercept_
: array, shape(1) or (n_classes)
It
represents the constant,
also known as bias,
added to the decision function.
classes_
: array, shape(n_classes)
It will provide a list of
class labels known to the
classifier.
n_iter_
: array, shape (n_classes) or (1)
It returns the actual number of iterations for all the
classes.
Implementation Example
Following Python script provides a simple example of implementing logistic regression on
iris
dataset of scikit-learn:
from
sklearn import datasets
from
sklearn import linear
_
model
from sklearn.datasets import load
_
iris
X, y = load_iris(return_X_y=True)
LRG = linear
_
model.LogisticRegression(random_state=0,solver='liblinear',multi
).fit(X, y)
LRG.score(X, y)
Output
0.96
The output shows that the above Logistic Regression model gave the accuracy of 96
percent.
Ridge Regression
Ridge regression or Tikhonov regularization is the regularization technique that performs
L2 regularization. It modifies the loss function by adding the penalty (shrinkage quantity)
equivalent to the square of the magnitude of coefficients.
∑ (𝑌
𝑖
− 𝑊
0
− ∑ 𝑊
𝑖
𝑋
𝑗𝑖
𝑛
𝑖=1
)
2
+
𝑚
𝑗=1
𝛼 ∑ 𝑊
𝑖
2
𝑛
𝑖=1
= 𝑙𝑜𝑠𝑠_𝑓𝑢𝑛𝑐𝑡𝑖𝑜𝑛 + 𝛼 ∑ 𝑊
𝑖
2
𝑛
𝑖=1
Dostları ilə paylaş: