Kohonen Self-Organizing Maps¶
References¶
Intro¶
Unsupervised Learning
Dimensionality Reduction Method
An SOM is a type of artificial neural network but is trained using competitive learning rather than the error-correction learning (e.g., backpropagation with gradient descent) used by other artificial neural network
There is no loss/cost function, hence there is no back propagation
[15]:
import numpy as np
import pandas as pd
from sklearn.datasets import load_iris
from minisom import MiniSom
import matplotlib.pyplot as plt
[16]:
dataset = load_iris(as_frame=True)
data = dataset.data.values
[25]:
n_neurons = 3
m_neurons = 3
som = MiniSom(n_neurons, m_neurons, data.shape[1], sigma=1.5, learning_rate=0.5,
neighborhood_function='gaussian', random_seed=0)
som.pca_weights_init(data)
som.train(data, 10000, verbose=True)
[ 10000 / 10000 ] 100% - 0:00:00 left
quantization error: 0.5285510165231397
[26]:
plt.figure(figsize=(7, 7))
frequencies = som.activation_response(data)
plt.pcolor(frequencies.T, cmap='Blues')
plt.colorbar()
plt.show()
