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.1.tar.gz (4.5 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.1.win-amd64-py3.4.exe (257.4 kB view details)

Uploaded Source

somoclu-1.5.1.win-amd64-py2.7.exe (256.9 kB view details)

Uploaded Source

somoclu-1.5.1.win32-py3.4.exe (221.3 kB view details)

Uploaded Source

somoclu-1.5.1.win32-py2.7.exe (224.4 kB view details)

Uploaded Source

somoclu-1.5.1-cp34-none-win_amd64.whl (34.4 kB view details)

Uploaded CPython 3.4Windows x86-64

somoclu-1.5.1-cp34-none-win32.whl (29.6 kB view details)

Uploaded CPython 3.4Windows x86

somoclu-1.5.1-cp34-cp34m-macosx_10_5_x86_64.whl (36.7 kB view details)

Uploaded CPython 3.4mmacOS 10.5+ x86-64

somoclu-1.5.1-cp27-none-win_amd64.whl (32.4 kB view details)

Uploaded CPython 2.7Windows x86-64

somoclu-1.5.1-cp27-none-win32.whl (27.6 kB view details)

Uploaded CPython 2.7Windows x86

somoclu-1.5.1-cp27-none-macosx_10_11_x86_64.whl (38.4 kB view details)

Uploaded CPython 2.7macOS 10.11+ x86-64

File details

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

File metadata

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

File hashes

Hashes for somoclu-1.5.1.tar.gz
Algorithm Hash digest
SHA256 48edf1eeed25cd2b13169fafe7ea4e9d6b65a6435b5625a49a7c83058203cb5a
MD5 692fce1f6d4370283f92eeb969a43771
BLAKE2b-256 e0f1df04fe5285fa1d439476b0d88e01f83e2093bf3171e0a7090ba8e0bccb54

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for somoclu-1.5.1.win-amd64-py3.4.exe
Algorithm Hash digest
SHA256 5368419f6cde1e455ec86c4c4d8be6eba3d713adb14d22249a7c23fa66fda27f
MD5 85ecee88eb217823a4a901f2ccc0b173
BLAKE2b-256 57fd6924271f2f765cb32d53f3ac469b719672f365a97527b29ae3ff1b7d2a6a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for somoclu-1.5.1.win-amd64-py2.7.exe
Algorithm Hash digest
SHA256 73198549bdf66483d22e34bfeed819ccb4f0479b33c2c18d5abb1b135304661e
MD5 f8488b992c04c5eecb3358dd850811f2
BLAKE2b-256 87726d9eabb6b4f0acc10080483af7133cd8ee492956607405bc42e7835d44a0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for somoclu-1.5.1.win32-py3.4.exe
Algorithm Hash digest
SHA256 ae059de26af8567fd316c6fcbd934d62f09208546a6336481b35f26e60dba1f9
MD5 8d073bf3c3c8574319b2a3e7fa5d1c79
BLAKE2b-256 29c8c6762a0c62e4e5c7e47b0bf1498350679b0c502713e5af12ab23f28f2308

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for somoclu-1.5.1.win32-py2.7.exe
Algorithm Hash digest
SHA256 91467021a0dabd6eb23c21dce6f884e8bb064b9c671002b3809d6e3229aa688a
MD5 302eee062a8eac55295c6c24fd5257da
BLAKE2b-256 f794a8ccd184e5d9ce92f738c5db03aee39fade60c65c9247ff633761c0e0f71

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for somoclu-1.5.1-cp34-none-win_amd64.whl
Algorithm Hash digest
SHA256 0ba1898274c4309489a71c3859d37ec9c63e43015cead49b62c86700caefae24
MD5 b34247780d8aa5bbcb6dc8e86b93a110
BLAKE2b-256 26217e39da1321cdeb95d41f5ce13a78e69c148280f9df7a6c8c5693e8d212c4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for somoclu-1.5.1-cp34-none-win32.whl
Algorithm Hash digest
SHA256 4b77ca01e84b4a665dfd6ce3524962d35c87528c127ab38c45dbbae2ffab0ff6
MD5 01979222123b6598a5376e4a01b639fb
BLAKE2b-256 6be5000d120afd685b3b34ecc205a488852c0054fd0ac7655307f05a40205137

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for somoclu-1.5.1-cp34-cp34m-macosx_10_5_x86_64.whl
Algorithm Hash digest
SHA256 08fc4f96a40c1246be292d3a3bd3a79f760eaf5438662c1b15d39c60b8089f95
MD5 20ccf4d71ca341e1bc2c117cd3cfb044
BLAKE2b-256 112aa60abae97af3c6cc90fb7c7e7526df074ef5adebdf929ce0489c9f267460

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for somoclu-1.5.1-cp27-none-win_amd64.whl
Algorithm Hash digest
SHA256 5c479b1c48acb311558e18480ce83c7703b40963672577702348a4bf2b468aca
MD5 d8434e369b88fc748d71b37ba6e0d98b
BLAKE2b-256 e830d74a9ead6c591ad2f21c57f99731c44736e76b75def36a9f01f0796cead4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for somoclu-1.5.1-cp27-none-win32.whl
Algorithm Hash digest
SHA256 e3fe60a977fba1a075a010d9bd5bd091720db8dea0f27874d916b34ad87bcd82
MD5 892bf3ef5cc77b2255c0c786486be3a5
BLAKE2b-256 adff077816b5e807494df4b736a30108115e7572dc943d1836ed0aea74f27e06

See more details on using hashes here.

File details

Details for the file somoclu-1.5.1-cp27-none-macosx_10_11_x86_64.whl.

File metadata

File hashes

Hashes for somoclu-1.5.1-cp27-none-macosx_10_11_x86_64.whl
Algorithm Hash digest
SHA256 9af387497d69178b0e01b3a504e54ec3242e866bcf30c8651d0782f575df02ac
MD5 04911656ed0bf89a4943a85ae4afb0bf
BLAKE2b-256 6de23e3a56eb85605c00ad233c2f718661019ded3697246ea7378babfc94fb18

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