Scikit-Learn


Complete code of implementation example



Yüklə 1,92 Mb.
Pdf görüntüsü
səhifə31/124
tarix23.02.2023
ölçüsü1,92 Mb.
#101394
1   ...   27   28   29   30   31   32   33   34   ...   124
sklearn

Complete code of implementation example: 
import numpy as np 
from sklearn.linear_model import LinearRegression 
X = np.array([[1,1],[1,2],[2,2],[2,3]]) 
y = np.dot(X, np.array([1,2])) + 3 
regr = LinearRegression(fit_intercept=True, normalize = True, copy_X=True, 
n_jobs=2).fit(X,y) 
regr.predict(np.array([[3,5]])) 
regr.score(X,y) 
regr.coef

regr.intercept
_
Logistic Regression 
Logistic regression, despite its name, is a classification algorithm rather than regression 
algorithm. Based on a given set of independent variables, it is used to estimate discrete 
value (0 or 1, yes/no, true/false). It is also called logit or MaxEnt Classifier.
Basically, it measures the relationship between the categorical dependent variable and one 
or more independent variables by estimating the probability of occurrence of an event 
using its logistics function.
sklearn.linear_model.LogisticRegression
is the module used to implement logistic 
regression. 
Parameters 
Following table lists the parameters used by 
Logistic Regression
module: 
Parameter 
Description 
penalty

str, ‘L1’, ‘L2’, ‘elasticnet’ or none, 
optional, default = ‘L2’
 
This parameter is used to specify the norm (L1 or 
L2) used in penalization (regularization). 


Scikit-Learn
35 
dual
: Boolean, optional, default = False 
It is used for dual or primal formulation whereas 
dual formulation is only implemented for L2 
penalty. 
tol
: float, optional, default=1e-4 
It represents the tolerance for stopping criteria.
C
: float, optional, default=1.0 
It represents the inverse of regularization 
strength, which must always be a positive float.
fit_intercept
: Boolean, optional, default = 
True 
This parameter specifies that a constant (bias or 
intercept) should be added to the decision 
function.

Yüklə 1,92 Mb.

Dostları ilə paylaş:
1   ...   27   28   29   30   31   32   33   34   ...   124




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə