When a class in your Machine Learning code knows too much about its dependencies, you have a problem. You are not adhering to the Open-Closed Principle (‘O’ in the SOLID principles).
Your code will be tightly coupled and difficult to test in isolation.
Learn about the Open-Closed Principle, how to spot its violations, and how you can refactor ML code to respect it.
By adhering to OCP, your ML code will be cleaner and more maintainable in the longer run.
Slides:
https://github.com/musikalkemist/solidforml/blob/main/solidforml/03%20Open%20Closed%20Principle/Open%20Closed%20Principle.pdf
Code:
https://github.com/musikalkemist/solidforml/blob/main/solidforml/03%20Open%20Closed%20Principle/openclosed.py
===============================
Interested in hiring me as a consultant/freelancer?
https://valeriovelardo.com/
Join The Sound Of AI Slack community:
https://valeriovelardo.com/the-sound-of-ai-community/
Connect with Valerio on Linkedin:
https://www.linkedin.com/in/valeriovelardo
Follow Valerio on Facebook:
https://www.facebook.com/TheSoundOfAI
Follow Valerio on Twitter:
https://twitter.com/musikalkemist
===============================
Content:
0:00 Intro
0:21 Open-Closed Principle definition
1:20 OCP violation problems
1:57 How to spot OCP violations
2:34 Introducing the Python example
5:08 Why the example violates OCP
8:26 Solving the OCP violation
9:51 Refactoring the code
14:32 Outro