Skip to content

Commit

Permalink
The "first" version.
Browse files Browse the repository at this point in the history
  • Loading branch information
orrorcol committed Apr 25, 2021
1 parent 5761055 commit 931d75b
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 2 deletions.
67 changes: 66 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down

0 comments on commit 931d75b

Please sign in to comment.