SOMPY icon indicating copy to clipboard operation
SOMPY copied to clipboard

SOMPY basic usage

Open dcaled opened this issue 8 years ago • 10 comments

I tried this example: http://bit.ly/1eZvaCM And it does not seems to be up to date. I made some fixes, but, I can not run it yet.

I changed:

sm = SOM.SOM('sm', Data, mapsize = [msz0, msz1],norm_method = 'var',initmethod='pca')
sm.train(n_job = 1, shared_memory = 'no',verbose='final')

to:

sm = SOM.SOM(data = Data, neighborhood = neighborhood, mapsize = [msz0, msz1], initialization ='pca') #, norm_method = 'var')
sm.train(n_job = 1, shared_memory = False, verbose='info')

Neighborhood is a required attribute. So, I have to instantiate an object of the type NeighborhoodFactory, right? So, I created it and used it as a parameter of SOM.SOM method.

neighborhood = NeighborhoodFactory.build('gaussian')

I don't know if this is the right choice. And, also, I can not visualize the resulting data as the example because of the changes made in the visualization methods.

Is it possible to assign labels to data and to verify in which group they were grouped in? I also tried this code below (according to this) and it raises a TypeError.

sm = SOM.SOM(data = Data, neighborhood = neighborhood, mapsize = [msz0, msz1], initialization ='pca') 
labels = ['a','b','c'] 
sm.data_labels(labels)

Is there another basic usage example?

dcaled avatar Apr 05 '16 15:04 dcaled

Hi. I have manage to translate most of the code, which you were using into new version of code

About you second question, I can not figure it out too. I am working on that

melgor avatar Apr 14 '16 11:04 melgor

I also would be curious to know if labels can be assigned I tried writing to the _dlabel attribute directly, but I assume it gets overwritten?

I have a working version of the basic stuff (which seems different (at least by a little) to @melgor), see: https://github.com/oliviaguest/my-sompy/blob/master/basic_uses.py

oliviaguest avatar May 05 '16 18:05 oliviaguest

OK, got the labels done if anybody is interested: https://github.com/oliviaguest/SOMPY/commit/bb7a0c023b66035e45e03c775a2298256897b910

@sevamoo if you want I can request a pull?

oliviaguest avatar May 05 '16 20:05 oliviaguest

@oliviaguest thanks. yes. plz

sevamoo avatar May 05 '16 23:05 sevamoo

Done! And tidier: https://github.com/sevamoo/SOMPY/commit/2256b07a48ada0386513ad810232744b016c3d09 :smile:

oliviaguest avatar May 05 '16 23:05 oliviaguest

That allows both custom labels and those generated within the object itself. I'm using custom labels. So value for labels can be Boolean or a list of strings. Pull request: https://github.com/sevamoo/SOMPY/pull/13

oliviaguest avatar May 06 '16 00:05 oliviaguest

Hi, thanks for the library. @oliviaguest I need to write specific labels to neurons ¿how can I do this?

sergiohzlz avatar Mar 12 '18 15:03 sergiohzlz

IIRC you pass the labels to the constructor when you create the object.

oliviaguest avatar Mar 12 '18 15:03 oliviaguest

Mmm no, at least there's no attribute to do this, nevertheless there is an attribute in the instance called sm = sompy.SOMFactory.build(data, mapsize=size, mapshape='planar', lattice='rect', normalization='var', initialization='random', neighborhood='gaussian', training='batch') sm.data_labels

sergiohzlz avatar Mar 12 '18 21:03 sergiohzlz

Here's how: Once the som is trained som.data_labels = np.arrray(somelistofvalues)

Hope it is useful

sergiohzlz avatar Mar 13 '18 01:03 sergiohzlz