generalize SOM so that it can be used with toy samples