SOMPY
SOMPY copied to clipboard
SOMPY basic usage
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?
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
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
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 thanks. yes. plz
Done! And tidier: https://github.com/sevamoo/SOMPY/commit/2256b07a48ada0386513ad810232744b016c3d09 :smile:
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
Hi, thanks for the library. @oliviaguest I need to write specific labels to neurons ¿how can I do this?
IIRC you pass the labels to the constructor when you create the object.
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
Here's how: Once the som is trained
som.data_labels = np.arrray(somelistofvalues)
Hope it is useful