This repository contains code for a sample python package called distributions. It will enable users to import it in their python projects and use it to perform operations on various statistical distributions.
An object oriented approach has been followed, and all distributions are expected to inherit from parent class called Distribution
, written in Generaldistribution.py
.
The project follows a test driven approach, with the unit tests written in test.py
.
This project stems from the AWS Machine Learning Foundations Course over Udacity.
The following distributions have been covered yet:
- Gaussian Distribution
- Normal Distribution
Here is a description of each file and folder in this project
distributions
, which contains the code for the distributions package includingGaussiandistribution.py
andGeneraldistribution.py
code.setup.py
a file needed for building python packages with piptest.py
unit tests to help you debug your codenumbers.txt
andnumbers_binomial.txt
are data files used as part of the unit tests
Installing the distributions package
To pip install your distributions package, in the terminal, assuming you are in the root directory of the project, type the following into the command line:
pip install .
Note that if you change the code in the distributions folder after pip installing the package, Python will not know about the changes. You'll need to run
pip install --upgrade .
when you make changes to the package files.
Testing your code
When you're ready to test out your code, run the unit tests by typing:
python -m unittest test
- Every new distribution should be written in a new file inside the
distributions
folder. - Every new distribution should preferably inherit from
Distributions
class written inGeneraldistribution.py
. - The distributions should be imported inside the
__init.py__
file inside thedistributions
folder. - Each distribution should at least have the
__add__
and__repr__
magic functions available. - Unit tests should be written in
test.py
in the root directory. - Data for unit tests should also be in the root directory.