Skip to main content

Friends-of-friends cluster finding in python

Project description

pyfof

Friends of Friends cluster finding in python.

This implements the friends-of-friends algorithm to find clusters of points, accelerated with an R*-tree.

Requirements

  • c++11 complient compiler
  • Cython (for the development version only)
  • numpy
  • boost

Installation

If your boost installation is in a normal place you should just be able to install the latest release of the package directly from PyPI

pip install pyfof

If that fails then you will need to tell pip where to find your boost include directory. This can be done by creating a file in your home directory called .pydistutils.cfg containing:

[build_ext]
include_dirs=/path/to/boost/include/directory

and then running the above command.

Examples

Two Gaussian blobs

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import pyfof

npts = 10000
data = np.vstack((np.random.normal(-1,0.2,(npts/2,2)),\
                  np.random.normal(1,0.2,(npts/2,2))))

groups = pyfof.friends_of_friends(data, 0.4)

colors = cm.rainbow(np.linspace(0, 1, len(groups)))
for g,c in zip(groups, colors):
    plt.scatter(data[g,0], data[g,1], color=c, s=3)

plt.show()

gaussian_example

A more complicated example

stream_example

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyfof-0.1.5.tar.gz (56.5 kB view hashes)

Uploaded Source

Built Distributions

pyfof-0.1.5-cp38-cp38-manylinux1_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.8

pyfof-0.1.5-cp37-cp37m-manylinux1_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.7m

pyfof-0.1.5-cp36-cp36m-manylinux1_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.6m

pyfof-0.1.5-cp35-cp35m-manylinux1_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.5m

pyfof-0.1.5-cp34-cp34m-manylinux1_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.4m

pyfof-0.1.5-cp27-cp27mu-manylinux1_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 2.7mu

pyfof-0.1.5-cp27-cp27m-manylinux1_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 2.7m

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page