for lamb in lambda_seq: ridge_model = sm.ols(formula, data=male_df).fit_regularized(method='elastic_net', alpha=lamb, L1_wt=1) coeffs_array.append(list(ridge_model.params)) predictions = ridge_model.fittedvalues residuals = [x - y for x, y in zip(np.squeeze(predictions), childHeight)]