<> Elastic network regression
Elastic network ElasticNet It uses the coefficient vector at the same time l1 Norm sum l2 Linear regression model of norm , So that you can learn to be similar to Lasso A sparse model of , At the same time, it has been retained
Ridge Regularization properties of , It combines the advantages of both , It is especially suitable for situations where multiple features are related to each other .
<> Description of main parameters

alpha: a value .

fit_intercept: A Boolean value , Specifies whether calculation is required b value . If False, Then don't count b value ( The model will assume that you've become data centric ).

max_iter: Integer value , Specifies the maximum number of iterations .

normalize: A Boolean value . If True, Then the training samples will be normalized before regression .

copy_X: A Boolean value , If True, Will be copied X value

precompute: A Boolean or a sequence . He decided whether to calculate ahead of time Gram Matrix to speed up the calculation .

tol: A floating point number , Specifies the threshold to judge whether the iteration converges or not .

warm_start: A Boolean value , If True, Then use the previous training results to continue training . Or start training again .

positive: A Boolean value , If Ture, Then, it is mandatory that the loud components in the whole should be integers .

selection: A string , Can be used for ‘cyclic’( Update time , Select one component of the weight vector one at a time from front to back to update ) perhaps ‘random’( Randomly select a component of the weight vector to update ), He specifies when each iteration is made , Select a component of the weight vector to update

random_state: An integer or an integer RandomState example , Or for None. If integer , Then he specifies the seed of the random number generator . If RandomState example , A random number generator is specified . If None, The default random number generator is used .
%config InteractiveShell.ast_node_interactivity = 'all' # Output multi row results at the same time from sklearn.
linear_modelimport ElasticNet reg = ElasticNet(alpha=1.0, l1_ratio=0.7) X = [[3]
, [8]] y = [1, 2] reg.fit(X, y) ElasticNet(alpha=1.0, copy_X=True, fit_intercept
=True, l1_ratio=0.7, max_iter=1000, normalize=False, positive=False, precompute=
False, random_state=None, selection='cyclic', tol=0.0001, warm_start=False)
# Parameter meaning and lasso and ridge similar reg.predict([[6]]) reg.coef_ reg.intercept_
ElasticNet(alpha=1.0, copy_X=True, fit_intercept=True, l1_ratio=0.7,
max_iter=1000, normalize=False, positive=False, precompute=False,
random_state=None, selection='cyclic', tol=0.0001, warm_start=False)
ElasticNet(alpha=1.0, copy_X=True, fit_intercept=True, l1_ratio=0.7,
max_iter=1000, normalize=False, positive=False, precompute=False,
random_state=None, selection='cyclic', tol=0.0001, warm_start=False)
array([1.54198473]) array([0.08396947]) 1.0381679389312977 # Modify parameter comparison results reg =
ElasticNet(alpha=1.0, l1_ratio=0.3) # modify parameters , Compare reg.fit(X, y) ElasticNet(alpha=
1.0, copy_X=True, fit_intercept=True, l1_ratio=0.3, max_iter=1000, normalize=
False, positive=False, precompute=False, random_state=None, selection='cyclic',
tol=0.0001, warm_start=False) reg.predict([[6]]) reg.coef_ reg.intercept_
ElasticNet(alpha=1.0, copy_X=True, fit_intercept=True, l1_ratio=0.3,
max_iter=1000, normalize=False, positive=False, precompute=False,
random_state=None, selection='cyclic', tol=0.0001, warm_start=False)
ElasticNet(alpha=1.0, copy_X=True, fit_intercept=True, l1_ratio=0.3,
max_iter=1000, normalize=False, positive=False, precompute=False,
random_state=None, selection='cyclic', tol=0.0001, warm_start=False)
array([1.56834532]) array([0.13669065]) 0.748201438848921 # utilize IRIS Elastic network regression was applied to the data set
import pandas as pd import numpy as np from sklearn.datasets import load_iris
from sklearn import linear_model from sklearn import metrics # Import IRIS data set iris =
load_iris() # Characteristic matrix X=iris.data # Target vector y=iris.target from sklearn.
cross_validationimport train_test_split # Import data partition package # with 20% Data construction test sample , The rest is used as training sample X_train
,X_test,y_train,y_test=train_test_split(X,y,test_size=0.20,random_state =1)
elastic= linear_model.ElasticNet(alpha=0.1,l1_ratio=0.5) # set up lambda value ,l1_ratio value
elastic.fit(X_train,y_train) # Using training data to solve parameters y_hat2 = elastic.predict(X_test)
# Prediction of test set print ("RMSE:", np.sqrt(metrics.mean_squared_error(y_test, y_hat2)))
# calculation RMSE ElasticNet(alpha=0.1, copy_X=True, fit_intercept=True, l1_ratio=0.5,
max_iter=1000, normalize=False, positive=False, precompute=False,
random_state=None, selection='cyclic', tol=0.0001, warm_start=False) RMSE:
0.25040264500501913

Technology
©2019-2020 Toolsou All rights reserved,
QT Delete directory and file Java aggregate ------LinkedHashMap Underlying principle I've been drinking soft water for three years ? What is the use of soft water and water softener Java Xiao Ming A+B About wechat payment body( Product description ) Problems encountered Digital rolling lottery program 3 species Python data structure ,13 Creation methods , This is the conclusion , Great ! Huawei Mate 40 Pro+ 5G exposure : Leica film lens , Ceramic body What's the difference in server prices ? Operators Website visitors' mobile phone number capture