Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simpler models should be selected in Forward/Backward Selection in Lecture_6_Notebook.ipynb #7

Open
covuworie opened this issue Jun 26, 2018 · 0 comments

Comments

@covuworie
Copy link

covuworie commented Jun 26, 2018

I've spotted two small bugs in Lecture_6_Notebook.ipynb in the Forward Selection and Backward Selection code. There are 3 models in both cases where the feature sets in have exactly the same value of R squared and AIC respectively.

In both cases, the model with the the largest number of features is selected. Really, in accordance with Occam's razor, we should favor the simplest model and select the model with the smallest number of features.

  1. Forward Selection code should read:
best_predictor_set = sorted(predictors, key=lambda t: t[1], reverse=True)[0]
  1. Backward Selection code should read:
best_predictor_set = sorted(predictors, key=lambda t: t[1], reverse=True)[-1]

PS: I would have submitted a pull request, but wasn't sure you would want it as the output in the notebook would change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant