This repository contains an implementation of a Self-Organizing Map (SOM), a type of artificial neural network that is trained using unsupervised learning to produce a low-dimensional (typically two-dimensional) representation of the input space. This implementation is particularly useful for visualizing high-dimensional data in a lower-dimensional space.
- Initialization Modes: Diagonal, One Point, Random.
- Adjustable Parameters: Learning rate, neighborhood influence, and number of neurons.
- Dynamic Neighborhood Updating: Automatic updating during training.
- Visualization Support: Visualize the training process in real-time.
- Data Mapping: Mapping of data points to neurons for cluster identification.
numpy
matplotlib
sklearn
(for example data generation)
No specific installation steps are required apart from ensuring the required dependencies are installed. You can install the dependencies using pip:
pip install numpy matplotlib scikit-learn
from som_module import SOM, analyze_array
from sklearn.datasets import make_blobs
data, _ = make_blobs(n_samples=1000, centers=50, n_features=7, random_state=42)
num_neurons = int(np.ceil(np.sqrt(data.shape[0])))
epochs = 100
learning_rate = 0.3
update_neighbors_epoch = 5
influence = 0.1
calculate_k_epoch = 2
k_neighbors = 5
som = SOM(data, num_neurons, epochs, learning_rate, influence, update_neighbors_epoch, calculate_k_epoch, k_neighbors, randomize_data=False, init_mode='diagonal')
mapped_data = som.train(step_by_step=True)
print(analyze_array(mapped_data))
Set step_by_step
to True
to enable real-time training visualization.