Set and get extra parameters
Set and get extra parameters#
In the previous section we computed an additional parameter for each neuron in the SOM: the petal width. Rather than keeping such parameters in separate variables, we can integrate them into the SOM to easily access them later on.
This is done with the set()
method
som.set('petal width', swidth_med)
som.set('petal width uncertainty', swidth_std)
To retrieve later on an extra parameter (e.g. petal width), then one can use the get()
method
pwidth = som.get('petal width')
print('Petal width for the SOM neurons:')
print(swidth_med)
print('\nPetal width stored in the SOM:')
print(pwidth)
Results
Petal width for the SOM neurons:
[nan, nan, nan, nan, nan, nan, 3.1, 3.2, nan, nan, nan, 3.5, 3.8, nan, 2.9, nan, nan, 2.3499999999999996, 2.9, 3.0, nan, nan, 2.6500000000000004, 2.8499999999999996, 3.0]
Petal width stored in the SOM:
[nan, nan, nan, nan, nan, nan, 3.1, 3.2, nan, nan, nan, 3.5, 3.8, nan, 2.9, nan, nan, 2.3499999999999996, 2.9, 3.0, nan, nan, 2.6500000000000004, 2.8499999999999996, 3.0]