Scikit-Learn



Yüklə 1,92 Mb.
Pdf görüntüsü
səhifə42/124
tarix23.02.2023
ölçüsü1,92 Mb.
#101394
1   ...   38   39   40   41   42   43   44   45   ...   124
sklearn

RandomState instance
: In this case, 
random_state
is the random number 
generator.

None
: In this case, the random number 
generator is the RandonState instance used 
by np.random.
selection
: str, default=‘cyclic’ 
 

Cyclic
: The default value is cyclic which 
means the features will be looping over 
sequentially by default. 

Random
: If we set the selection to 
random, a random coefficient will be 
updated every iteration. 
Attributes 
Followings table consist the attributes used by 
Lasso
module: 
Attributes 
Description 
coef_

array, 
shape(n_features,) 
or 
(n_target, n_features) 
This attribute provides the weight vectors.
intercept_
: float | array, shape = 
(n_targets) 
It represents the independent term in decision 
function. 
n_iter_

int 
or 
array-like, 
shape 
(n_targets) 
It gives the number of iterations run by the 
coordinate descent solver to reach the specified 
tolerance.
Implementation Example 
Following Python script uses Lasso model which further uses coordinate descent as the 
algorithm to fit the coefficients: 


Scikit-Learn
45 
from sklearn import linear_model 
Lreg = linear_model.Lasso(alpha=0.5) 
Lreg.fit([[0,0], [1, 1], [2, 2]], [0, 1, 2]) 
Output 
Lasso(alpha=0.5, copy_X=True, fit_intercept=True, max_iter=1000, 
normalize=False, positive=False, precompute=False, random_state=None, 
selection='cyclic', tol=0.0001, warm_start=False) 
Now, once fitted, the model can predict new values as follows: 
Lreg.predict([[0,1]]) 

Yüklə 1,92 Mb.

Dostları ilə paylaş:
1   ...   38   39   40   41   42   43   44   45   ...   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ə