Refactoring: move algorithm and data extraction from CSV into separate functions. Grid search on the model parameters.