Member-only story
Stop Hard Coding in a Data Science Project — Use Config Files Instead
How to efficiently interact with config files in Python
Originally published at https://mathdatasimplified.com on May 26, 2023.
Problem
In your data science project, certain values tend to change frequently, such as file names, selected features, train-test split ratio, and hyperparameters for your model.
It is okay to hard-code these values when writing ad-hoc code for hypothesis testing or demonstration purposes. However, as your code base and team expand, it becomes essential to avoid hard coding because it can give rise to various issues:
- Maintainability: If values are scattered throughout the codebase, updating them consistently becomes harder. This can lead to errors or inconsistencies when values must be updated.