Reputation: 2005
I am new with clustering and neural nets, and I have just started using Self-Organizing Maps (SOM) to perform some clustering. I have a 15 dimensional dataset and I created a som with the next code:
size = 20
from minisom import MiniSom
som = MiniSom(size, size, 15, sigma=0.3, learning_rate=0.9, random_seed=149)
som.train_random(data, 650000, verbose=True)
And I plotted the som the next way:
plt.figure()
plt.pcolor(som.distance_map().T, cmap='Blues')
plt.colorbar()
plt.show()
My question is: if I have a new 15 dimensional element, how can I know which cluster of the som belongs to?
Upvotes: 2
Views: 2528
Reputation: 199
I have a feeling that MiniSom has a function implemented for this:
som.winner(*input_data*)
which returns the node that it is closest to.
Upvotes: 1
Reputation: 2139
Best Matching Unit (BMU)
for t in itertools.count():
i = np.random.choice(range(len(data)))
bmu = self.find_bmu(data[i])
Finding the Best Matching Unit
create n x n map with random node vector values
loop while s < StepsMax times
compute what a "close" node means, based on s
compute a learn rate, based on s
pick a random data item
determine the map node closest to data item (BMU)
for-each node close to the BMU
adjust node vector values towards data item
end-loop
Upvotes: 1