1 from sklearn.model_selection import train_test_split 2 from sklearn.datasets import load_diabetes 3 X,y=load_diabetes().data,load_diabetes().target 4 X_train,X_test,y_train,y_test=train_test_split(X,y,random_state=8) 5 6 import numpy as np 7 from sklearn import linear_model 8 elastic_net=linear_model.ElasticNet().fit(X_train,y_train) 9 print("the coefficient:{}".format(elastic_net.coef_)) 10 print('the intercept:{}'.format(elastic_net.intercept_)) 11 print("the score of this model:{:.3f}".format(elastic_net.score(X_test,y_test))) 12 print("the model uses {}".format(np.sum(elastic_net.coef_!=0))+" features ")