Nowadays, Data Scientists are becoming more and more involved in the production side of deploying a machine learning model. This means we need to be able to write production standard Python code like our fellow software engineers. In this article, I want to go over some of the key tools and packages that can aid in creating production-worthy code for your next model.
Linters are a tool that catches small bugs, formatting errors, and odd design patterns that can lead to runtime problems and unexpected outputs.
To install flake8
pip install flake8 and you can use it by
flake8 <file_name.py>. It really is that simple!
For example, let’s say we have the function
add_numbers in a file
result = a+ b
To call flake8 on this file, we execute
flake8 flake8_example.py and the output looks like this:
Flake8 has picked up several styling errors that we should correct to be in line with PEP8.
See here for more information about flake8 and how to customise it for your needs.
Linters often just tell you what’s wrong with your code but don’t actively fix it for you. Formatters do fix your code and help expedite your workflow, ensure your code adheres to style guides, and makes it more readable for other people.