Skip to main content

Massively parallel implementation of self-organizing maps

Project description

Somoclu is a massively parallel implementation of self-organizing maps. It relies on OpenMP for multicore execution, MPI for distributing the workload, and it can be accelerated by CUDA. A sparse kernel is also included, which is useful for training maps on vector spaces generated in text mining processes. The topology of map is either planar or toroid, the grid is rectangular or hexagonal. Currently a subset of the command line version is supported with this Python module.

Key features of the Python interface:

  • Fast execution by parallelization: OpenMP and CUDA are supported.

  • Multi-platform: Linux, OS X, and Windows are supported.

  • Planar and toroid maps.

  • Rectangular and hexagonal grids.

  • Visualization of maps, including those that were trained outside of Python.

The documentation is available on Read the Docs. Further details are found in the following paper:

Peter Wittek, Shi Chao Gao, Ik Soo Lim, Li Zhao (2015). Somoclu: An Efficient Parallel Library for Self-Organizing Maps. arXiv:1305.1422.

Usage

A simple example is below. For more example, please refer to the documentation and a more thorough ipython notebook example at Somoclu in Python.ipynb.

import somoclu
import numpy as np
import matplotlib.pyplot as plt

c1 = np.random.rand(50, 2)/5
c2 = (0.2, 0.5) + np.random.rand(50, 2)/5
c3 = (0.4, 0.1) + np.random.rand(50, 2)/5
data = np.float32(np.concatenate((c1, c2, c3)))
colors = ["red"] * 50
colors.extend(["green"] * 50)
colors.extend(["blue"] * 50)

labels = list(range(150))
#labels[2] = None
#labels[41] = None
#labels[40] = None
n_rows, n_columns = 30, 50
som = somoclu.Somoclu(n_columns, n_rows, data=data, maptype="planar",
                      gridtype="rectangular")
som.train(epochs=10)
som.view_umatrix(bestmatches=True, bestmatchcolors=colors, labels=labels)

Installation

The code is available on PyPI, hence it can be installed by

$ sudo pip install somoclu

Some pre-built binaries in the wheel format or windows installer are provided at PyPI Dowloads, they are tested with Anaconda distributions. If you encounter errors like ImportError: DLL load failed: The specified module could not be found when import somoclu, you may need to use Dependency Walker as shown here on _somoclu_wrap.pyd to find out missing DLLs and place them at the write place. Usually right version (32/64bit) of vcomp90.dll, msvcp90.dll, msvcr90.dll should be put to C:\Windows\System32 or C:\Windows\SysWOW64.

The wheel binaries for OSX are compiled with clang-omp , and depend on libiomp5, which you can install by:

$ brew install libiomp

If you want the latest git version, first git clone the repo, install swig and run:

$ ./autogen.sh
$ ./configure [options]
$ make
$ make python

to generate python interface files.

Then follow the standard procedure for installing Python modules:

$ sudo python setup.py install

Build on Mac OS X

Using GCC

Since OS X 10.9, gcc is just symlink to clang. To build somoclu and this extension correctly, it is recommended to install gcc using something like:

$ brew install gcc --without-multilib

and set environment using:

export CC=/usr/local/bin/gcc-5
export CXX=/usr/local/bin/g++-5
export CPP=/usr/local/bin/cpp-5
export LD=/usr/local/bin/gcc-5
alias c++=/usr/local/bin/c++-5
alias g++=/usr/local/bin/g++-5
alias gcc=/usr/local/bin/gcc-5
alias cpp=/usr/local/bin/cpp-5
alias ld=/usr/local/bin/gcc-5
alias cc=/usr/local/bin/gcc-5

Using clang-omp

To install clang-omp, follow instructions at http://clang-omp.github.io/. And set environment using:

export CC=/usr/local/bin/clang-omp
export CXX=/usr/local/bin/clang-omp++
export CPP=/usr/local/bin/clang-omp++
export LD=/usr/local/bin/clang-omp
alias c++=/usr/local/bin/clang-omp++
alias g++=/usr/local/bin/clang-omp++
alias gcc=/usr/local/bin/clang-omp
alias cpp=/usr/local/bin/clang-omp++
alias ld=/usr/local/bin/clang-omp
alias cc=/usr/local/bin/clang-omp
export PATH=/usr/local/bin/:$PATH
export C_INCLUDE_PATH=/usr/local/include/:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=/usr/local/include/:$CPLUS_INCLUDE_PATH
export LIBRARY_PATH=/usr/local/lib:$LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

Before building the module manually with:

$ python setup.py build

Build with CUDA support on Linux and OS X:

If your CUDA is installed elsewhere than /usr/local/cuda, you cannot directly install the module from PyPI. Please download the source distribution from PyPI. Open the setup.py file in an editor and modify the path to your CUDA installation directory:

cuda_dir = /path/to/cuda

Then run the install command

$ sudo python setup.py install

Build with CUDA support on Windows:

You should first follow the instructions to build the Windows binary with MPI disabled with the same version Visual Studio as your Python is built with.(Since currently Python is built by VS2008 by default and CUDA v6.5 removed VS2008 support, you may use CUDA 6.0 with VS2008 or find a Python prebuilt with VS2010. And remember to install VS2010 or Windows SDK7.1 to get the option in Platform Toolset if you use VS2013.) Then you should copy the .obj files generated in the release build path to the Python/src folder.

Then modify the win_cuda_dir in setup.py to your CUDA path and run the install command

$ sudo python setup.py install

Then it should be able to build and install the module.

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

somoclu-1.5.0.1.tar.gz (4.3 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

somoclu-1.5.0.1.win-amd64-py3.4.exe (272.3 kB view details)

Uploaded Source

somoclu-1.5.0.1.win-amd64-py2.7.exe (260.1 kB view details)

Uploaded Source

somoclu-1.5.0.1.win32-py3.4.exe (233.5 kB view details)

Uploaded Source

somoclu-1.5.0.1.win32-py2.7.exe (227.2 kB view details)

Uploaded Source

somoclu-1.5.0.1-cp34-none-win_amd64.whl (49.3 kB view details)

Uploaded CPython 3.4Windows x86-64

somoclu-1.5.0.1-cp34-none-win32.whl (41.7 kB view details)

Uploaded CPython 3.4Windows x86

somoclu-1.5.0.1-cp34-cp34m-macosx_10_5_x86_64.whl (44.2 kB view details)

Uploaded CPython 3.4mmacOS 10.5+ x86-64

somoclu-1.5.0.1-cp27-none-win_amd64.whl (35.5 kB view details)

Uploaded CPython 2.7Windows x86-64

somoclu-1.5.0.1-cp27-none-win32.whl (30.3 kB view details)

Uploaded CPython 2.7Windows x86

somoclu-1.5.0.1-cp27-none-macosx_10_10_x86_64.whl (63.5 kB view details)

Uploaded CPython 2.7macOS 10.10+ x86-64

File details

Details for the file somoclu-1.5.0.1.tar.gz.

File metadata

  • Download URL: somoclu-1.5.0.1.tar.gz
  • Upload date:
  • Size: 4.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for somoclu-1.5.0.1.tar.gz
Algorithm Hash digest
SHA256 289c4b6dca40b05572a3492b56b1d0fba02b129d4ae804bb67082f5c418f7803
MD5 03990d6a6f317c924d5ad82fcabedbbb
BLAKE2b-256 c578d9196362a7f314096794418fb1771f7d9e52539cfb3feb82c8f3b1f092b6

See more details on using hashes here.

File details

Details for the file somoclu-1.5.0.1.win-amd64-py3.4.exe.

File metadata

File hashes

Hashes for somoclu-1.5.0.1.win-amd64-py3.4.exe
Algorithm Hash digest
SHA256 21f5f540e992c05a67570918fa4b36b0aa1fed576e7fd4319310fcc6cc49a028
MD5 41ba9090ea20e45c0124ef21f31aadf3
BLAKE2b-256 327636488c363ed88a7b89266879638f4d4253f78f483028fa2bf052d3a0b1a1

See more details on using hashes here.

File details

Details for the file somoclu-1.5.0.1.win-amd64-py2.7.exe.

File metadata

File hashes

Hashes for somoclu-1.5.0.1.win-amd64-py2.7.exe
Algorithm Hash digest
SHA256 23a872e82d1b66899b45dbf05b9457a4fb8c028622347ce34ac097a75a1a01c2
MD5 49164c446b9d098e6c67ef6753bbde1f
BLAKE2b-256 db9aea9620316a5598378520d68701b3635a78196562cc941abd634ba5c9e7e1

See more details on using hashes here.

File details

Details for the file somoclu-1.5.0.1.win32-py3.4.exe.

File metadata

File hashes

Hashes for somoclu-1.5.0.1.win32-py3.4.exe
Algorithm Hash digest
SHA256 45a70744ebad68eff5605025608fb71ca1492eb314e1577b0abdc1e92c2c7c67
MD5 db41080ce8d599b09e58efaa4304b338
BLAKE2b-256 a0bad6206924d8311374fae77397394a11a996ee0655f2199a01c358d2f8d90d

See more details on using hashes here.

File details

Details for the file somoclu-1.5.0.1.win32-py2.7.exe.

File metadata

File hashes

Hashes for somoclu-1.5.0.1.win32-py2.7.exe
Algorithm Hash digest
SHA256 8a8def59d56866263e912d0407976fce36d72451c16d141746a03d9ff9019eb7
MD5 264434203b759beed3a2e8f64a773c8f
BLAKE2b-256 3ab18a156d2b9e458b9e1a1f26778dc3d0a6f0a3434f951a2a6a2e9e41a66977

See more details on using hashes here.

File details

Details for the file somoclu-1.5.0.1-cp34-none-win_amd64.whl.

File metadata

File hashes

Hashes for somoclu-1.5.0.1-cp34-none-win_amd64.whl
Algorithm Hash digest
SHA256 a9656ae0740e0699efa9a04a09dc9149d0057f6cce139918b7be12c147a3d2df
MD5 204af2037bea1d8f737060296e0877f1
BLAKE2b-256 1bd067723a6bab975f692031ba9188383446b4e3073e4a86bae39b3bc5e6f416

See more details on using hashes here.

File details

Details for the file somoclu-1.5.0.1-cp34-none-win32.whl.

File metadata

File hashes

Hashes for somoclu-1.5.0.1-cp34-none-win32.whl
Algorithm Hash digest
SHA256 645e03c10c118f1b94e84e8faa299dd67f82c8924736c344a036f8ad10917dcd
MD5 737edc8b29c27ce5c888d5794dda187c
BLAKE2b-256 5c5aad16d7d6b6ae4ed56358fc14d69053d9c2bf377d015ecaf8ec6d055e59cc

See more details on using hashes here.

File details

Details for the file somoclu-1.5.0.1-cp34-cp34m-macosx_10_5_x86_64.whl.

File metadata

File hashes

Hashes for somoclu-1.5.0.1-cp34-cp34m-macosx_10_5_x86_64.whl
Algorithm Hash digest
SHA256 f3ec279ea3cfe93f375e3784c44446eda1a3c784baa70c37f2698bb71d52aedf
MD5 7c9024eca17c2b746c1754e6bc21a7fe
BLAKE2b-256 a754b4d66901d892660ca8a57a1488b1fa2f42aca91671b4ae09a6e3cacfc12b

See more details on using hashes here.

File details

Details for the file somoclu-1.5.0.1-cp27-none-win_amd64.whl.

File metadata

File hashes

Hashes for somoclu-1.5.0.1-cp27-none-win_amd64.whl
Algorithm Hash digest
SHA256 bcef8255764dc501765d35d091a4d34eaca3314b018d5eb34c2176a06b8eec40
MD5 ad654260055dde1f9b87393f7d8c028c
BLAKE2b-256 6a254561fda6f62316ee486d8ff5dc60fc9350ee74fbbbc62e3469c5348554e6

See more details on using hashes here.

File details

Details for the file somoclu-1.5.0.1-cp27-none-win32.whl.

File metadata

File hashes

Hashes for somoclu-1.5.0.1-cp27-none-win32.whl
Algorithm Hash digest
SHA256 77912fd8ce5994abac788675f6337d1a72f02e70905f7d06ae0886ad540cedd7
MD5 4da1e8fc561c07a2b86188649d4c325a
BLAKE2b-256 a9d18381649b4141453b246d5092c4f1b36335feea2a635f1b576a584c8fb071

See more details on using hashes here.

File details

Details for the file somoclu-1.5.0.1-cp27-none-macosx_10_10_x86_64.whl.

File metadata

File hashes

Hashes for somoclu-1.5.0.1-cp27-none-macosx_10_10_x86_64.whl
Algorithm Hash digest
SHA256 5e197725e1bb2e0ba93f6ab915a5ead8ccbd1521e50f0ea806b50f0f7848f0ff
MD5 7e489f5c0b62e6e4e18bd97e483fc0fc
BLAKE2b-256 48ff8724a19d2e438906c6716cda9766488f44b3c9a53707b72236fc78789bfd

See more details on using hashes here.

Supported by

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