1

I`m trying to plot the SOM that I performed on unlabeled data that consists of 25 columns where each column represents the power consumption of a specific house during 2 years. the code after pre-processing the data is here:

import sys
sys.path.insert(0, '../')
%load_ext autoreload

import numpy as np
from numpy import genfromtxt
import pandas as pd
import matplotlib.pyplot as plt
from pylab import plot,axis,show,pcolor,colorbar,bone
from matplotlib.patches import Patch
%matplotlib inline

from minisom import MiniSom
%autoreload 2
data1 = np.array(data1)
som =MiniSom(5, 5, data1.shape[1], sigma=1.5, learning_rate=0.7)
som.pca_weights_init(data1)
som.train_batch(data=data1 ,num_iteration=2500,verbose=True)
from pylab import plot,axis,show,pcolor,colorbar,bone
bone()
pcolor(som.distance_map().T) # distance map as background
colorbar()

for cnt,xx in enumerate(X):
    
    w = som.winner(xx) 
    plot(w[0]+0.5,w[1]+0.5)
axis([0,som._weights.shape[0],0,som._weights.shape[1]])
show() 

the code is not giving any error and the output is basically the distance map, how can I add markers and colors to the plot to know the clustering results of the houses? is there any way where I can do it automatically or I should declare a list of Markers and colors? please any help I have been trying to plot it since a long time and no results.

Aghyad Skaif
  • 49
  • 10

0 Answers0