Skip to content

Instantly share code, notes, and snippets.

@naddeoa
Last active April 28, 2019 21:30
Show Gist options
  • Save naddeoa/72254acab7ab0bbd63271f1e3d299255 to your computer and use it in GitHub Desktop.
Save naddeoa/72254acab7ab0bbd63271f1e3d299255 to your computer and use it in GitHub Desktop.
Python ML project setup
# Logic above in make form. Run with `make init`
project.name := project-name
freeze.txt := requirements.txt
notebook.dir := notebooks
data.dir := data
src.dir := src
.PHONY: init dependencies reinstall
init: $(project.name)
bash -c "source ./$(project.name)/bin/activate && make dependencies $(freeze.txt) $(notebook.dir) $(data.dir) $(src.dir)"
@echo
@echo "Done. Execute this command manually before working: source ./$(project.name)/bin/activate"
$(project.name):
python3 -m virtualenv $(project.name)
$(freeze.txt):
pip3 freeze > $(freeze.txt)
$(notebook.dir):
mkdir -p $(notebook.dir)
$(data.dir):
mkdir -p $(data.dir)
$(src.dir):
mkdir -p $(src.dir)
dependencies:
pip3 install jupyter pandas numpy sklearn freeze Pygments matplotlib
reinstall:
pip3 install -r $(freeze.txt)
# Create a virtual env where everything is installed
python3 -m virtualenv project-name
# Source the geenrated activate script to update your local env variables. Like a bad chroot.
source ./kaggle-titanic/bin/activate
# Install whatever you need for the project locally
pip3 install jupyter pandas numpy sklearn matplotlib
# Start your jupyter notebook and do some stuff
jupyter notebook
# Optionally, make a dedicated dir for saving notebook stuff to
mkdir ./notebook/
# Download and save your data locally
mkdir ./data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment