Skip to content

Commit

Permalink
Finishing demo notebook and predict_proba on unseen data
Browse files Browse the repository at this point in the history
  • Loading branch information
Leandro Bugnon committed Oct 3, 2020
1 parent abb2982 commit fc2b321
Show file tree
Hide file tree
Showing 6 changed files with 3,192 additions and 403 deletions.
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ DeeSOM
--------------------------------------------------------------------------------
Self-organized map based classifier, developed to deal with large and highly imbalanced data.

sinc(i) - http://sinc.unl.edu.ar

The methods automatically build several layers of SOM. Data is clustered and samples that
are not likely to be positive class member are discarded at each level.

Expand All @@ -21,9 +19,19 @@ GPL. Please feel free to contact with any issue, comment or suggestion.
This code was used in:

"Deep neural architectures for highly imbalanced data in bioinformatics"
L. A. Bugnon, C. Yones, D. H. Milone and G. Stegmayer*, IEEE Transactions on Neural Networks and Learning Systems,
L. A. Bugnon, C. Yones, D. H. Milone and G. Stegmayer, IEEE Transactions on Neural Networks and Learning Systems,
Special Issue on Recent Advances in Theory, Methodology and Applications of Imbalanced Learning (in press).

sinc(i) - http://sinc.unl.edu.ar


## Instalation

## Running the demo.
just do:
```bash
python -m pip install --user -U deeSOM
```

## Running the demo

You'll find a Jupyter notebook with a small tutorial to train a deeSOM model and use it for predictions.
26 changes: 10 additions & 16 deletions deesom/deesom.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,29 +287,23 @@ def predict_proba(self, test_data=None):
if test_data is None:
return self.data_proba/np.max(self.data_proba)

# TODO when test_data is not none

def get_deesom_height(self, n_out, n_in):
""" Calculate next SOM layer height using the elastic algorithm"""
if self.elastic and n_out > self.elastic_threshold * n_in:
self.elastic_factor *= 1.2

def predict(self, test_data):
"""
Implement deepsom testing per level.
"""
n_data = test_data.shape[0]
idxtst = np.array(range(n_data))
slabsh = np.zeros(n_data, dtype=np.int)
scores = np.zeros(n_data, dtype=np.int)
h = 0
while h < len(self.layers) and len(idxtst) > 0:

resh = self.layers[h].predict(test_data[idxtst, :])

idxtst = idxtst[np.where(resh == 1)[0]]
slabsh[idxtst] += 1
scores[idxtst] += 1
# slab[i]==n means sample i was discarded in layer n (thus it was considered as positive up to layer n-1)
h += 1
return slabsh
return scores/np.max(scores)


def get_deesom_height(self, n_out, n_in):
""" Calculate next SOM layer height using the elastic algorithm"""
if self.elastic and n_out > self.elastic_threshold * n_in:
self.elastic_factor *= 1.2


379 changes: 0 additions & 379 deletions deesom/demo.ipynb

This file was deleted.

Loading

0 comments on commit fc2b321

Please sign in to comment.