Python Machine Learning Snippets (pymls)
Python Machine Learning Snippets (pymls) is an ongoing project. This project contains various machine learning examples as Jupyter Notebooks with scikit-learn, statsmodel, numpy and other libraries. The examples are tested with Python 3.6.x.
Note: This is an ongoing project and is far away from complete.
To get started you can choose one of the these approaches:
- create a virtual environment with virtualenv and install the required packages with pip
- create a new conda environment and install the packges with conda install
- use the docker image rueedlinger/pyml (https://github.com/rueedlinger/docker-pyml) which has all required packages already installed.
First you should get a copy of this project. To do this just use the git clone or fork command.
git clone https://github.com/rueedlinger/machine-learning-snippets.git
The next example shows how to create an environment with "virtualenv" (https://virtualenv.pypa.io/) and install the required packages.
virtualenv --python=/usr/bin/python3.6 py36-ml source py36-ml/bin/activate pip install -r requirements.txt
Another aproach is to create an environment with conda (http://conda.pydata.org/) and the required packages.
conda create -n py36-ml python=3.6 source activate py36-ml pip install -r requirements.txt
You can just start the Docker image with the following command.
docker run -v /path/to/notebooks:/notebooks -p8888:8888 -it rueedlinger/pyml:0.3
With the -v flag you can specify where the volume is mounted on your local machine. This should point to the location where the notebooks are stored. The Juypter Notebook is running on port 8888. To change the port mapping to the container you can us the -p. To use the latest image you can change the tag 0.3 to latest.
Or use the bash script run-docker.sh with linux or mac which will start the Jupyter notebook and mount the voulme '/notebook'.
Next you shoud see the following output in the command line.
Copy/paste this URL into your browser when you connect for the first time, to login with a token: http://localhost:8888/?token=e00b3199838bcc3f15a3227fd52752eec4992ad8111d1b57
To connect to the Jupyter Notebook you have to copy/paste this URL into your browser.
At the moment there are the following machine learning snippets available as Jupyter (Python) Notebook.
- Centroid-based clustering
- K-means (scikit-learn)
- Density-based clustering
- Connectivity based clustering
- Agglomerative Clustering (Hierarchical Clustering) (scikit-learn)
- Hierarchical Clustering (SciPy)
- Distribution-based clustering
- Gaussian Mixture Model (scikit-learn)