Refactoring model selection from pycon tutorial