Credit default risk prediction pipeline — Kaggle competition dataset.
Notebook (.py) → presentation layer (Jupytext)
Python package → logic (data, features, models)
Papermill → parameterized execution & automation
credit/ # installable package — all logic lives here
data/ # load_train(), load_test()
features/ # build_features()
models/ # train(), evaluate()
utils/ # get_logger()
notebooks/ # Jupytext percent-format .py files (version-control friendly)
01_eda.py
02_feature_engineering.py
03_model_training.py
04_evaluation.py
outputs/ # Papermill-executed .ipynb outputs (gitignored except .gitkeep)
data/ # raw CSVs (gitignored)
poetry installActivate the virtual environment (Poetry 2.0+):
# Option 1 — recommended
source $(poetry env info --path)/bin/activate
# Option 2 — one-off commands without activating
poetry run python ...Install the Jupyter kernel for this env:
python -m ipykernel install --user --name give-me-some-creditInstall Poetry via PowerShell:
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python -If PowerShell blocks script execution, allow it first:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUserThen install dependencies and activate the environment:
poetry install
# activate
& $(poetry env info --path)\Scripts\Activate.ps1
# or run one-off commands without activating
poetry run python ...Install the Jupyter kernel:
python -m ipykernel install --user --name give-me-some-creditjupytext ships with a JupyterLab extension — open .py notebooks directly as notebooks, write code, and run cells without any conversion step:
jupyter lab notebooks/Right-click a .py file → Open With → Notebook. Edits are saved back to the .py file automatically.
Use Papermill for batch execution with overridden parameters (e.g. in CI or experiments). It requires a .ipynb input, so convert first:
jupytext --to notebook notebooks/03_model_training.py
papermill notebooks/03_model_training.ipynb outputs/03_model_training.ipynb \
-p n_estimators 200 \
-p max_depth 5Place the Kaggle files in data/:
cs-training.csvcs-test.csv
Download from: https://www.kaggle.com/competitions/GiveMeSomeCredit/data