Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Pyenv and poetry for environment management #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 136 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# User defined ignores
.DS_Store
.python-version


# Autogenerated

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.DEFAULT_GOAL:=help

# --------------------------
.PHONY: install jupyter pyenv

pyenv: ## Create the env with pyenv
pyenv virtualenv -f 3.8.12 islp
pyenv local islp
@make install

install: ## Install python environment
poetry install

jupyter: ## Run jupyter lab
poetry run jupyter lab

help: ## Show this help.
@echo "Make for ISLP"
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m (default: help)\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-12s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
42 changes: 24 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,31 @@ In this repository, I have implemented the same/similar functionality in Python.
Please refer https://www.statlearning.com/ for more details. In 2nd Edition, the authors introduced a R library ISLR2 for all the dataset used in the book.

### Setup for this repository:
* Python==3.6.2
* ipykernal==4.10.0
* numpy==1.19.2
* matplotlib==3.3.4
* pandas==1.1.5
* statsmodels==0.12.2
* scikit-learn==0.21.1
* patsy==0.5.1
* scipy==1.5.2
* seaborn==0.11.2
* json==2.0.9
* tensorflow==2.0.0
* keras==2.3.1
* lifelines==0.26.3
* math
* random
* collections
* itertools

The python environment is managed with [poetry](https://python-poetry.org/) and [pyenv](https://github.com/pyenv/pyenv).

To setup the environment run:

1. Make sure you have `pyenv` installed on your system, with the [pyenv-virtualenv](https://github.com/pyenv/pyenv-virtualenv) plugin.
2. Run `make pyenv`. This will install pyhton 3.8.12 on your environment, create a virtual local environment `islp` and assign it to this repo.
3. Run `make jupyter` to start an instance of jupyter lab.
4. Open and run the notebooks.


The dependencies can be seen from [pyproject.toml]() under `[tool.poetry.dependencies]`:
```
python = "3.8.12"
jupyterlab = "^3.2.4"
pandas = "^1.3.4"
numpy = "^1.21.5"
matplotlib = "^3.5.1"
statsmodels = "^0.13.1"
scikit-learn = "^1.0.1"
seaborn = "^0.11.2"
tensorflow = "^2.7.0"
keras = "^2.7.0"
lifelines = "^0.26.4"
```

### Special thanks to Bommy

Expand Down
Loading