TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Member-only story

Stop Hard Coding in a Data Science Project — Use Config Files Instead

How to efficiently interact with config files in Python

Khuyen Tran
TDS Archive
Published in
6 min readMay 26, 2023

--

Image by Author

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.

Image by Author

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:

  • : If values are scattered throughout the codebase, updating them consistently becomes harder. This can lead to errors or inconsistencies when values must be updated.

--

--

TDS Archive
TDS Archive

Published in TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Responses (32)