├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── cookiecutter.json ├── docs ├── README.md ├── docs │ ├── css │ │ └── extra.css │ ├── favicon.ico │ └── index.md └── mkdocs.yml ├── hooks └── pre_gen_project.py ├── requirements.txt ├── tests ├── conftest.py └── test_creation.py └── {{ cookiecutter.repo_name }} ├── .env ├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── data ├── external │ └── .gitkeep ├── interim │ └── .gitkeep ├── processed │ └── .gitkeep └── raw │ └── .gitkeep ├── docs ├── Makefile ├── commands.rst ├── conf.py ├── getting-started.rst ├── index.rst └── make.bat ├── models └── .gitkeep ├── notebooks └── .gitkeep ├── references └── .gitkeep ├── reports ├── .gitkeep └── figures │ └── .gitkeep ├── requirements.txt ├── setup.py ├── src ├── __init__.py ├── data │ ├── .gitkeep │ ├── __init__.py │ └── make_dataset.py ├── features │ ├── .gitkeep │ ├── __init__.py │ └── build_features.py ├── models │ ├── .gitkeep │ ├── __init__.py │ ├── predict_model.py │ └── train_model.py └── visualization │ ├── .gitkeep │ ├── __init__.py │ └── visualize.py ├── test_environment.py └── tox.ini /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | docs/site/ 2 | 3 | # OSX Junk 4 | .DS_Store 5 | 6 | # test cache 7 | .cache/* 8 | tests/__pycache__/* 9 | *.pytest_cache/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright (c) 2016 DrivenData, Inc. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Cookiecutter Data Science 2 | 3 | _A logical, reasonably standardized, but flexible project structure for doing and sharing data science work._ 4 | 5 | 6 | #### [Project homepage](http://drivendata.github.io/cookiecutter-data-science/) 7 | 8 | 9 | ### Requirements to use the cookiecutter template: 10 | ----------- 11 | - Python 2.7 or 3.5+ 12 | - [Cookiecutter Python package](http://cookiecutter.readthedocs.org/en/latest/installation.html) >= 1.4.0: This can be installed with pip by or conda depending on how you manage your Python packages: 13 | 14 | ``` bash 15 | $ pip install cookiecutter 16 | ``` 17 | 18 | or 19 | 20 | ``` bash 21 | $ conda config --add channels conda-forge 22 | $ conda install cookiecutter 23 | ``` 24 | 25 | 26 | ### To start a new project, run: 27 | ------------ 28 | 29 | cookiecutter -c v1 https://github.com/drivendata/cookiecutter-data-science 30 | 31 | 32 | [![asciicast](https://asciinema.org/a/244658.svg)](https://asciinema.org/a/244658) 33 | 34 | ### New version of Cookiecutter Data Science 35 | ------------ 36 | Cookiecutter data science is moving to v2 soon, which will entail using 37 | the command `ccds ...` rather than `cookiecutter ...`. The cookiecutter command 38 | will continue to work, and this version of the template will still be available. 39 | To use the legacy template, you will need to explicitly use `-c v1` to select it. 40 | Please update any scripts/automation you have to append the `-c v1` option (as above), 41 | which is available now. 42 | 43 | 44 | ### The resulting directory structure 45 | ------------ 46 | 47 | The directory structure of your new project looks like this: 48 | 49 | ``` 50 | ├── LICENSE 51 | ├── Makefile <- Makefile with commands like `make data` or `make train` 52 | ├── README.md <- The top-level README for developers using this project. 53 | ├── data 54 | │ ├── external <- Data from third party sources. 55 | │ ├── interim <- Intermediate data that has been transformed. 56 | │ ├── processed <- The final, canonical data sets for modeling. 57 | │ └── raw <- The original, immutable data dump. 58 | ├── data.dvc <- A data version control file (optional); see dvc.org for details 59 | │ 60 | ├── docs <- A default Sphinx project; see sphinx-doc.org for details 61 | │ 62 | ├── models <- Trained and serialized models, model predictions, or model summaries 63 | │ 64 | ├── notebooks <- Jupyter notebooks. Naming convention is a number (for ordering), 65 | │ the creator's initials, and a short `-` delimited description, e.g. 66 | │ `1.0-jqp-initial-data-exploration`. 67 | │ 68 | ├── references <- Data dictionaries, manuals, and all other explanatory materials. 69 | │ 70 | ├── reports <- Generated analysis as HTML, PDF, LaTeX, etc. 71 | │ └── figures <- Generated graphics and figures to be used in reporting 72 | │ 73 | ├── requirements.txt <- The requirements file for reproducing the analysis environment, e.g. 74 | │ generated with `pip freeze > requirements.txt` 75 | │ 76 | ├── setup.py <- makes project pip installable (pip install -e .) so src can be imported 77 | ├── src <- Source code for use in this project. 78 | │ ├── __init__.py <- Makes src a Python module 79 | │ │ 80 | │ ├── data <- Scripts to download or generate data 81 | │ │ └── make_dataset.py 82 | │ │ 83 | │ ├── features <- Scripts to turn raw data into features for modeling 84 | │ │ └── build_features.py 85 | │ │ 86 | │ ├── models <- Scripts to train models and then use trained models to make 87 | │ │ │ predictions 88 | │ │ ├── predict_model.py 89 | │ │ └── train_model.py 90 | │ │ 91 | │ └── visualization <- Scripts to create exploratory and results oriented visualizations 92 | │ └── visualize.py 93 | │ 94 | └── tox.ini <- tox file with settings for running tox; see tox.readthedocs.io 95 | ``` 96 | 97 | ## Contributing 98 | 99 | We welcome contributions! [See the docs for guidelines](https://drivendata.github.io/cookiecutter-data-science/#contributing). 100 | 101 | ### Installing development requirements 102 | ------------ 103 | 104 | pip install -r requirements.txt 105 | 106 | ### Running the tests 107 | ------------ 108 | 109 | py.test tests 110 | -------------------------------------------------------------------------------- /cookiecutter.json: -------------------------------------------------------------------------------- 1 | { 2 | "project_name": "project_name", 3 | "repo_name": "{{ cookiecutter.project_name.lower().replace(' ', '_') }}", 4 | "author_name": "Your name (or your organization/company/team)", 5 | "description": "A short description of the project.", 6 | "open_source_license": ["MIT", "BSD-3-Clause", "No license file"], 7 | "s3_bucket": "[OPTIONAL] your-bucket-for-syncing-data (do not include 's3://')", 8 | "aws_profile": "default", 9 | "use_data_version_control": "y", 10 | "python_interpreter": ["python3", "python"] 11 | } 12 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | Generating the docs 2 | ---------- 3 | 4 | Install requirements: 5 | 6 | pip install -r requirements.txt 7 | 8 | Change directories into the docs folder: 9 | 10 | cd docs 11 | 12 | Use [mkdocs](http://www.mkdocs.org/) structure to update the documentation. Test locally with: 13 | 14 | mkdocs serve 15 | 16 | Once the docs look good, publish to `gh-pages` branch with: 17 | 18 | mkdocs gh-deploy --clean 19 | 20 | ** Note **: Never edit the generated site by hand because using `gh-deploy` blows away the `gh-pages` branch and you'll lose your edits. 21 | -------------------------------------------------------------------------------- /docs/docs/css/extra.css: -------------------------------------------------------------------------------- 1 | h1, h2, h3 { 2 | margin-top: 77px; 3 | } 4 | -------------------------------------------------------------------------------- /docs/docs/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iterative/cookiecutter-data-science/b987fdc5f55ab7fc80b63a1f88c5ed98917e463c/docs/docs/favicon.ico -------------------------------------------------------------------------------- /docs/docs/index.md: -------------------------------------------------------------------------------- 1 | # Cookiecutter Data Science 2 | 3 | _A logical, reasonably standardized, but flexible project structure for doing and sharing data science work._ 4 | 5 | ## Why use this project structure? 6 | 7 | > We're not talking about bikeshedding the indentation aesthetics or pedantic formatting standards — ultimately, data science code quality is about correctness and reproducibility. 8 | 9 | When we think about data analysis, we often think just about the resulting reports, insights, or visualizations. While these end products are generally the main event, it's easy to focus on making the products _look nice_ and ignore the _quality of the code that generates them_. Because these end products are created programmatically, **code quality is still important**! And we're not talking about bikeshedding the indentation aesthetics or pedantic formatting standards — ultimately, data science code quality is about correctness and reproducibility. 10 | 11 | It's no secret that good analyses are often the result of very scattershot and serendipitous explorations. Tentative experiments and rapidly testing approaches that might not work out are all part of the process for getting to the good stuff, and there is no magic bullet to turn data exploration into a simple, linear progression. 12 | 13 | That being said, once started it is not a process that lends itself to thinking carefully about the structure of your code or project layout, so it's best to start with a clean, logical structure and stick to it throughout. We think it's a pretty big win all around to use a fairly standardized setup like this one. Here's why: 14 | 15 | 16 | ### Other people will thank you 17 | 18 | > Nobody sits around before creating a new Rails project to figure out where they want to put their views; they just run `rails new` to get a standard project skeleton like everybody else. 19 | 20 | A well-defined, standard project structure means that a newcomer can begin to understand an analysis without digging in to extensive documentation. It also means that they don't necessarily have to read 100% of the code before knowing where to look for very specific things. 21 | 22 | Well organized code tends to be self-documenting in that the organization itself provides context for your code without much overhead. People will thank you for this because they can: 23 | 24 | - Collaborate more easily with you on this analysis 25 | - Learn from your analysis about the process and the domain 26 | - Feel confident in the conclusions at which the analysis arrives 27 | 28 | A good example of this can be found in any of the major web development frameworks like Django or Ruby on Rails. Nobody sits around before creating a new Rails project to figure out where they want to put their views; they just run `rails new` to get a standard project skeleton like everybody else. Because that default project structure is _logical_ and _reasonably standard across most projects_, it is much easier for somebody who has never seen a particular project to figure out where they would find the various moving parts. 29 | 30 | Another great example is the [Filesystem Hierarchy Standard](https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard) for Unix-like systems. The `/etc` directory has a very specific purpose, as does the `/tmp` folder, and everybody (more or less) agrees to honor that social contract. That means a Red Hat user and an Ubuntu user both know roughly where to look for certain types of files, even when using each other's system — or any other standards-compliant system for that matter! 31 | 32 | Ideally, that's how it should be when a colleague opens up your data science project. 33 | 34 | ### You will thank you 35 | 36 | Ever tried to reproduce an analysis that you did a few months ago or even a few years ago? You may have written the code, but it's now impossible to decipher whether you should use `make_figures.py.old`, `make_figures_working.py` or `new_make_figures01.py` to get things done. Here are some questions we've learned to ask with a sense of existential dread: 37 | 38 | * Are we supposed to go in and join the column X to the data before we get started or did that come from one of the notebooks? 39 | * Come to think of it, which notebook do we have to run first before running the plotting code: was it "process data" or "clean data"? 40 | * Where did the shapefiles get downloaded from for the geographic plots? 41 | * _Et cetera, times infinity._ 42 | 43 | These types of questions are painful and are symptoms of a disorganized project. A good project structure encourages practices that make it easier to come back to old work, for example separation of concerns, abstracting analysis as a [DAG](https://en.wikipedia.org/wiki/Directed_acyclic_graph), and engineering best practices like version control. 44 | 45 | ### Nothing here is binding 46 | 47 | > "A foolish consistency is the hobgoblin of little minds" — Ralph Waldo Emerson (and [PEP 8!](https://www.python.org/dev/peps/pep-0008/#a-foolish-consistency-is-the-hobgoblin-of-little-minds)) 48 | 49 | Disagree with a couple of the default folder names? Working on a project that's a little nonstandard and doesn't exactly fit with the current structure? Prefer to use a different package than one of the (few) defaults? 50 | 51 | **Go for it!** This is a lightweight structure, and is intended to be a good _starting point_ for many projects. Or, as PEP 8 put it: 52 | 53 | > Consistency within a project is more important. Consistency within one module or function is the most important. ... However, know when to be inconsistent -- sometimes style guide recommendations just aren't applicable. When in doubt, use your best judgment. Look at other examples and decide what looks best. And don't hesitate to ask! 54 | 55 | ## Getting started 56 | 57 | With this in mind, we've created a data science cookiecutter template for projects in Python. Your analysis doesn't have to be in Python, but the template does provide some Python boilerplate that you'd want to remove (in the `src` folder for example, and the Sphinx documentation skeleton in `docs`). 58 | 59 | ### Requirements 60 | 61 | - Python 2.7 or 3.5 62 | - [cookiecutter Python package](http://cookiecutter.readthedocs.org/en/latest/installation.html) >= 1.4.0: `pip install cookiecutter` 63 | 64 | 65 | ### Starting a new project 66 | 67 | Starting a new project is as easy as running this command at the command line. No need to create a directory first, the cookiecutter will do it for you. 68 | 69 | ```nohighlight 70 | cookiecutter https://github.com/drivendata/cookiecutter-data-science 71 | ``` 72 | 73 | ### Example 74 | 75 | 76 | 77 | ## Directory structure 78 | 79 | ```nohighlight 80 | ├── LICENSE 81 | ├── Makefile <- Makefile with commands like `make data` or `make train` 82 | ├── README.md <- The top-level README for developers using this project. 83 | ├── data 84 | │   ├── external <- Data from third party sources. 85 | │   ├── interim <- Intermediate data that has been transformed. 86 | │   ├── processed <- The final, canonical data sets for modeling. 87 | │   └── raw <- The original, immutable data dump. 88 | │ 89 | ├── docs <- A default Sphinx project; see sphinx-doc.org for details 90 | │ 91 | ├── models <- Trained and serialized models, model predictions, or model summaries 92 | │ 93 | ├── notebooks <- Jupyter notebooks. Naming convention is a number (for ordering), 94 | │ the creator's initials, and a short `-` delimited description, e.g. 95 | │ `1.0-jqp-initial-data-exploration`. 96 | │ 97 | ├── references <- Data dictionaries, manuals, and all other explanatory materials. 98 | │ 99 | ├── reports <- Generated analysis as HTML, PDF, LaTeX, etc. 100 | │   └── figures <- Generated graphics and figures to be used in reporting 101 | │ 102 | ├── requirements.txt <- The requirements file for reproducing the analysis environment, e.g. 103 | │ generated with `pip freeze > requirements.txt` 104 | │ 105 | ├── setup.py <- Make this project pip installable with `pip install -e` 106 | ├── src <- Source code for use in this project. 107 | │   ├── __init__.py <- Makes src a Python module 108 | │ │ 109 | │   ├── data <- Scripts to download or generate data 110 | │   │   └── make_dataset.py 111 | │ │ 112 | │   ├── features <- Scripts to turn raw data into features for modeling 113 | │   │   └── build_features.py 114 | │ │ 115 | │   ├── models <- Scripts to train models and then use trained models to make 116 | │ │ │ predictions 117 | │   │   ├── predict_model.py 118 | │   │   └── train_model.py 119 | │ │ 120 | │   └── visualization <- Scripts to create exploratory and results oriented visualizations 121 | │   └── visualize.py 122 | │ 123 | └── tox.ini <- tox file with settings for running tox; see tox.readthedocs.io 124 | ``` 125 | 126 | ## Opinions 127 | 128 | There are some opinions implicit in the project structure that have grown out of our experience with what works and what doesn't when collaborating on data science projects. Some of the opinions are about workflows, and some of the opinions are about tools that make life easier. Here are some of the beliefs which this project is built on—if you've got thoughts, please [contribute or share them](#contributing). 129 | 130 | ### Data is immutable 131 | 132 | Don't ever edit your raw data, especially not manually, and especially not in Excel. Don't overwrite your raw data. Don't save multiple versions of the raw data. Treat the data (and its format) as immutable. The code you write should move the raw data through a pipeline to your final analysis. You shouldn't have to run all of the steps every time you want to make a new figure (see [Analysis is a DAG](#analysis-is-a-dag)), but anyone should be able to reproduce the final products with only the code in `src` and the data in `data/raw`. 133 | 134 | Also, if data is immutable, it doesn't need source control in the same way that code does. Therefore, ***by default, the data folder is included in the `.gitignore` file.*** If you have a small amount of data that rarely changes, you may want to include the data in the repository. Github currently warns if files are over 50MB and rejects files over 100MB. Some other options for storing/syncing large data include [AWS S3](https://aws.amazon.com/s3/) with a syncing tool (e.g., [`s3cmd`](http://s3tools.org/s3cmd)), [Git Large File Storage](https://git-lfs.github.com/), [Git Annex](https://git-annex.branchable.com/), and [dat](http://dat-data.com/). Currently by default, we ask for an S3 bucket and use [AWS CLI](http://docs.aws.amazon.com/cli/latest/reference/s3/index.html) to sync data in the `data` folder with the server. 135 | 136 | ### Notebooks are for exploration and communication 137 | 138 | Notebook packages like the [Jupyter notebook](http://jupyter.org/), [Beaker notebook](http://beakernotebook.com/), [Zeppelin](http://zeppelin-project.org/), and other literate programming tools are very effective for exploratory data analysis. However, these tools can be less effective for reproducing an analysis. When we use notebooks in our work, we often subdivide the `notebooks` folder. For example, `notebooks/exploratory` contains initial explorations, whereas `notebooks/reports` is more polished work that can be exported as html to the `reports` directory. 139 | 140 | Since notebooks are challenging objects for source control (e.g., diffs of the `json` are often not human-readable and merging is near impossible), we recommended not collaborating directly with others on Jupyter notebooks. There are two steps we recommend for using notebooks effectively: 141 | 142 | 1. Follow a naming convention that shows the owner and the order the analysis was done in. We use the format `--.ipynb` (e.g., `0.3-bull-visualize-distributions.ipynb`). 143 | 144 | 2. Refactor the good parts. Don't write code to do the same task in multiple notebooks. If it's a data preprocessing task, put it in the pipeline at `src/data/make_dataset.py` and load data from `data/interim`. If it's useful utility code, refactor it to `src`. 145 | 146 | Now by default we turn the project into a Python package (see the `setup.py` file). You can import your code and use it in notebooks with a cell like the following: 147 | 148 | ``` 149 | # OPTIONAL: Load the "autoreload" extension so that code can change 150 | %load_ext autoreload 151 | 152 | # OPTIONAL: always reload modules so that as you change code in src, it gets loaded 153 | %autoreload 2 154 | 155 | from src.data import make_dataset 156 | ``` 157 | 158 | ### Analysis is a directed acyclic graph ([DAG](https://en.wikipedia.org/wiki/Directed_acyclic_graph)) 159 | 160 | Often in an analysis you have long-running steps that preprocess data or train models. If these steps have been run already (and you have stored the output somewhere like the `data/interim` directory), you don't want to wait to rerun them every time. We prefer [`make`](https://www.gnu.org/software/make/) for managing steps that depend on each other, especially the long-running ones. Make is a common tool on Unix-based platforms (and [is available for Windows]()). Following the [`make` documentation](https://www.gnu.org/software/make/), [Makefile conventions](https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html#Makefile-Conventions), and [portability guide](http://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Portable-Make.html#Portable-Make) will help ensure your Makefiles work effectively across systems. Here are [some](http://zmjones.com/make/) [examples](http://blog.kaggle.com/2012/10/15/make-for-data-scientists/) to [get started](https://web.archive.org/web/20150206054212/http://www.bioinformaticszen.com/post/decomplected-workflows-makefiles/). A number of data folks use `make` as their tool of choice, including [Mike Bostock](https://bost.ocks.org/mike/make/). 161 | 162 | There are other tools for managing DAGs that are written in Python instead of a DSL (e.g., [Paver](http://paver.github.io/paver/#), [Luigi](http://luigi.readthedocs.org/en/stable/index.html), [Airflow](https://airflow.apache.org/index.html), [Snakemake](https://snakemake.readthedocs.io/en/stable/), [Ruffus](http://www.ruffus.org.uk/), or [Joblib](https://pythonhosted.org/joblib/memory.html)). Feel free to use these if they are more appropriate for your analysis. 163 | 164 | ### Build from the environment up 165 | 166 | The first step in reproducing an analysis is always reproducing the computational environment it was run in. You need the same tools, the same libraries, and the same versions to make everything play nicely together. 167 | 168 | One effective approach to this is use [virtualenv](https://virtualenv.pypa.io/en/latest/) (we recommend [virtualenvwrapper](https://virtualenvwrapper.readthedocs.org/en/latest/) for managing virtualenvs). By listing all of your requirements in the repository (we include a `requirements.txt` file) you can easily track the packages needed to recreate the analysis. Here is a good workflow: 169 | 170 | 1. Run `mkvirtualenv` when creating a new project 171 | 2. `pip install` the packages that your analysis needs 172 | 3. Run `pip freeze > requirements.txt` to pin the exact package versions used to recreate the analysis 173 | 4. If you find you need to install another package, run `pip freeze > requirements.txt` again and commit the changes to version control. 174 | 175 | If you have more complex requirements for recreating your environment, consider a virtual machine based approach such as [Docker](https://www.docker.com/) or [Vagrant](https://www.vagrantup.com/). Both of these tools use text-based formats (Dockerfile and Vagrantfile respectively) you can easily add to source control to describe how to create a virtual machine with the requirements you need. 176 | 177 | ### Keep secrets and configuration out of version control 178 | 179 | You _really_ don't want to leak your AWS secret key or Postgres username and password on Github. Enough said — see the [Twelve Factor App](http://12factor.net/config) principles on this point. Here's one way to do this: 180 | 181 | #### Store your secrets and config variables in a special file 182 | 183 | Create a `.env` file in the project root folder. Thanks to the `.gitignore`, this file should never get committed into the version control repository. Here's an example: 184 | 185 | ```nohighlight 186 | # example .env file 187 | DATABASE_URL=postgres://username:password@localhost:5432/dbname 188 | AWS_ACCESS_KEY=myaccesskey 189 | AWS_SECRET_ACCESS_KEY=mysecretkey 190 | OTHER_VARIABLE=something 191 | ``` 192 | 193 | #### Use a package to load these variables automatically. 194 | 195 | If you look at the stub script in `src/data/make_dataset.py`, it uses a package called [python-dotenv](https://github.com/theskumar/python-dotenv) to load up all the entries in this file as environment variables so they are accessible with `os.environ.get`. Here's an example snippet adapted from the `python-dotenv` documentation: 196 | 197 | ```python 198 | # src/data/dotenv_example.py 199 | import os 200 | from dotenv import load_dotenv, find_dotenv 201 | 202 | # find .env automagically by walking up directories until it's found 203 | dotenv_path = find_dotenv() 204 | 205 | # load up the entries as environment variables 206 | load_dotenv(dotenv_path) 207 | 208 | database_url = os.environ.get("DATABASE_URL") 209 | other_variable = os.environ.get("OTHER_VARIABLE") 210 | ``` 211 | 212 | #### AWS CLI configuration 213 | When using Amazon S3 to store data, a simple method of managing AWS access is to set your access keys to environment variables. However, managing mutiple sets of keys on a single machine (e.g. when working on multiple projects) it is best to use a [credentials file](https://docs.aws.amazon.com/cli/latest/userguide/cli-config-files.html), typically located in `~/.aws/credentials`. A typical file might look like: 214 | ``` 215 | [default] 216 | aws_access_key_id=myaccesskey 217 | aws_secret_access_key=mysecretkey 218 | 219 | [another_project] 220 | aws_access_key_id=myprojectaccesskey 221 | aws_secret_access_key=myprojectsecretkey 222 | ``` 223 | You can add the profile name when initialising a project; assuming no applicable environment variables are set, the profile credentials will be used by default. 224 | 225 | ### Be conservative in changing the default folder structure 226 | 227 | To keep this structure broadly applicable for many different kinds of projects, we think the best approach is to be liberal in changing the folders around for _your_ project, but be conservative in changing the default structure for _all_ projects. 228 | 229 | We've created a folder-layout label specifically for issues proposing to add, subtract, rename, or move folders around. More generally, we've also created a needs-discussion label for issues that should have some careful discussion and broad support before being implemented. 230 | 231 | ## Contributing 232 | 233 | The Cookiecutter Data Science project is opinionated, but not afraid to be wrong. Best practices change, tools evolve, and lessons are learned. **The goal of this project is to make it easier to start, structure, and share an analysis.** [Pull requests](https://github.com/drivendata/cookiecutter-data-science/pulls) and [filing issues](https://github.com/drivendata/cookiecutter-data-science/issues) is encouraged. We'd love to hear what works for you, and what doesn't. 234 | 235 | If you use the Cookiecutter Data Science project, link back to this page or [give us a holler](https://twitter.com/drivendataorg) and [let us know](mailto:info@drivendata.org)! 236 | 237 | ## Links to related projects and references 238 | 239 | Project structure and reproducibility is talked about more in the R research community. Here are some projects and blog posts if you're working in R that may help you out. 240 | 241 | - [Project Template](http://projecttemplate.net/index.html) - An R data analysis template 242 | - "[Designing projects](http://nicercode.github.io/blog/2013-04-05-projects/)" on Nice R Code 243 | - "[My research workflow](http://www.carlboettiger.info/2012/05/06/research-workflow.html)" on Carlboettiger.info 244 | - "[A Quick Guide to Organizing Computational Biology Projects](http://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1000424)" in PLOS Computational Biology 245 | 246 | Finally, a huge thanks to the [Cookiecutter](https://cookiecutter.readthedocs.org/en/latest/) project ([github](https://github.com/audreyr/cookiecutter)), which is helping us all spend less time thinking about and writing boilerplate and more time getting things done. 247 | -------------------------------------------------------------------------------- /docs/mkdocs.yml: -------------------------------------------------------------------------------- 1 | site_name: Cookiecutter Data Science 2 | site_description: A project template and directory structure for Python data science projects. 3 | site_favicon: favicon.ico 4 | repo_url: https://github.com/drivendata/cookiecutter-data-science 5 | edit_uri: edit/master/docs/docs 6 | copyright: Project maintained by the friendly folks at DrivenData. 7 | google_analytics: ['UA-54096005-4', 'auto'] 8 | theme: cinder 9 | extra_css: 10 | - css/extra.css 11 | pages: 12 | - Home: index.md 13 | -------------------------------------------------------------------------------- /hooks/pre_gen_project.py: -------------------------------------------------------------------------------- 1 | def deprecation_warning(): 2 | print(""" 3 | 4 | ============================================================================= 5 | *** DEPRECATION WARNING *** 6 | 7 | Cookiecutter data science is moving to v2 soon, which will entail using 8 | the command `ccds ...` rather than `cookiecutter ...`. The cookiecutter command 9 | will continue to work, and this version of the template will still be available. 10 | To use the legacy template, you will need to explicitly use `-c v1` to select it. 11 | 12 | Please update any scripts/automation you have to append the `-c v1` option, 13 | which is available now. 14 | 15 | For example: 16 | cookiecutter -c v1 https://github.com/drivendata/cookiecutter-data-science 17 | ============================================================================= 18 | 19 | """) 20 | 21 | 22 | deprecation_warning() 23 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | mkdocs 2 | mkdocs-cinder 3 | cookiecutter 4 | pytest 5 | -------------------------------------------------------------------------------- /tests/conftest.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import pytest 3 | import shutil 4 | from pathlib import Path 5 | from cookiecutter import main 6 | 7 | CCDS_ROOT = Path(__file__).parents[1].resolve() 8 | 9 | args = { 10 | 'project_name': 'DrivenData', 11 | 'author_name': 'DrivenData', 12 | 'open_source_license': 'BSD-3-Clause', 13 | 'python_interpreter': 'python' 14 | } 15 | 16 | 17 | def system_check(basename): 18 | platform = sys.platform 19 | if 'linux' in platform: 20 | basename = basename.lower() 21 | return basename 22 | 23 | 24 | @pytest.fixture(scope='class', params=[{}, args]) 25 | def default_baked_project(tmpdir_factory, request): 26 | temp = tmpdir_factory.mktemp('data-project') 27 | out_dir = Path(temp).resolve() 28 | 29 | pytest.param = request.param 30 | main.cookiecutter( 31 | str(CCDS_ROOT), 32 | no_input=True, 33 | extra_context=pytest.param, 34 | output_dir=out_dir 35 | ) 36 | 37 | pn = pytest.param.get('project_name') or 'project_name' 38 | 39 | # project name gets converted to lower case on Linux but not Mac 40 | pn = system_check(pn) 41 | 42 | proj = out_dir / pn 43 | request.cls.path = proj 44 | yield 45 | 46 | # cleanup after 47 | shutil.rmtree(out_dir) 48 | 49 | -------------------------------------------------------------------------------- /tests/test_creation.py: -------------------------------------------------------------------------------- 1 | import os 2 | import pytest 3 | from subprocess import check_output 4 | from conftest import system_check 5 | 6 | 7 | def no_curlies(filepath): 8 | """ Utility to make sure no curly braces appear in a file. 9 | That is, was Jinja able to render everything? 10 | """ 11 | with open(filepath, 'r') as f: 12 | data = f.read() 13 | 14 | template_strings = [ 15 | '{{', 16 | '}}', 17 | '{%', 18 | '%}' 19 | ] 20 | 21 | template_strings_in_file = [s in data for s in template_strings] 22 | return not any(template_strings_in_file) 23 | 24 | 25 | @pytest.mark.usefixtures("default_baked_project") 26 | class TestCookieSetup(object): 27 | def test_project_name(self): 28 | project = self.path 29 | if pytest.param.get('project_name'): 30 | name = system_check('DrivenData') 31 | assert project.name == name 32 | else: 33 | assert project.name == 'project_name' 34 | 35 | def test_author(self): 36 | setup_ = self.path / 'setup.py' 37 | args = ['python', str(setup_), '--author'] 38 | p = check_output(args).decode('ascii').strip() 39 | if pytest.param.get('author_name'): 40 | assert p == 'DrivenData' 41 | else: 42 | assert p == 'Your name (or your organization/company/team)' 43 | 44 | def test_readme(self): 45 | readme_path = self.path / 'README.md' 46 | assert readme_path.exists() 47 | assert no_curlies(readme_path) 48 | if pytest.param.get('project_name'): 49 | with open(readme_path) as fin: 50 | assert 'DrivenData' == next(fin).strip() 51 | 52 | def test_setup(self): 53 | setup_ = self.path / 'setup.py' 54 | args = ['python', str(setup_), '--version'] 55 | p = check_output(args).decode('ascii').strip() 56 | assert p == '0.1.0' 57 | 58 | def test_license(self): 59 | license_path = self.path / 'LICENSE' 60 | assert license_path.exists() 61 | assert no_curlies(license_path) 62 | 63 | def test_license_type(self): 64 | setup_ = self.path / 'setup.py' 65 | args = ['python', str(setup_), '--license'] 66 | p = check_output(args).decode('ascii').strip() 67 | if pytest.param.get('open_source_license'): 68 | assert p == 'BSD-3' 69 | else: 70 | assert p == 'MIT' 71 | 72 | def test_requirements(self): 73 | reqs_path = self.path / 'requirements.txt' 74 | assert reqs_path.exists() 75 | assert no_curlies(reqs_path) 76 | if pytest.param.get('python_interpreter'): 77 | with open(reqs_path) as fin: 78 | lines = list(map(lambda x: x.strip(), fin.readlines())) 79 | assert 'pathlib2' in lines 80 | 81 | def test_makefile(self): 82 | makefile_path = self.path / 'Makefile' 83 | assert makefile_path.exists() 84 | assert no_curlies(makefile_path) 85 | 86 | def test_folders(self): 87 | expected_dirs = [ 88 | 'data', 89 | 'data/external', 90 | 'data/interim', 91 | 'data/processed', 92 | 'data/raw', 93 | 'docs', 94 | 'models', 95 | 'notebooks', 96 | 'references', 97 | 'reports', 98 | 'reports/figures', 99 | 'src', 100 | 'src/data', 101 | 'src/features', 102 | 'src/models', 103 | 'src/visualization', 104 | ] 105 | 106 | ignored_dirs = [ 107 | str(self.path) 108 | ] 109 | 110 | abs_expected_dirs = [str(self.path / d) for d in expected_dirs] 111 | abs_dirs, _, _ = list(zip(*os.walk(self.path))) 112 | assert len(set(abs_expected_dirs + ignored_dirs) - set(abs_dirs)) == 0 113 | 114 | -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/.env: -------------------------------------------------------------------------------- 1 | # Environment variables go here, can be read by `python-dotenv` package: 2 | # 3 | # `src/script.py` 4 | # ---------------------------------------------------------------- 5 | # import dotenv 6 | # 7 | # project_dir = os.path.join(os.path.dirname(__file__), os.pardir) 8 | # dotenv_path = os.path.join(project_dir, '.env') 9 | # dotenv.load_dotenv(dotenv_path) 10 | # ---------------------------------------------------------------- 11 | # 12 | # DO NOT ADD THIS FILE TO VERSION CONTROL! 13 | -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | 5 | # C extensions 6 | *.so 7 | 8 | # Distribution / packaging 9 | .Python 10 | env/ 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | *.egg-info/ 23 | .installed.cfg 24 | *.egg 25 | 26 | # PyInstaller 27 | # Usually these files are written by a python script from a template 28 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 29 | *.manifest 30 | *.spec 31 | 32 | # Installer logs 33 | pip-log.txt 34 | pip-delete-this-directory.txt 35 | 36 | # Unit test / coverage reports 37 | htmlcov/ 38 | .tox/ 39 | .coverage 40 | .coverage.* 41 | .cache 42 | nosetests.xml 43 | coverage.xml 44 | *.cover 45 | 46 | # Translations 47 | *.mo 48 | *.pot 49 | 50 | # Django stuff: 51 | *.log 52 | 53 | # Sphinx documentation 54 | docs/_build/ 55 | 56 | # PyBuilder 57 | target/ 58 | 59 | # DotEnv configuration 60 | .env 61 | 62 | # Database 63 | *.db 64 | *.rdb 65 | 66 | # Pycharm 67 | .idea 68 | 69 | # VS Code 70 | .vscode/ 71 | 72 | # Spyder 73 | .spyproject/ 74 | 75 | # Jupyter NB Checkpoints 76 | .ipynb_checkpoints/ 77 | 78 | # exclude data from source control by default 79 | /data/ 80 | 81 | # Mac OS-specific storage files 82 | .DS_Store 83 | 84 | # vim 85 | *.swp 86 | *.swo 87 | 88 | # Mypy cache 89 | .mypy_cache/ 90 | -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/LICENSE: -------------------------------------------------------------------------------- 1 | {% if cookiecutter.open_source_license == 'MIT' %} 2 | The MIT License (MIT) 3 | Copyright (c) {% now 'utc', '%Y' %}, {{ cookiecutter.author_name }} 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | {% elif cookiecutter.open_source_license == 'BSD-3-Clause' %} 11 | Copyright (c) {% now 'utc', '%Y' %}, {{ cookiecutter.author_name }} 12 | All rights reserved. 13 | 14 | Redistribution and use in source and binary forms, with or without modification, 15 | are permitted provided that the following conditions are met: 16 | 17 | * Redistributions of source code must retain the above copyright notice, this 18 | list of conditions and the following disclaimer. 19 | 20 | * Redistributions in binary form must reproduce the above copyright notice, this 21 | list of conditions and the following disclaimer in the documentation and/or 22 | other materials provided with the distribution. 23 | 24 | * Neither the name of {{ cookiecutter.project_name }} nor the names of its 25 | contributors may be used to endorse or promote products derived from this 26 | software without specific prior written permission. 27 | 28 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 29 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 30 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 31 | IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 32 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 33 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 34 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 35 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 36 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 37 | OF THE POSSIBILITY OF SUCH DAMAGE. 38 | {% endif %} 39 | -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean data lint requirements sync_data_to_s3 sync_data_from_s3 initialize_version_control 2 | 3 | ################################################################################# 4 | # GLOBALS # 5 | ################################################################################# 6 | 7 | PROJECT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) 8 | BUCKET = {{ cookiecutter.s3_bucket }} 9 | PROFILE = {{ cookiecutter.aws_profile }} 10 | PROJECT_NAME = {{ cookiecutter.repo_name }} 11 | PYTHON_INTERPRETER = {{ cookiecutter.python_interpreter }} 12 | 13 | ifeq (,$(shell which conda)) 14 | HAS_CONDA=False 15 | else 16 | HAS_CONDA=True 17 | endif 18 | 19 | ################################################################################# 20 | # COMMANDS # 21 | ################################################################################# 22 | 23 | ## Install Python Dependencies 24 | requirements: test_environment 25 | $(PYTHON_INTERPRETER) -m pip install -U pip setuptools wheel 26 | $(PYTHON_INTERPRETER) -m pip install -r requirements.txt 27 | 28 | {% if cookiecutter.use_data_version_control == 'y' %} 29 | .dvc: requirements 30 | git init 31 | dvc init 32 | dvc config cache.type reflink,copy 33 | dvc remote add -d origin s3://$(BUCKET)/data 34 | ifneq (default,$(PROFILE)) 35 | dvc remote modify origin profile $(PROFILE) 36 | endif 37 | dvc add data 38 | dvc push 39 | git add data.dvc 40 | git commit -m 'Initialize data version control' 41 | 42 | ## Inititalize git + dvc if data version conrol is used 43 | initialize_version_control: .dvc 44 | {% else %} 45 | initialize_version_control: requirements 46 | @echo ">>> Data version control setup is skipped for this project" 47 | {% endif %} 48 | 49 | ## Make Dataset 50 | data: initialize_version_control 51 | $(PYTHON_INTERPRETER) src/data/make_dataset.py data/raw data/processed 52 | 53 | ## Delete all compiled Python files 54 | clean: 55 | find . -type f -name "*.py[co]" -delete 56 | find . -type d -name "__pycache__" -delete 57 | 58 | ## Lint using flake8 59 | lint: 60 | flake8 src 61 | 62 | ## Upload Data to S3 63 | sync_data_to_s3: 64 | {% if cookiecutter.use_data_version_control == 'y' %} 65 | dvc add data 66 | dvc push data.dvc 67 | git commit data.dvc -m "Save data directory" 68 | {% else %} 69 | ifeq (default,$(PROFILE)) 70 | aws s3 sync data/ s3://$(BUCKET)/data/ 71 | else 72 | aws s3 sync data/ s3://$(BUCKET)/data/ --profile $(PROFILE) 73 | endif 74 | {% endif %} 75 | 76 | ## Download Data from S3 77 | sync_data_from_s3: 78 | {% if cookiecutter.use_data_version_control == 'y' %} 79 | dvc pull data.dvc 80 | {% else %} 81 | ifeq (default,$(PROFILE)) 82 | aws s3 sync s3://$(BUCKET)/data/ data/ 83 | else 84 | aws s3 sync s3://$(BUCKET)/data/ data/ --profile $(PROFILE) 85 | endif 86 | {% endif %} 87 | 88 | ## Set up python interpreter environment 89 | create_environment: 90 | ifeq (True,$(HAS_CONDA)) 91 | @echo ">>> Detected conda, creating conda environment." 92 | ifeq (3,$(findstring 3,$(PYTHON_INTERPRETER))) 93 | conda create --name $(PROJECT_NAME) python=3 94 | else 95 | conda create --name $(PROJECT_NAME) python=2.7 96 | endif 97 | @echo ">>> New conda env created. Activate with:\nsource activate $(PROJECT_NAME)" 98 | else 99 | $(PYTHON_INTERPRETER) -m pip install -q virtualenv virtualenvwrapper 100 | @echo ">>> Installing virtualenvwrapper if not already installed.\nMake sure the following lines are in shell startup file\n\ 101 | export WORKON_HOME=$$HOME/.virtualenvs\nexport PROJECT_HOME=$$HOME/Devel\nsource /usr/local/bin/virtualenvwrapper.sh\n" 102 | @bash -c "source `which virtualenvwrapper.sh`;mkvirtualenv $(PROJECT_NAME) --python=$(PYTHON_INTERPRETER)" 103 | @echo ">>> New virtualenv created. Activate with:\nworkon $(PROJECT_NAME)" 104 | endif 105 | 106 | ## Test python environment is setup correctly 107 | test_environment: 108 | $(PYTHON_INTERPRETER) test_environment.py 109 | 110 | ################################################################################# 111 | # PROJECT RULES # 112 | ################################################################################# 113 | 114 | 115 | 116 | ################################################################################# 117 | # Self Documenting Commands # 118 | ################################################################################# 119 | 120 | .DEFAULT_GOAL := help 121 | 122 | # Inspired by 123 | # sed script explained: 124 | # /^##/: 125 | # * save line in hold space 126 | # * purge line 127 | # * Loop: 128 | # * append newline + line to hold space 129 | # * go to next line 130 | # * if line starts with doc comment, strip comment character off and loop 131 | # * remove target prerequisites 132 | # A 133 | # * append hold space (+ newline) to line 134 | # * replace newline plus comments by `---` 135 | # * print line 136 | # Separate expressions are necessary because labels cannot be delimited by 137 | # semicolon; see 138 | .PHONY: help 139 | help: 140 | @echo "$$(tput bold)Available rules:$$(tput sgr0)" 141 | @echo 142 | @sed -n -e "/^## / { \ 143 | h; \ 144 | s/.*//; \ 145 | :doc" \ 146 | -e "H; \ 147 | n; \ 148 | s/^## //; \ 149 | t doc" \ 150 | -e "s/:.*//; \ 151 | G; \ 152 | s/\\n## /---/; \ 153 | s/\\n/ /g; \ 154 | p; \ 155 | }" ${MAKEFILE_LIST} \ 156 | | LC_ALL='C' sort --ignore-case \ 157 | | awk -F '---' \ 158 | -v ncol=$$(tput cols) \ 159 | -v indent=26 \ 160 | -v col_on="$$(tput setaf 6)" \ 161 | -v col_off="$$(tput sgr0)" \ 162 | '{ \ 163 | printf "%s%*s%s ", col_on, -indent, $$1, col_off; \ 164 | n = split($$2, words, " "); \ 165 | line_length = ncol - indent; \ 166 | for (i = 1; i <= n; i++) { \ 167 | line_length -= length(words[i]) + 1; \ 168 | if (line_length <= 0) { \ 169 | line_length = ncol - indent - length(words[i]) - 1; \ 170 | printf "\n%*s ", -indent, " "; \ 171 | } \ 172 | printf "%s ", words[i]; \ 173 | } \ 174 | printf "\n"; \ 175 | }' \ 176 | | more $(shell test $(shell uname) = Darwin && echo '--no-init --raw-control-chars') 177 | -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/README.md: -------------------------------------------------------------------------------- 1 | {{cookiecutter.project_name}} 2 | ============================== 3 | 4 | {{cookiecutter.description}} 5 | 6 | Project Organization 7 | ------------ 8 | 9 | ├── LICENSE 10 | ├── Makefile <- Makefile with commands like `make data` or `make train` 11 | ├── README.md <- The top-level README for developers using this project. 12 | ├── data 13 | │   ├── external <- Data from third party sources. 14 | │   ├── interim <- Intermediate data that has been transformed. 15 | │   ├── processed <- The final, canonical data sets for modeling. 16 | │   └── raw <- The original, immutable data dump.{% if cookiecutter.use_data_version_control == 'y' %} 17 | │ 18 | ├── data.dvc <- Data version control file; see dvc.org for details 19 | │{% endif %} 20 | ├── docs <- A default Sphinx project; see sphinx-doc.org for details 21 | │ 22 | ├── models <- Trained and serialized models, model predictions, or model summaries 23 | │ 24 | ├── notebooks <- Jupyter notebooks. Naming convention is a number (for ordering), 25 | │ the creator's initials, and a short `-` delimited description, e.g. 26 | │ `1.0-jqp-initial-data-exploration`. 27 | │ 28 | ├── references <- Data dictionaries, manuals, and all other explanatory materials. 29 | │ 30 | ├── reports <- Generated analysis as HTML, PDF, LaTeX, etc. 31 | │   └── figures <- Generated graphics and figures to be used in reporting 32 | │ 33 | ├── requirements.txt <- The requirements file for reproducing the analysis environment, e.g. 34 | │ generated with `pip freeze > requirements.txt` 35 | │ 36 | ├── setup.py <- makes project pip installable (pip install -e .) so src can be imported 37 | ├── src <- Source code for use in this project. 38 | │   ├── __init__.py <- Makes src a Python module 39 | │ │ 40 | │   ├── data <- Scripts to download or generate data 41 | │   │   └── make_dataset.py 42 | │ │ 43 | │   ├── features <- Scripts to turn raw data into features for modeling 44 | │   │   └── build_features.py 45 | │ │ 46 | │   ├── models <- Scripts to train models and then use trained models to make 47 | │ │ │ predictions 48 | │   │   ├── predict_model.py 49 | │   │   └── train_model.py 50 | │ │ 51 | │   └── visualization <- Scripts to create exploratory and results oriented visualizations 52 | │   └── visualize.py 53 | │ 54 | └── tox.ini <- tox file with settings for running tox; see tox.readthedocs.io 55 | 56 | 57 | -------- 58 | 59 |

Project based on the cookiecutter data science project template. #cookiecutterdatascience

60 | -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/data/external/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iterative/cookiecutter-data-science/b987fdc5f55ab7fc80b63a1f88c5ed98917e463c/{{ cookiecutter.repo_name }}/data/external/.gitkeep -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/data/interim/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iterative/cookiecutter-data-science/b987fdc5f55ab7fc80b63a1f88c5ed98917e463c/{{ cookiecutter.repo_name }}/data/interim/.gitkeep -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/data/processed/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iterative/cookiecutter-data-science/b987fdc5f55ab7fc80b63a1f88c5ed98917e463c/{{ cookiecutter.repo_name }}/data/processed/.gitkeep -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/data/raw/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iterative/cookiecutter-data-science/b987fdc5f55ab7fc80b63a1f88c5ed98917e463c/{{ cookiecutter.repo_name }}/data/raw/.gitkeep -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/docs/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = _build 9 | 10 | # Internal variables. 11 | PAPEROPT_a4 = -D latex_paper_size=a4 12 | PAPEROPT_letter = -D latex_paper_size=letter 13 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 14 | # the i18n builder cannot share the environment and doctrees with the others 15 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 16 | 17 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext 18 | 19 | help: 20 | @echo "Please use \`make ' where is one of" 21 | @echo " html to make standalone HTML files" 22 | @echo " dirhtml to make HTML files named index.html in directories" 23 | @echo " singlehtml to make a single large HTML file" 24 | @echo " pickle to make pickle files" 25 | @echo " json to make JSON files" 26 | @echo " htmlhelp to make HTML files and a HTML help project" 27 | @echo " qthelp to make HTML files and a qthelp project" 28 | @echo " devhelp to make HTML files and a Devhelp project" 29 | @echo " epub to make an epub" 30 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 31 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 32 | @echo " text to make text files" 33 | @echo " man to make manual pages" 34 | @echo " texinfo to make Texinfo files" 35 | @echo " info to make Texinfo files and run them through makeinfo" 36 | @echo " gettext to make PO message catalogs" 37 | @echo " changes to make an overview of all changed/added/deprecated items" 38 | @echo " linkcheck to check all external links for integrity" 39 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 40 | 41 | clean: 42 | -rm -rf $(BUILDDIR)/* 43 | 44 | html: 45 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 46 | @echo 47 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 48 | 49 | dirhtml: 50 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 51 | @echo 52 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 53 | 54 | singlehtml: 55 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 56 | @echo 57 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 58 | 59 | pickle: 60 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 61 | @echo 62 | @echo "Build finished; now you can process the pickle files." 63 | 64 | json: 65 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 66 | @echo 67 | @echo "Build finished; now you can process the JSON files." 68 | 69 | htmlhelp: 70 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 71 | @echo 72 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 73 | ".hhp project file in $(BUILDDIR)/htmlhelp." 74 | 75 | qthelp: 76 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 77 | @echo 78 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 79 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 80 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/{{ cookiecutter.repo_name }}.qhcp" 81 | @echo "To view the help file:" 82 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/{{ cookiecutter.repo_name }}.qhc" 83 | 84 | devhelp: 85 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 86 | @echo 87 | @echo "Build finished." 88 | @echo "To view the help file:" 89 | @echo "# mkdir -p $$HOME/.local/share/devhelp/{{ cookiecutter.repo_name }}" 90 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/{{ cookiecutter.repo_name }}" 91 | @echo "# devhelp" 92 | 93 | epub: 94 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 95 | @echo 96 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 97 | 98 | latex: 99 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 100 | @echo 101 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 102 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 103 | "(use \`make latexpdf' here to do that automatically)." 104 | 105 | latexpdf: 106 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 107 | @echo "Running LaTeX files through pdflatex..." 108 | $(MAKE) -C $(BUILDDIR)/latex all-pdf 109 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 110 | 111 | text: 112 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 113 | @echo 114 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 115 | 116 | man: 117 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 118 | @echo 119 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 120 | 121 | texinfo: 122 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 123 | @echo 124 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." 125 | @echo "Run \`make' in that directory to run these through makeinfo" \ 126 | "(use \`make info' here to do that automatically)." 127 | 128 | info: 129 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 130 | @echo "Running Texinfo files through makeinfo..." 131 | make -C $(BUILDDIR)/texinfo info 132 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." 133 | 134 | gettext: 135 | $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale 136 | @echo 137 | @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." 138 | 139 | changes: 140 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 141 | @echo 142 | @echo "The overview file is in $(BUILDDIR)/changes." 143 | 144 | linkcheck: 145 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 146 | @echo 147 | @echo "Link check complete; look for any errors in the above output " \ 148 | "or in $(BUILDDIR)/linkcheck/output.txt." 149 | 150 | doctest: 151 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 152 | @echo "Testing of doctests in the sources finished, look at the " \ 153 | "results in $(BUILDDIR)/doctest/output.txt." 154 | -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/docs/commands.rst: -------------------------------------------------------------------------------- 1 | Commands 2 | ======== 3 | 4 | The Makefile contains the central entry points for common tasks related to this project. 5 | 6 | Syncing data to S3 7 | ^^^^^^^^^^^^^^^^^^ 8 | 9 | * `make sync_data_to_s3` will use `aws s3 sync` to recursively sync files in `data/` up to `s3://{{ cookiecutter.s3_bucket }}/data/`. 10 | * `make sync_data_from_s3` will use `aws s3 sync` to recursively sync files from `s3://{{ cookiecutter.s3_bucket }}/data/` to `data/`. 11 | -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/docs/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # {{ cookiecutter.project_name }} documentation build configuration file, created by 4 | # sphinx-quickstart. 5 | # 6 | # This file is execfile()d with the current directory set to its containing dir. 7 | # 8 | # Note that not all possible configuration values are present in this 9 | # autogenerated file. 10 | # 11 | # All configuration values have a default; values that are commented out 12 | # serve to show the default. 13 | 14 | import os 15 | import sys 16 | 17 | # If extensions (or modules to document with autodoc) are in another directory, 18 | # add these directories to sys.path here. If the directory is relative to the 19 | # documentation root, use os.path.abspath to make it absolute, like shown here. 20 | # sys.path.insert(0, os.path.abspath('.')) 21 | 22 | # -- General configuration ----------------------------------------------------- 23 | 24 | # If your documentation needs a minimal Sphinx version, state it here. 25 | # needs_sphinx = '1.0' 26 | 27 | # Add any Sphinx extension module names here, as strings. They can be extensions 28 | # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 29 | extensions = [] 30 | 31 | # Add any paths that contain templates here, relative to this directory. 32 | templates_path = ['_templates'] 33 | 34 | # The suffix of source filenames. 35 | source_suffix = '.rst' 36 | 37 | # The encoding of source files. 38 | # source_encoding = 'utf-8-sig' 39 | 40 | # The master toctree document. 41 | master_doc = 'index' 42 | 43 | # General information about the project. 44 | project = u'{{ cookiecutter.project_name }}' 45 | 46 | # The version info for the project you're documenting, acts as replacement for 47 | # |version| and |release|, also used in various other places throughout the 48 | # built documents. 49 | # 50 | # The short X.Y version. 51 | version = '0.1' 52 | # The full version, including alpha/beta/rc tags. 53 | release = '0.1' 54 | 55 | # The language for content autogenerated by Sphinx. Refer to documentation 56 | # for a list of supported languages. 57 | # language = None 58 | 59 | # There are two options for replacing |today|: either, you set today to some 60 | # non-false value, then it is used: 61 | # today = '' 62 | # Else, today_fmt is used as the format for a strftime call. 63 | # today_fmt = '%B %d, %Y' 64 | 65 | # List of patterns, relative to source directory, that match files and 66 | # directories to ignore when looking for source files. 67 | exclude_patterns = ['_build'] 68 | 69 | # The reST default role (used for this markup: `text`) to use for all documents. 70 | # default_role = None 71 | 72 | # If true, '()' will be appended to :func: etc. cross-reference text. 73 | # add_function_parentheses = True 74 | 75 | # If true, the current module name will be prepended to all description 76 | # unit titles (such as .. function::). 77 | # add_module_names = True 78 | 79 | # If true, sectionauthor and moduleauthor directives will be shown in the 80 | # output. They are ignored by default. 81 | # show_authors = False 82 | 83 | # The name of the Pygments (syntax highlighting) style to use. 84 | pygments_style = 'sphinx' 85 | 86 | # A list of ignored prefixes for module index sorting. 87 | # modindex_common_prefix = [] 88 | 89 | 90 | # -- Options for HTML output --------------------------------------------------- 91 | 92 | # The theme to use for HTML and HTML Help pages. See the documentation for 93 | # a list of builtin themes. 94 | html_theme = 'default' 95 | 96 | # Theme options are theme-specific and customize the look and feel of a theme 97 | # further. For a list of options available for each theme, see the 98 | # documentation. 99 | # html_theme_options = {} 100 | 101 | # Add any paths that contain custom themes here, relative to this directory. 102 | # html_theme_path = [] 103 | 104 | # The name for this set of Sphinx documents. If None, it defaults to 105 | # " v documentation". 106 | # html_title = None 107 | 108 | # A shorter title for the navigation bar. Default is the same as html_title. 109 | # html_short_title = None 110 | 111 | # The name of an image file (relative to this directory) to place at the top 112 | # of the sidebar. 113 | # html_logo = None 114 | 115 | # The name of an image file (within the static path) to use as favicon of the 116 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 117 | # pixels large. 118 | # html_favicon = None 119 | 120 | # Add any paths that contain custom static files (such as style sheets) here, 121 | # relative to this directory. They are copied after the builtin static files, 122 | # so a file named "default.css" will overwrite the builtin "default.css". 123 | html_static_path = ['_static'] 124 | 125 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 126 | # using the given strftime format. 127 | # html_last_updated_fmt = '%b %d, %Y' 128 | 129 | # If true, SmartyPants will be used to convert quotes and dashes to 130 | # typographically correct entities. 131 | # html_use_smartypants = True 132 | 133 | # Custom sidebar templates, maps document names to template names. 134 | # html_sidebars = {} 135 | 136 | # Additional templates that should be rendered to pages, maps page names to 137 | # template names. 138 | # html_additional_pages = {} 139 | 140 | # If false, no module index is generated. 141 | # html_domain_indices = True 142 | 143 | # If false, no index is generated. 144 | # html_use_index = True 145 | 146 | # If true, the index is split into individual pages for each letter. 147 | # html_split_index = False 148 | 149 | # If true, links to the reST sources are added to the pages. 150 | # html_show_sourcelink = True 151 | 152 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 153 | # html_show_sphinx = True 154 | 155 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 156 | # html_show_copyright = True 157 | 158 | # If true, an OpenSearch description file will be output, and all pages will 159 | # contain a tag referring to it. The value of this option must be the 160 | # base URL from which the finished HTML is served. 161 | # html_use_opensearch = '' 162 | 163 | # This is the file name suffix for HTML files (e.g. ".xhtml"). 164 | # html_file_suffix = None 165 | 166 | # Output file base name for HTML help builder. 167 | htmlhelp_basename = '{{ cookiecutter.repo_name }}doc' 168 | 169 | 170 | # -- Options for LaTeX output -------------------------------------------------- 171 | 172 | latex_elements = { 173 | # The paper size ('letterpaper' or 'a4paper'). 174 | # 'papersize': 'letterpaper', 175 | 176 | # The font size ('10pt', '11pt' or '12pt'). 177 | # 'pointsize': '10pt', 178 | 179 | # Additional stuff for the LaTeX preamble. 180 | # 'preamble': '', 181 | } 182 | 183 | # Grouping the document tree into LaTeX files. List of tuples 184 | # (source start file, target name, title, author, documentclass [howto/manual]). 185 | latex_documents = [ 186 | ('index', 187 | '{{ cookiecutter.repo_name }}.tex', 188 | u'{{ cookiecutter.project_name }} Documentation', 189 | u"{{ cookiecutter.author_name }}", 'manual'), 190 | ] 191 | 192 | # The name of an image file (relative to this directory) to place at the top of 193 | # the title page. 194 | # latex_logo = None 195 | 196 | # For "manual" documents, if this is true, then toplevel headings are parts, 197 | # not chapters. 198 | # latex_use_parts = False 199 | 200 | # If true, show page references after internal links. 201 | # latex_show_pagerefs = False 202 | 203 | # If true, show URL addresses after external links. 204 | # latex_show_urls = False 205 | 206 | # Documents to append as an appendix to all manuals. 207 | # latex_appendices = [] 208 | 209 | # If false, no module index is generated. 210 | # latex_domain_indices = True 211 | 212 | 213 | # -- Options for manual page output -------------------------------------------- 214 | 215 | # One entry per manual page. List of tuples 216 | # (source start file, name, description, authors, manual section). 217 | man_pages = [ 218 | ('index', '{{ cookiecutter.repo_name }}', u'{{ cookiecutter.project_name }} Documentation', 219 | [u"{{ cookiecutter.author_name }}"], 1) 220 | ] 221 | 222 | # If true, show URL addresses after external links. 223 | # man_show_urls = False 224 | 225 | 226 | # -- Options for Texinfo output ------------------------------------------------ 227 | 228 | # Grouping the document tree into Texinfo files. List of tuples 229 | # (source start file, target name, title, author, 230 | # dir menu entry, description, category) 231 | texinfo_documents = [ 232 | ('index', '{{ cookiecutter.repo_name }}', u'{{ cookiecutter.project_name }} Documentation', 233 | u"{{ cookiecutter.author_name }}", '{{ cookiecutter.project_name }}', 234 | '{{ cookiecutter.description }}', 'Miscellaneous'), 235 | ] 236 | 237 | # Documents to append as an appendix to all manuals. 238 | # texinfo_appendices = [] 239 | 240 | # If false, no module index is generated. 241 | # texinfo_domain_indices = True 242 | 243 | # How to display URL addresses: 'footnote', 'no', or 'inline'. 244 | # texinfo_show_urls = 'footnote' 245 | -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/docs/getting-started.rst: -------------------------------------------------------------------------------- 1 | Getting started 2 | =============== 3 | 4 | This is where you describe how to get set up on a clean install, including the 5 | commands necessary to get the raw data (using the `sync_data_from_s3` command, 6 | for example), and then how to make the cleaned, final data sets. 7 | -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/docs/index.rst: -------------------------------------------------------------------------------- 1 | .. {{ cookiecutter.project_name }} documentation master file, created by 2 | sphinx-quickstart. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | {{ cookiecutter.project_name }} documentation! 7 | ============================================== 8 | 9 | Contents: 10 | 11 | .. toctree:: 12 | :maxdepth: 2 13 | 14 | getting-started 15 | commands 16 | 17 | 18 | 19 | Indices and tables 20 | ================== 21 | 22 | * :ref:`genindex` 23 | * :ref:`modindex` 24 | * :ref:`search` 25 | -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | if "%SPHINXBUILD%" == "" ( 6 | set SPHINXBUILD=sphinx-build 7 | ) 8 | set BUILDDIR=_build 9 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . 10 | set I18NSPHINXOPTS=%SPHINXOPTS% . 11 | if NOT "%PAPER%" == "" ( 12 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 13 | set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% 14 | ) 15 | 16 | if "%1" == "" goto help 17 | 18 | if "%1" == "help" ( 19 | :help 20 | echo.Please use `make ^` where ^ is one of 21 | echo. html to make standalone HTML files 22 | echo. dirhtml to make HTML files named index.html in directories 23 | echo. singlehtml to make a single large HTML file 24 | echo. pickle to make pickle files 25 | echo. json to make JSON files 26 | echo. htmlhelp to make HTML files and a HTML help project 27 | echo. qthelp to make HTML files and a qthelp project 28 | echo. devhelp to make HTML files and a Devhelp project 29 | echo. epub to make an epub 30 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 31 | echo. text to make text files 32 | echo. man to make manual pages 33 | echo. texinfo to make Texinfo files 34 | echo. gettext to make PO message catalogs 35 | echo. changes to make an overview over all changed/added/deprecated items 36 | echo. linkcheck to check all external links for integrity 37 | echo. doctest to run all doctests embedded in the documentation if enabled 38 | goto end 39 | ) 40 | 41 | if "%1" == "clean" ( 42 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 43 | del /q /s %BUILDDIR%\* 44 | goto end 45 | ) 46 | 47 | if "%1" == "html" ( 48 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 49 | if errorlevel 1 exit /b 1 50 | echo. 51 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 52 | goto end 53 | ) 54 | 55 | if "%1" == "dirhtml" ( 56 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 57 | if errorlevel 1 exit /b 1 58 | echo. 59 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 60 | goto end 61 | ) 62 | 63 | if "%1" == "singlehtml" ( 64 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml 65 | if errorlevel 1 exit /b 1 66 | echo. 67 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. 68 | goto end 69 | ) 70 | 71 | if "%1" == "pickle" ( 72 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 73 | if errorlevel 1 exit /b 1 74 | echo. 75 | echo.Build finished; now you can process the pickle files. 76 | goto end 77 | ) 78 | 79 | if "%1" == "json" ( 80 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 81 | if errorlevel 1 exit /b 1 82 | echo. 83 | echo.Build finished; now you can process the JSON files. 84 | goto end 85 | ) 86 | 87 | if "%1" == "htmlhelp" ( 88 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 89 | if errorlevel 1 exit /b 1 90 | echo. 91 | echo.Build finished; now you can run HTML Help Workshop with the ^ 92 | .hhp project file in %BUILDDIR%/htmlhelp. 93 | goto end 94 | ) 95 | 96 | if "%1" == "qthelp" ( 97 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 98 | if errorlevel 1 exit /b 1 99 | echo. 100 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 101 | .qhcp project file in %BUILDDIR%/qthelp, like this: 102 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\{{ cookiecutter.repo_name }}.qhcp 103 | echo.To view the help file: 104 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\{{ cookiecutter.repo_name }}.ghc 105 | goto end 106 | ) 107 | 108 | if "%1" == "devhelp" ( 109 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp 110 | if errorlevel 1 exit /b 1 111 | echo. 112 | echo.Build finished. 113 | goto end 114 | ) 115 | 116 | if "%1" == "epub" ( 117 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub 118 | if errorlevel 1 exit /b 1 119 | echo. 120 | echo.Build finished. The epub file is in %BUILDDIR%/epub. 121 | goto end 122 | ) 123 | 124 | if "%1" == "latex" ( 125 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 126 | if errorlevel 1 exit /b 1 127 | echo. 128 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 129 | goto end 130 | ) 131 | 132 | if "%1" == "text" ( 133 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text 134 | if errorlevel 1 exit /b 1 135 | echo. 136 | echo.Build finished. The text files are in %BUILDDIR%/text. 137 | goto end 138 | ) 139 | 140 | if "%1" == "man" ( 141 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man 142 | if errorlevel 1 exit /b 1 143 | echo. 144 | echo.Build finished. The manual pages are in %BUILDDIR%/man. 145 | goto end 146 | ) 147 | 148 | if "%1" == "texinfo" ( 149 | %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo 150 | if errorlevel 1 exit /b 1 151 | echo. 152 | echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. 153 | goto end 154 | ) 155 | 156 | if "%1" == "gettext" ( 157 | %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale 158 | if errorlevel 1 exit /b 1 159 | echo. 160 | echo.Build finished. The message catalogs are in %BUILDDIR%/locale. 161 | goto end 162 | ) 163 | 164 | if "%1" == "changes" ( 165 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 166 | if errorlevel 1 exit /b 1 167 | echo. 168 | echo.The overview file is in %BUILDDIR%/changes. 169 | goto end 170 | ) 171 | 172 | if "%1" == "linkcheck" ( 173 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 174 | if errorlevel 1 exit /b 1 175 | echo. 176 | echo.Link check complete; look for any errors in the above output ^ 177 | or in %BUILDDIR%/linkcheck/output.txt. 178 | goto end 179 | ) 180 | 181 | if "%1" == "doctest" ( 182 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 183 | if errorlevel 1 exit /b 1 184 | echo. 185 | echo.Testing of doctests in the sources finished, look at the ^ 186 | results in %BUILDDIR%/doctest/output.txt. 187 | goto end 188 | ) 189 | 190 | :end 191 | -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/models/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iterative/cookiecutter-data-science/b987fdc5f55ab7fc80b63a1f88c5ed98917e463c/{{ cookiecutter.repo_name }}/models/.gitkeep -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/notebooks/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iterative/cookiecutter-data-science/b987fdc5f55ab7fc80b63a1f88c5ed98917e463c/{{ cookiecutter.repo_name }}/notebooks/.gitkeep -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/references/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iterative/cookiecutter-data-science/b987fdc5f55ab7fc80b63a1f88c5ed98917e463c/{{ cookiecutter.repo_name }}/references/.gitkeep -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/reports/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iterative/cookiecutter-data-science/b987fdc5f55ab7fc80b63a1f88c5ed98917e463c/{{ cookiecutter.repo_name }}/reports/.gitkeep -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/reports/figures/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iterative/cookiecutter-data-science/b987fdc5f55ab7fc80b63a1f88c5ed98917e463c/{{ cookiecutter.repo_name }}/reports/figures/.gitkeep -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/requirements.txt: -------------------------------------------------------------------------------- 1 | # local package 2 | -e . 3 | 4 | # external requirements 5 | click 6 | Sphinx 7 | coverage 8 | awscli 9 | flake8 10 | python-dotenv>=0.5.1 11 | {% if cookiecutter.use_data_version_control == 'y' %} 12 | dvc[s3] 13 | {% endif %} 14 | {% if cookiecutter.python_interpreter != 'python3' %} 15 | 16 | # backwards compatibility 17 | pathlib2 18 | {% endif %} 19 | -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import find_packages, setup 2 | 3 | setup( 4 | name='src', 5 | packages=find_packages(), 6 | version='0.1.0', 7 | description='{{ cookiecutter.description }}', 8 | author='{{ cookiecutter.author_name }}', 9 | license='{% if cookiecutter.open_source_license == 'MIT' %}MIT{% elif cookiecutter.open_source_license == 'BSD-3-Clause' %}BSD-3{% endif %}', 10 | ) 11 | -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/src/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iterative/cookiecutter-data-science/b987fdc5f55ab7fc80b63a1f88c5ed98917e463c/{{ cookiecutter.repo_name }}/src/__init__.py -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/src/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iterative/cookiecutter-data-science/b987fdc5f55ab7fc80b63a1f88c5ed98917e463c/{{ cookiecutter.repo_name }}/src/data/.gitkeep -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/src/data/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iterative/cookiecutter-data-science/b987fdc5f55ab7fc80b63a1f88c5ed98917e463c/{{ cookiecutter.repo_name }}/src/data/__init__.py -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/src/data/make_dataset.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import click 3 | import logging 4 | from pathlib import Path 5 | from dotenv import find_dotenv, load_dotenv 6 | 7 | 8 | @click.command() 9 | @click.argument('input_filepath', type=click.Path(exists=True)) 10 | @click.argument('output_filepath', type=click.Path()) 11 | def main(input_filepath, output_filepath): 12 | """ Runs data processing scripts to turn raw data from (../raw) into 13 | cleaned data ready to be analyzed (saved in ../processed). 14 | """ 15 | logger = logging.getLogger(__name__) 16 | logger.info('making final data set from raw data') 17 | 18 | 19 | if __name__ == '__main__': 20 | log_fmt = '%(asctime)s - %(name)s - %(levelname)s - %(message)s' 21 | logging.basicConfig(level=logging.INFO, format=log_fmt) 22 | 23 | # not used in this stub but often useful for finding various files 24 | project_dir = Path(__file__).resolve().parents[2] 25 | 26 | # find .env automagically by walking up directories until it's found, then 27 | # load up the .env entries as environment variables 28 | load_dotenv(find_dotenv()) 29 | 30 | main() 31 | -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/src/features/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iterative/cookiecutter-data-science/b987fdc5f55ab7fc80b63a1f88c5ed98917e463c/{{ cookiecutter.repo_name }}/src/features/.gitkeep -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/src/features/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iterative/cookiecutter-data-science/b987fdc5f55ab7fc80b63a1f88c5ed98917e463c/{{ cookiecutter.repo_name }}/src/features/__init__.py -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/src/features/build_features.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iterative/cookiecutter-data-science/b987fdc5f55ab7fc80b63a1f88c5ed98917e463c/{{ cookiecutter.repo_name }}/src/features/build_features.py -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/src/models/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iterative/cookiecutter-data-science/b987fdc5f55ab7fc80b63a1f88c5ed98917e463c/{{ cookiecutter.repo_name }}/src/models/.gitkeep -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/src/models/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iterative/cookiecutter-data-science/b987fdc5f55ab7fc80b63a1f88c5ed98917e463c/{{ cookiecutter.repo_name }}/src/models/__init__.py -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/src/models/predict_model.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iterative/cookiecutter-data-science/b987fdc5f55ab7fc80b63a1f88c5ed98917e463c/{{ cookiecutter.repo_name }}/src/models/predict_model.py -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/src/models/train_model.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iterative/cookiecutter-data-science/b987fdc5f55ab7fc80b63a1f88c5ed98917e463c/{{ cookiecutter.repo_name }}/src/models/train_model.py -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/src/visualization/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iterative/cookiecutter-data-science/b987fdc5f55ab7fc80b63a1f88c5ed98917e463c/{{ cookiecutter.repo_name }}/src/visualization/.gitkeep -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/src/visualization/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iterative/cookiecutter-data-science/b987fdc5f55ab7fc80b63a1f88c5ed98917e463c/{{ cookiecutter.repo_name }}/src/visualization/__init__.py -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/src/visualization/visualize.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iterative/cookiecutter-data-science/b987fdc5f55ab7fc80b63a1f88c5ed98917e463c/{{ cookiecutter.repo_name }}/src/visualization/visualize.py -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/test_environment.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | REQUIRED_PYTHON = "{{ cookiecutter.python_interpreter }}" 4 | 5 | 6 | def main(): 7 | system_major = sys.version_info.major 8 | if REQUIRED_PYTHON == "python": 9 | required_major = 2 10 | elif REQUIRED_PYTHON == "python3": 11 | required_major = 3 12 | else: 13 | raise ValueError("Unrecognized python interpreter: {}".format( 14 | REQUIRED_PYTHON)) 15 | 16 | if system_major != required_major: 17 | raise TypeError( 18 | "This project requires Python {}. Found: Python {}".format( 19 | required_major, sys.version)) 20 | else: 21 | print(">>> Development environment passes all tests!") 22 | 23 | 24 | if __name__ == '__main__': 25 | main() 26 | -------------------------------------------------------------------------------- /{{ cookiecutter.repo_name }}/tox.ini: -------------------------------------------------------------------------------- 1 | [flake8] 2 | max-line-length = 79 3 | max-complexity = 10 4 | --------------------------------------------------------------------------------