Machine Learning tools, techniques, gists and projects. Some of this code is referenced in our Blog.
This repository uses pipenv as an environment manager.
The base python version is 3.9.
You will need a base python installed in your system.
python --versionThen you will need to install pip and pipenv.
python -m pip install --user pip --upgrade pip
python -m pip install --user pipenvInstall the dependencies with
make installThis calls pipenv, which will create a virtual environment for this project.
To activate this environment run
make activateTo add this project's packages to the environment run
make packagesInstall and lock packages always through make, as it will handle different platforms for you.
If a new platform is not supported, please update the platform_pipfile.py appropriately, or create a new platform directory if necessary. This should be a temporary fix, as Pipenv creates multi-platform Pipfile.lock support.
To see graphs of ML models using tf.keras.utils.plot_model, you will also need graphviz.
The [packages] and [dev-packages] sections of the Pipfiles correspond to dependencies imported in the code, and those used through the cli respectively.
Every file in the cli/ folder is an independent example available through
CLI commands. Use python <file>.py --help to see the available options
for the given example.
For example, try running the Snake Game:
.../cli > python play_snake.pyRun the entire test suite with pytest.
Use
make testWe use PEP8 as a style guide for python code.
Check lint errors with
make lintWe use autopep8 to automatically fix errors.
Use
make lintfixor
make lintfixhardfor in-place fixing of lint errors under the /src dir.
If you are using VSCode, the virtual environment created by pipenv will not
be immediately available and you will see warnings in your import statements.
To fix this first make sure the appropriate virtual environment is activated
by running make activate, then get the location of the current python
interpreter using make python. The printed line should look something like
this:
/Users/yourname/path/to/virtualenvs/machine-learning-abcde1234/bin/pythonCopy that line. Then open your
settings.json
file and add a new key "python.defaultInterpreterPath", then paste the
previously copied python interpreter path as its value and restart VSCode.
{
"python.defaultInterpreterPath": "/Users/yourname/path/to/virtualenvs/machine-learning-abcde1234/bin/python"
}- Create a new feature branch that compares to the main branch and open a PR.
- Ensure you have written appropriate tests and they are passing.
- Ensure the code passes the style guide conventions.
If some dependencies were added, update the Pipfile.lock file
using:
make lock