From 931d75b129377bf17dd9466740819a8454df41fc Mon Sep 17 00:00:00 2001 From: uestc-lfs Date: Sun, 25 Apr 2021 18:23:16 +0800 Subject: [PATCH] The "first" version. --- README.md | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- setup.py | 2 +- 2 files changed, 67 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0674f98..9ee4296 100644 --- a/README.md +++ b/README.md @@ -20,10 +20,75 @@ pip install soinn python -m build ` + + +## API + +`learn(data: object = None, dead_age: int = 100, lambda: int = 100, noise: float = 0.5, num_layer: int = 1) -> object` + +**input** : numpy array of shape (n, dim) + +**dead_age ** : the dead age of edges during the learning process, default 100 + +**lamda** : the number of iterations before removing noise, default 100 + +**noise** : the ratio of noise in input data, default 0.5 + +**num_layer** : the number of soinn layer, default 1 + +**return** : return a one dimensional numpy array contaning all learned cendrioids + + + ## Run demo -After install soinn, you can run a demo to show how soinn works. +Here is a simple code using SOINN to learn cendroids of the input data + + + +`from scipy.io import loadmat + +import matplotlib.pyplot as plt + +import soinn + + + +data = loadmat("train.mat")['train'] + +print('Load data with shape', data.shape) + + + +ax=plt.subplot(121) + +ax.set_title('origin data') + +plt.plot(data[:,0], data[:,1], '.') + + + +clus = soinn.learn(data) + +print('soinn learned clusters with shape', clus.shape) + +ax=plt.subplot(122) + +ax.set_title('learned cendroids') + +plt.plot(clus[:,0], clus[:,1], '.') + + + +plt.show() + +` + +You can run it by: + ` cd demo && python demo.py ` + You can get the following result ![image](https://github.com/uestc-lfs/soinn/blob/master/demo/result.png) + diff --git a/setup.py b/setup.py index 9787d94..b8afa20 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ from setuptools import Extension, setup from setuptools.command.build_ext import build_ext -__version__ = '0.2.0' +__version__ = '0.2.1' include_dirs = [