@@ -231,7 +231,7 @@ les variables sélectionnées sont :
231
231
#| echo: false
232
232
233
233
#3. Estimer un modèle LASSO et afficher les valeurs des coefficients
234
- lasso1 = Lasso(fit_intercept=True,normalize=False, alpha = 0.1).fit(X_train,y_train)
234
+ lasso1 = Lasso(fit_intercept=True, alpha = 0.1).fit(X_train, y_train)
235
235
236
236
#np.abs(lasso1.coef_)
237
237
features_selec = df2.select_dtypes(include=np.number).drop("per_gop", axis = 1).columns[np.abs(lasso1.coef_)>0].tolist()
@@ -254,7 +254,7 @@ Par ailleurs, on sélectionne des variables redondantes. Une phase plus approfon
254
254
corr = df2[features_selec].corr()
255
255
256
256
plt.figure()
257
- p = corr.style.background_gradient(cmap='coolwarm', axis=None).set_precision(2 )
257
+ p = corr.style.background_gradient(cmap='coolwarm', axis=None).format('{:.2f}' )
258
258
p
259
259
```
260
260
@@ -358,7 +358,7 @@ yindex = df3.columns.get_loc("per_gop")
358
358
df3_scale = scaler.fit(df3).transform(df3)
359
359
# X_train, X_test , y_train, y_test = train_test_split(np.delete(data, yindex, axis = 1),data[:,yindex], test_size=0.2, random_state=0)
360
360
361
- lcv = LassoCV(alphas=my_alphas ,normalize=False, fit_intercept=False,random_state=0,cv=5).fit(np.delete(df3_scale, yindex, axis = 1), df3_scale[:,yindex])
361
+ lcv = LassoCV(alphas=my_alphas, fit_intercept=False,random_state=0,cv=5).fit(np.delete(df3_scale, yindex, axis = 1), df3_scale[:,yindex])
362
362
```
363
363
364
364
``` {python}
0 commit comments