Giter Club home page Giter Club logo

data-testing-tutorial's Introduction

Best Testing Practices for Data Science

A short tutorial for data scientists on how to write tests for your code and your data. Before the tutorial, please read through this README file, for it contains a lot of useful information that will help you best prepare for the tutorial.

How to use this repository

The tutorial notes are typed up in Jupyter notebooks, and static HTML versions are available under the docs folder. For the non-bonus material, I suggest working through the notes in order. With the exception of the Projects, the bonus material can be tackled in any order. During the tutorial, be sure to have the HTML versions open.

Pre-Requisite Knowledge

I am assuming you are of the following type of coder:

  • You are a data analytics type, who knows how to read/write CSV files with Pandas, and do basic data manipulation (slicing, indexing rows + columns, using the .apply() function).
  • You are not necessarily a seasoned software developer who has experience running tests.
  • You are comfortable with operating in the Terminal environment.
  • You have some rudimentary knowledge of numpy, particularly the the array.min(), array.max(), array.mean(), array.std(), and numpy.allclose(a1, a2) function calls.

In order to prepare for the tutorial, there are some pieces of Python syntax that will come in handy to know:

  • the context manager syntax (with ....),
  • assertions (assert conditions1 == condition2),
  • file I/O (with open(....) as f:...),
  • list/dict/tuple comprehensions ([a for a in container if condition(a)]),
  • checking types & attributes (isinstance(obj, type) or hasattr(obj, attr)).

Feedback

If you've taken a version of this tutorial, please leave feedback here. I use the suggestions in there to adjust the tutorial content and make it better. The changes are always released publicly on GitHub, so everybody benefits!

Environment Setup

conda setup

This installation route should work cross-platform. I recommend using the Anaconda distribution of Python because it is a good way to bootstrap your data science environment.

To get setup, create a conda environment based on the provided environment.yml spec file. Run the following commands in your bash terminal.

$ bash conda-setup.sh

pip setup

The alternative way is to use a virtualenv environment:

$ bash venv-setup.sh
$ source datatest/bin/activate

Alternatively, you can pip install each of the dependencies listed in the environment.yml file. (The requirements.txt file may be less eagerly maintained than the environment.yml file, given the conda-biases that I have.)

Manual Setup

If you prefer having more control over your installation process, conda or pip install the dependencies listed in the environment.yml file.

Checks

To check whether the environment is correctly setup, run the checkenv.py script:

$ python checkenv.py

It should print to your terminal, All packages found; environment checks passed.. Otherwise, conda or pip install the necessary packages stated (they will show up one by one).

Authors

Contributors

Special thanks goes to individuals who have contributed in ways big and small to the improvement of the material.

  • Renee Chu
  • Matt Bachmann: @Bachmann1234
  • Hugo Bowne-Anderson: @hugobowne
  • Boston Python tutorial attendees:
    • @races1986
    • Thao Nguyen: @ThaoNguyen15
    • @ChrisMuir

Data Credits

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.