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.

  • Gaussian or bubble neighborhood functions.

  • 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 manuscript describing the library [1].

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 the CUDAHOME variable is set, the usual install command will build and install the library:

$ sudo python setup.py install

Build with CUDA support on Windows:

You should first follow the instructions to build the Windows binary with HAVE_MPI and CLI 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.) The recommended configuration is VS2010 Platform Toolset with Python 3.4. Then you should copy the .obj files generated in the release build path to the Python\somoclu\src folder.

Then modify the environment variable CUDA_PATH or 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.

Citation

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

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.6.2.tar.gz (5.6 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.6.2.win-amd64-py3.5.exe (176.1 kB view details)

Uploaded Source

somoclu-1.6.2.win-amd64-py2.7.exe (145.9 kB view details)

Uploaded Source

somoclu-1.6.2.win32-py3.5.exe (162.8 kB view details)

Uploaded Source

somoclu-1.6.2.win32-py2.7.exe (225.5 kB view details)

Uploaded Source

somoclu-1.6.2-cp35-cp35m-win_amd64.whl (39.4 kB view details)

Uploaded CPython 3.5mWindows x86-64

somoclu-1.6.2-cp35-cp35m-win32.whl (33.3 kB view details)

Uploaded CPython 3.5mWindows x86

somoclu-1.6.2-cp35-cp35m-macosx_10_11_x86_64.whl (39.0 kB view details)

Uploaded CPython 3.5mmacOS 10.11+ x86-64

somoclu-1.6.2-cp34-cp34m-macosx_10_5_x86_64.whl (37.3 kB view details)

Uploaded CPython 3.4mmacOS 10.5+ x86-64

somoclu-1.6.2-cp27-none-macosx_10_11_x86_64.whl (39.3 kB view details)

Uploaded CPython 2.7macOS 10.11+ x86-64

somoclu-1.6.2-cp27-cp27m-win_amd64.whl (33.4 kB view details)

Uploaded CPython 2.7mWindows x86-64

somoclu-1.6.2-cp27-cp27m-win32.whl (29.0 kB view details)

Uploaded CPython 2.7mWindows x86

File details

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

File metadata

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

File hashes

Hashes for somoclu-1.6.2.tar.gz
Algorithm Hash digest
SHA256 3ed2bb9e3f7dbac091f31bd4fe5a70e35a1a6f4e3feb61a29b50b92405424c17
MD5 e40e79338934edd38408c17c4a13f3a9
BLAKE2b-256 aa75c3f11032f0cf86eada236acab7e161472c44ab3a801a823bf7dd1b399a4c

See more details on using hashes here.

File details

Details for the file somoclu-1.6.2.win-amd64-py3.5.exe.

File metadata

File hashes

Hashes for somoclu-1.6.2.win-amd64-py3.5.exe
Algorithm Hash digest
SHA256 7ddc6a42d7452cb10860b105ad16c1d32e83471ead5d5e4a4c385c3c113bd766
MD5 3d91a60d01207e86bfd633864c57889f
BLAKE2b-256 70dfc16952b7c70657ea72a1783c2f74af75a28fba0793716fe1db42a24727af

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for somoclu-1.6.2.win-amd64-py2.7.exe
Algorithm Hash digest
SHA256 ab902be7a3874f493da99d0415c6f09a8aacf3acd6c1ed33b232fc33b0c24c11
MD5 9482068799c55d29bf3550d5d7b11492
BLAKE2b-256 d7d31336ae27bcc2159f2427d0d077d2481e2e7ce3db2f0426c5938b175fbd20

See more details on using hashes here.

File details

Details for the file somoclu-1.6.2.win32-py3.5.exe.

File metadata

File hashes

Hashes for somoclu-1.6.2.win32-py3.5.exe
Algorithm Hash digest
SHA256 8180a0a8166e7828932d0a8bbb059d9bd4fc33b566cb29bf310c3f07070046bc
MD5 06e8ae4fc0728e570145ad3595322909
BLAKE2b-256 3558427fb39574d64dcf81c94cda443ed061db5678c4bc368e5a8d4ae6d5744e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for somoclu-1.6.2.win32-py2.7.exe
Algorithm Hash digest
SHA256 abb28d0feb959304e5bb831d3a824e49a7b595ad3f956bcdbe0f520435bfcd46
MD5 8430d1739edcc93f96c19bee168c0167
BLAKE2b-256 7f8272a911c936984a288d7bc15a343556059fcfb6ec545840926497bb6292c2

See more details on using hashes here.

File details

Details for the file somoclu-1.6.2-cp35-cp35m-win_amd64.whl.

File metadata

File hashes

Hashes for somoclu-1.6.2-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 e2487c7d253219d50d2ff7a9c5dc277e7d44331cf8f0489ed3901a2953968a65
MD5 fb46ffd16f3067637d86bba7465e0c55
BLAKE2b-256 191fe55fe5adacde307a23e88b36bee89472c69f6906257d1ad9555c94efa788

See more details on using hashes here.

File details

Details for the file somoclu-1.6.2-cp35-cp35m-win32.whl.

File metadata

File hashes

Hashes for somoclu-1.6.2-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 bf12cfd4757e068653b318150f2b6d0180ad088016c2c5cd9b1fd36de13b4130
MD5 9df76ab6023cc9d0998b95a7779d922a
BLAKE2b-256 d5a62d0fd2fab50b7bcb8b6c9e3dbc06ea405fdfc34dd6357c0d31a73f0b2a3a

See more details on using hashes here.

File details

Details for the file somoclu-1.6.2-cp35-cp35m-macosx_10_11_x86_64.whl.

File metadata

File hashes

Hashes for somoclu-1.6.2-cp35-cp35m-macosx_10_11_x86_64.whl
Algorithm Hash digest
SHA256 bee443b2dda34e6e5ea86318eeae1c1afbdd18c8096daf2c6c1f9caa9f2280d4
MD5 01872d64c278c9131888dc130dfaa7be
BLAKE2b-256 c482f7be502f2a5a4ddb421b1903bf16e37cfd1cdba010fd2dabef7928c832bd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for somoclu-1.6.2-cp34-cp34m-macosx_10_5_x86_64.whl
Algorithm Hash digest
SHA256 e701d7f57794a72b21d1e1b8d4d3015799d2b7c421bf404026562a9831bf0d00
MD5 7c136ab4a7822513549ef6d0dc200fa9
BLAKE2b-256 e67c61eab40c95743f20962be8da05b4eecc2dae7ad972544001b966457b7d5d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for somoclu-1.6.2-cp27-none-macosx_10_11_x86_64.whl
Algorithm Hash digest
SHA256 18f160c8a553811e8fc1473a9b400f9fc2d6f3c78e311ea292d0a8a6b8b9d333
MD5 77dce9ae32b9b2825db5aa11c94f841d
BLAKE2b-256 f8d2fbcddfb679d95052aac41a44efa2a4a715ca3b329d94b042ba02d5068fa1

See more details on using hashes here.

File details

Details for the file somoclu-1.6.2-cp27-cp27m-win_amd64.whl.

File metadata

File hashes

Hashes for somoclu-1.6.2-cp27-cp27m-win_amd64.whl
Algorithm Hash digest
SHA256 1da2e47c11485f4961644585e52bd859b8d26eac559c46ad88ad8325e1962eae
MD5 fbb714ab765a97a39a616641cdbb2403
BLAKE2b-256 90832d64f21b9e5a5616c33e8cd1f14c1143ad3a3d294b9327133eed7827af33

See more details on using hashes here.

File details

Details for the file somoclu-1.6.2-cp27-cp27m-win32.whl.

File metadata

File hashes

Hashes for somoclu-1.6.2-cp27-cp27m-win32.whl
Algorithm Hash digest
SHA256 2198001b0fe752fd042e5fe2d7a92838b5e4603ded4d86e3d46d10149bafe2dd
MD5 434260cf5dda80b1871ac8f515197de7
BLAKE2b-256 0fed775bab58f5d5fa1725c627993696f284595e6548e9d0bbd7d1716b5478f8

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