Question 6 and 7

I am not sure if I am doing it correctly, though my answers allowed me to select the right option.

For question 6, the ranking of my features did not change at all (unlike “weights order is very similar” as stated in the option).

# My code:
import numpy as np
from sklearn.linear_model import RidgeCV

alphas = np.logspace(-1, 3, num=30)

ridge_cv = make_pipeline(StandardScaler(), 
                         SimpleImputer(), 
                         RidgeCV(alphas=alphas)
                        )

ridgecv_results = cross_validate(ridge_cv,
                           data_numerical, target, 
                           cv = 10, 
                           scoring = 'neg_mean_squared_error',
                           return_estimator=True,      
                           n_jobs = 2)

coefs_cv = [estimator[-1].coef_ for estimator in ridgecv_results["estimator"]]
weights_ridgecv = pd.DataFrame(coefs_cv, columns=numerical_features)

For question 7, I got the exact same alpha for all folds except one, though it was in the correct range.

Also, what is **boxplot_property in _ = coefs.abs().plot.box(**boxplot_property, ax=ax)?
I could not plot the graphs…

Thanks for any help!

It is define in the answer of Q. 1:

boxplot_property = {
    "vert": True,
    "whis": 100,
    "patch_artist": True,
    "widths": 0.5,
    "rot": 90,
    "boxprops": dict(linewidth=3, color="black", alpha=0.9),
    "medianprops": dict(linewidth=2.5, color="black", alpha=0.9),
    "whiskerprops": dict(linewidth=3, color="black", alpha=0.9),
    "capprops": dict(linewidth=3, color="black", alpha=0.9),
}

Regarding your answers, it seem to be inline with the correction then.