pygsom
is an open source python-based implementation of GSOM algorithm. GSOM is unsupervised dimensionality reduction and clustering algorithm
- Installation
- Minimal example
- Getting started
- [Citing gsom](#citing pygsom)
To pip install pygsom
from github:
pip install pygsom
pygsom supports Python 3.6+.
import numpy as np
import pandas as pd
import gsom
data_filename = "data/zoo.txt".replace('\\', '/')
if __name__ == '__main__':
np.random.seed(1)
df = pd.read_csv(data_filename)
print(df.shape)
data_training = df.iloc[:, 1:17]
gsom_map = gsom.GSOM(.83, 16, max_radius=4)
gsom_map.fit(data_training.to_numpy(), 100, 50)
map_points = gsom_map.predict(df,"Name","label")
gsom.plot(map_points, "Name", gsom_map=gsom_map)
map_points.to_csv("gsom.csv", index=False)
Train the GSOM algorithm : need to give input data in numpy array with training iterations and smoothing iterations
gsom_map.fit(data_training.to_numpy(), <training iterations>, <smooth iterations>)
Predict cluster nodes : need to give input data in pandas dataframe with names and labels
map_points = gsom_map.predict(df,<name column name>,<label column name>)
Plot the 2D map: need to give the output of predict function with label column (name column or label column)
gsom.plot(map_points, <name column name/label column name>, gsom_map=<gsom_map>)
If you use pygsom
, please cite the following paper:
@article{alahakoon2000dynamic,
title={Dynamic self-organizing maps with controlled growth for knowledge discovery},
author={Alahakoon, Damminda and Halgamuge, Saman K and Srinivasan, Bala},
journal={IEEE Transactions on neural networks},
volume={11},
number={3},
pages={601--614},
year={2000},
publisher={IEEE}
}