Clusterer
Implementation of Self-Organizing Map.
SOM(n_columns=5, n_rows=5, initialcodebook=None, kerneltype=0, maptype='planar', gridtype='rectangular', compactsupport=True, neighborhood='gaussian', std_coeff=0.5, random_state=None, verbose=0)
Bases: BaseEstimator
, ClusterMixin
Class to fit and visualize a Self-Organizing Map (SOM).
The implementation uses SOM from Somoclu. Read more in the [user_guide].
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_columns |
int
|
The number of columns in the map. |
5
|
n_rows |
int
|
The number of rows in the map. |
5
|
initialcodebook |
ArrayLike | str | None
|
Define the codebook to start the training. If |
None
|
kerneltype |
int
|
Specify which kernel to use. If |
0
|
maptype |
str
|
Specify the map topology. If |
'planar'
|
gridtype |
str
|
Specify the grid form of the nodes. If |
'rectangular'
|
compactsupport |
bool
|
Cut off map updates beyond the training radius with the Gaussian neighborhood. |
True
|
neighborhood |
str
|
Specify the neighborhood. If |
'gaussian'
|
std_coeff |
float
|
Set the coefficient in the Gaussian
neighborhood :math: |
0.5
|
random_state |
int | RandomState | None
|
Control the randomization of the algorithm by specifying the
codebook initalization. It is ignored when
|
None
|
verbose |
int
|
Specify verbosity level (0, 1, or 2). |
0
|
Source code in src/clover/clusterer/_som.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
|
fit(X, y=None, **fit_params)
Train the self-organizing map.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
ArrayLike
|
Training instances to cluster. |
required |
y |
ArrayLike | None
|
Ignored |
None
|
fit_params |
dict[str, Any]
|
Parameters to pass to train method of Somoclu object. |
{}
|
Returns:
Type | Description |
---|---|
Self
|
The object itself. |
Source code in src/clover/clusterer/_som.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
|
fit_predict(X, y=None, **fit_params)
Train the self-organizing map and assign cluster labels to samples.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
ArrayLike
|
New data to transform. |
required |
y |
ArrayLike | None
|
Ignored. |
None
|
fit_params |
dict[str, Any]
|
Parameters to pass to train method of Somoclu object. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
labels |
NDArray
|
Index of the cluster each sample belongs to. |
Source code in src/clover/clusterer/_som.py
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
|
extract_topological_neighbors(col, row, gridtype, n_rows, n_columns, bmus)
Return the topological neighbors of a neuron.
Source code in src/clover/clusterer/_som.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
|
generate_labels_mapping(grid_labels)
Generate a mapping between grid labels and cluster labels.
Source code in src/clover/clusterer/_som.py
19 20 21 22 23 24 25 26 27 28 |
|