StanislavYatsevich / Store_Sales

The project is aimed at stores' sales prediction
0 stars 0 forks source link

functions.py module organization #12

Open astraszab opened 3 weeks ago

astraszab commented 3 weeks ago

What are the benefits of having all the non-click functions extracted into a single functions.py module? For example prepare_data is only used in splitting_and_preparing_data.py, but it is placed separately from it in functions.py - what do we gain from this separation? Why are we combine functions that are seemingly very different into a single module? For example, feature engineering and hyperparameter optimizations are both in there

StanislavYatsevich commented 2 weeks ago

Thank you, I got what you hint at.

What are the benefits of having all the non-click functions extracted into a single functions.py module? For example prepare_data is only used in splitting_and_preparing_data.py, but it is placed separately from it in functions.py - what do we gain from this separation?

Well, actually separating all non-click functions from the place where they are used has some benefits. The first is that this prevents us from copying and pasting the same code multiple times to different places. Even though prepare_data() (or any other function) is only used in the splitting_and_preparing_data.py script, there can still be a need for its usage in other places. For example, we may need to test it in another file after an update or during an ordinary troubleshooting or we may need to reorganize the project structure in the future somehow, so that we'll use this function in different places. Also, the approach of storing functions in a separate file helps us not to congest the scripts where this functions are used and to keep the code more clean and readable.

Why are we combine functions that are seemingly very different into a single module? For example, feature engineering and hyperparameter optimizations are both in there

That's a good point. I agree with you that it will be more convenient for both developers and users to have the functions stored in different files (modules) according to their content and usage. Will be updated. Upd: 59a6c2d