🍪

【Directory Management】How to use Cookiecutter Data Science

2024/06/25に公開

1. What is this?

Official site:
https://cookiecutter-data-science.drivendata.org/

Cookiecutter Data Science is a tool for making directory template to machine learning.

By using this, you can create directory like this:

Directroy architecture
├── LICENSE            <- Open-source license if one is chosen
├── Makefile           <- Makefile with convenience commands like `make data` or `make train`
├── README.md          <- The top-level README for developers using this project.
├── data
│   ├── external       <- Data from third party sources.
│   ├── interim        <- Intermediate data that has been transformed.
│   ├── processed      <- The final, canonical data sets for modeling.
│   └── raw            <- The original, immutable data dump.
│
├── docs               <- A default mkdocs project; see www.mkdocs.org for details
│
├── models             <- Trained and serialized models, model predictions, or model summaries
│
├── notebooks          <- Jupyter notebooks. Naming convention is a number (for ordering),
│                         the creator's initials, and a short `-` delimited description, e.g.
│                         `1.0-jqp-initial-data-exploration`.
│
├── pyproject.toml     <- Project configuration file with package metadata for 
│                         {{ cookiecutter.module_name }} and configuration for tools like black
│
├── references         <- Data dictionaries, manuals, and all other explanatory materials.
│
├── reports            <- Generated analysis as HTML, PDF, LaTeX, etc.
│   └── figures        <- Generated graphics and figures to be used in reporting
│
├── requirements.txt   <- The requirements file for reproducing the analysis environment, e.g.
│                         generated with `pip freeze > requirements.txt`
│
├── setup.cfg          <- Configuration file for flake8
│
└── {{ cookiecutter.module_name }}   <- Source code for use in this project.
    │
    ├── __init__.py             <- Makes {{ cookiecutter.module_name }} a Python module
    │
    ├── config.py               <- Store useful variables and configuration
    │
    ├── dataset.py              <- Scripts to download or generate data
    │
    ├── features.py             <- Code to create features for modeling
    │
    ├── modeling                
    │   ├── __init__.py 
    │   ├── predict.py          <- Code to run model inference with trained models          
    │   └── train.py            <- Code to train models
    │
    └── plots.py                <- Code to create visualizations   

This is very organized and great.

2. Install

pipx install cookiecutter-data-science

or

pip install cookiecutter-data-science

3. Use

Execute just this:

ccds

Then, you get many question to create directory. You should choice it with a light heart, and when you make a mistake, delete directory and retry!

This is great as is, but be more better by do like this:
This from @pluck.

├── project
│   ├── __init__.py
│   ├── train.py  <- Switch the model below when train
│   │
│   ├── data
│   │   └── make_dataset.py
│   │
│   ├── models  
│   │   │
│   │   ├── base  <- define base class
│   │   │   ├── __init__.py
│   │   │   ├── model.py
│   │   │   └── preprocess.py
│   │   ├── lightgbm 
│   │   │   ├── __init__.py
│   │   │   ├── model.py
│   │   │   └── preprocess.py
│   │   └── cnn
│   │       ├── __init__.py
│   │       ├── model.py
│   │       └── preprocess.py
│   │
│   └── visualization
│       └── visualize.py

4. Summary

Cookiecutter Data Science makes your machine learning life more confortly. Please try it.

Reference

[1] Cookiecutter Data Science
[2] Cookiecutter Data Scienceの改善案

Discussion