Skip to content

Machine Learning tools, techniques, gists and projects. Some of this code is referenced in our Blog.

License

Notifications You must be signed in to change notification settings

8thlight/machine-learning

Repository files navigation

Build Status

Machine Learning

Machine Learning tools, techniques, gists and projects. Some of this code is referenced in our Blog.

ezgif-3-53a018627a

This repository uses pipenv as an environment manager. The base python version is 3.9.

Install dependencies

You will need a base python installed in your system.

python --version

Then you will need to install pip and pipenv.

python -m pip install --user pip --upgrade pip
python -m pip install --user pipenv

Install the dependencies with

make install

This calls pipenv, which will create a virtual environment for this project.

To activate this environment run

make activate

To add this project's packages to the environment run

make packages

Install 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.

Running examples

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.py

Tests

Run the entire test suite with pytest. Use

make test

Code Style

We use PEP8 as a style guide for python code.

Check lint errors with

make lint

We use autopep8 to automatically fix errors.

Use

make lintfix

or

make lintfixhard

for in-place fixing of lint errors under the /src dir.

VSCode

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/python

Copy 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"
}

Contribution

  1. Create a new feature branch that compares to the main branch and open a PR.
  2. Ensure you have written appropriate tests and they are passing.
  3. Ensure the code passes the style guide conventions.

If some dependencies were added, update the Pipfile.lock file using:

make lock