Skip to content

Commit 3294368

Browse files
committed
[JTH] add more docu to custering techniques
1 parent 57e59b7 commit 3294368

File tree

4 files changed

+52
-14
lines changed

4 files changed

+52
-14
lines changed

bluemath_tk/core/decorators.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,14 @@ def wrapper(
216216
raise ValueError("Number of iterations must be integer and > 0")
217217
if not isinstance(normalize_data, bool):
218218
raise TypeError("Normalize data must be a boolean")
219-
return func(self, data, directional_variables, num_iteration)
219+
return func(
220+
self,
221+
data,
222+
directional_variables,
223+
custom_scale_factor,
224+
num_iteration,
225+
normalize_data,
226+
)
220227

221228
return wrapper
222229

bluemath_tk/datamining/kma.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,14 @@ def fit_predict(
377377
data : pd.DataFrame
378378
The input data to be used for the KMA algorithm.
379379
directional_variables : List[str], optional
380-
A list of directional variables (will be transformed to u and v).
380+
A list of directional variables that will be transformed to u and v components.
381+
Then, to use custom_scale_factor, you must specify the variables names with the u and v suffixes.
382+
Example: directional_variables=["Dir"], custom_scale_factor={"Dir_u": [0, 1], "Dir_v": [0, 1]}.
381383
Default is [].
382-
custom_scale_factor : dict
384+
custom_scale_factor : dict, optional
383385
A dictionary specifying custom scale factors for normalization.
386+
If normalize_data is True, this will be used to normalize the data.
387+
Example: {"Hs": [0, 10], "Tp": [0, 10]}.
384388
Default is {}.
385389
min_number_of_points : int, optional
386390
The minimum number of points to consider a cluster.
@@ -390,10 +394,13 @@ def fit_predict(
390394
This is used when min_number_of_points is not None.
391395
Default is 10.
392396
normalize_data : bool, optional
393-
A flag to normalize the data. Default is False.
397+
A flag to normalize the data.
398+
If True, the data will be normalized using the custom_scale_factor.
399+
Default is False.
394400
regression_guided: dict, optional
395401
A dictionary specifying regression-guided clustering variables and relative weights.
396-
Example: {"vars":["Fe"],"alpha":[0.6]}. Default is {}.
402+
Example: {"vars": ["Fe"], "alpha": [0.6]}.
403+
Default is {}.
397404
398405
Returns
399406
-------

bluemath_tk/datamining/mda.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,16 +297,22 @@ def fit(
297297
data : pd.DataFrame
298298
The input data to be used for the MDA algorithm.
299299
directional_variables : List[str], optional
300-
A list of names of the directional variables within the data.
300+
A list of directional variables that will be transformed to u and v components.
301+
Then, to use custom_scale_factor, you must specify the variables names with the u and v suffixes.
302+
Example: directional_variables=["Dir"], custom_scale_factor={"Dir_u": [0, 1], "Dir_v": [0, 1]}.
301303
Default is [].
302304
custom_scale_factor : dict, optional
303305
A dictionary specifying custom scale factors for normalization.
306+
If normalize_data is True, this will be used to normalize the data.
307+
Example: {"Hs": [0, 10], "Tp": [0, 10]}.
304308
Default is {}.
305309
first_centroid_seed : int, optional
306310
The index of the first centroid to use in the MDA algorithm.
307311
Default is None.
308312
normalize_data : bool, optional
309-
A flag to normalize the data. Default is False.
313+
A flag to normalize the data.
314+
If True, the data will be normalized using the custom_scale_factor.
315+
Default is False.
310316
311317
Notes
312318
-----
@@ -432,16 +438,22 @@ def fit_predict(
432438
data : pd.DataFrame
433439
The input data to be used for the MDA algorithm.
434440
directional_variables : List[str], optional
435-
A list of names of the directional variables within the data.
441+
A list of directional variables that will be transformed to u and v components.
442+
Then, to use custom_scale_factor, you must specify the variables names with the u and v suffixes.
443+
Example: directional_variables=["Dir"], custom_scale_factor={"Dir_u": [0, 1], "Dir_v": [0, 1]}.
436444
Default is [].
437445
custom_scale_factor : dict, optional
438446
A dictionary specifying custom scale factors for normalization.
447+
If normalize_data is True, this will be used to normalize the data.
448+
Example: {"Hs": [0, 10], "Tp": [0, 10]}.
439449
Default is {}.
440450
first_centroid_seed : int, optional
441451
The index of the first centroid to use in the MDA algorithm.
442452
Default is None.
443453
normalize_data : bool, optional
444-
A flag to normalize the data. Default is False.
454+
A flag to normalize the data.
455+
If True, the data will be normalized using the custom_scale_factor.
456+
Default is False.
445457
446458
Returns
447459
-------

bluemath_tk/datamining/som.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -294,18 +294,24 @@ def fit(
294294
Parameters
295295
----------
296296
data : pd.DataFrame
297-
The input data to be used for the fitting.
297+
The input data to be used for the SOM algorithm.
298298
directional_variables : List[str], optional
299-
A list with the directional variables (will be transformed to u and v).
299+
A list of directional variables that will be transformed to u and v components.
300+
Then, to use custom_scale_factor, you must specify the variables names with the u and v suffixes.
301+
Example: directional_variables=["Dir"], custom_scale_factor={"Dir_u": [0, 1], "Dir_v": [0, 1]}.
300302
Default is [].
301303
custom_scale_factor : dict, optional
302304
A dictionary specifying custom scale factors for normalization.
305+
If normalize_data is True, this will be used to normalize the data.
306+
Example: {"Hs": [0, 10], "Tp": [0, 10]}.
303307
Default is {}.
304308
num_iteration : int, optional
305309
The number of iterations for the SOM fitting.
306310
Default is 1000.
307311
normalize_data : bool, optional
308-
A flag to normalize the data. Default is False.
312+
A flag to normalize the data.
313+
If True, the data will be normalized using the custom_scale_factor.
314+
Default is False.
309315
"""
310316

311317
super().fit(
@@ -382,16 +388,22 @@ def fit_predict(
382388
data : pd.DataFrame
383389
The input data to be used for the SOM algorithm.
384390
directional_variables : List[str], optional
385-
A list of directional variables (will be transformed to u and v).
391+
A list of directional variables that will be transformed to u and v components.
392+
Then, to use custom_scale_factor, you must specify the variables names with the u and v suffixes.
393+
Example: directional_variables=["Dir"], custom_scale_factor={"Dir_u": [0, 1], "Dir_v": [0, 1]}.
386394
Default is [].
387395
custom_scale_factor : dict, optional
388396
A dictionary specifying custom scale factors for normalization.
397+
If normalize_data is True, this will be used to normalize the data.
398+
Example: {"Hs": [0, 10], "Tp": [0, 10]}.
389399
Default is {}.
390400
num_iteration : int, optional
391401
The number of iterations for the SOM fitting.
392402
Default is 1000.
393403
normalize_data : bool, optional
394-
A flag to normalize the data. Default is False.
404+
A flag to normalize the data.
405+
If True, the data will be normalized using the custom_scale_factor.
406+
Default is False.
395407
396408
Returns
397409
-------

0 commit comments

Comments
 (0)