0

I have used this code but it showing me error. Help me solve this.

som=MiniSom(x=10,y=10,input_len=15,sigma=1.0,learning_rate=0.5)
som.random_weights_init(x)

som.train_random(data=x,num_iteration=100)

from pylab import bone, pcolor, colorbar, plot, show
bone()

pcolor(som.distance_map().T)

colorbar()

markers = ['o', 's']
colors = ['r', 'g']

for i, x1 in enumerate(x):
    w = som.winner(x)
    plot(w[0] + 0.5,
         w[1] + 0.5,
         markers[y[i]],
         markeredgecolor = colors[y[i]],
         markerfacecolor = 'None',
         markersize = 10,
         markeredgewidth = 2)

show()
Jeroen Heier
  • 3,520
  • 15
  • 31
  • 32

1 Answers1

0

The line w = som.winner(x) should be replaced with w = som.winner(x1)

MiniSom.winner() method computes the coordinates of the winning neuron for the sample x, where sample x is one single row of your dataset, and the corresponding variable name in your code is x1.

You are iterating x1 over rows of x, however still trying to use the dataset variable x with som.winner() method.

Cesar
  • 21
  • 2