Hi! I can’t figure out why I am getting the error:

Q8: FAIL

The ridge linear regression model was not trained properly

AssertionError : After fitting, ‘model.coef_’ must be a list of 304 weights

The code I have written is:

train_inputs, val_inputs, train_targets, val_targets = train_test_split(inputs_df[numeric_cols + encoded_cols], targets, test_size=0.25, random_state=42)

model = Ridge()

model.fit(train_inputs, train_targets)

X_train = train_inputs[numeric_cols + encoded_cols]

X_val = val_inputs[numeric_cols + encoded_cols]

train_preds = model.predict(X_train)

train_rmse = mean_squared_error(train_targets, train_preds)

val_preds = model.predict(X_val)

val_rmse = mean_squared_error(val_targets, val_preds)

weights = model.coef_