From a554cdbb3ab69bb0f2c0d24e265962d6afb3cf9f Mon Sep 17 00:00:00 2001 From: steveyuwono Date: Sat, 25 May 2024 13:13:56 +0200 Subject: [PATCH 01/12] Wrapper CA: Management of new cluster property 'size' #19 --- src/mlpro_int_river/wrappers/clusteranalyzers/basics.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/mlpro_int_river/wrappers/clusteranalyzers/basics.py b/src/mlpro_int_river/wrappers/clusteranalyzers/basics.py index e9a4712..9562422 100644 --- a/src/mlpro_int_river/wrappers/clusteranalyzers/basics.py +++ b/src/mlpro_int_river/wrappers/clusteranalyzers/basics.py @@ -29,10 +29,11 @@ ## -- 2024-05-05 1.3.0 DA Alignment with MLPro 2 ## -- 2024-05-07 1.4.0 DA Separation of particular algorithms into separate modules ## -- 2024-05-24 1.5.0 DA Alignment with MLPro 2 +## -- 2024-05-25 1.5.1 SY Introduction of size as a property, Refactoring ## ------------------------------------------------------------------------------------------------- """ -Ver. 1.5.0 (2024-05-24) +Ver. 1.5.1 (2024-05-25) This module provides wrapper root classes from River to MLPro, specifically for cluster analyzers. @@ -88,7 +89,7 @@ class WrClusterAnalyzerRiver2MLPro (WrapperRiver, ClusterAnalyzer): C_TYPE = 'River Cluster Analyzer' - C_CLUSTER_PROPERTIES = [ cprop_centroid ] + C_CLUSTER_PROPERTIES = [ cprop_centroid, cprop_size ] ## ------------------------------------------------------------------------------------------------- def __init__( self, @@ -145,13 +146,13 @@ def _adapt(self, p_inst_new : Instance) -> bool: # update MLPro clusters from river self.get_clusters() - self._update_clusters() + self._update_clusters(input_data) return True ## ------------------------------------------------------------------------------------------------- - def _update_clusters(self): + def _update_clusters(self, input_data): """ This method is to update the centroids of each introduced cluster. """ From 207e4367705a3585ecfd50128c8bc8533d3fd904 Mon Sep 17 00:00:00 2001 From: steveyuwono Date: Sat, 25 May 2024 13:14:00 +0200 Subject: [PATCH 02/12] Wrapper CA: Management of new cluster property 'size' #19 --- .../wrappers/clusteranalyzers/clustream.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/mlpro_int_river/wrappers/clusteranalyzers/clustream.py b/src/mlpro_int_river/wrappers/clusteranalyzers/clustream.py index 29fdf0a..68c1dc5 100644 --- a/src/mlpro_int_river/wrappers/clusteranalyzers/clustream.py +++ b/src/mlpro_int_river/wrappers/clusteranalyzers/clustream.py @@ -28,10 +28,12 @@ ## -- 2024-04-30 1.2.0 DA Alignment with MLPro 2 ## -- 2024-05-05 1.3.0 DA Alignment with MLPro 2 ## -- 2024-05-07 1.4.0 DA Separated to own module +## -- 2024-05-25 1.4.1 SY Introduction of size as a property ## ------------------------------------------------------------------------------------------------- """ -Ver. 1.4.0 (2024-05-07) +Ver. 1.4.1 (2024-05-25) + This module provides a wrapper class for the CluStream algorithm provided by River. @@ -154,14 +156,23 @@ def __init__(self, ## ------------------------------------------------------------------------------------------------- - def _update_clusters(self): + def _update_clusters(self, input_data): """ This method is to update the centroids of each introduced cluster. """ + updated_cls = self._river_algo.predict_one(input_data) + for x in self._river_algo.centers.keys(): related_cluster = self._clusters[x] related_cluster.centroid.value = list(self._river_algo.centers[x].values()) + + if x == updated_cls: + act_size = related_cluster.size._get() + if act_size is not None: + related_cluster.size.set(act_size+1) + else: + related_cluster.size.set(1) ## ------------------------------------------------------------------------------------------------- @@ -180,7 +191,7 @@ def get_clusters(self) -> dict[Cluster]: try: related_cluster = self._clusters[x] except: - related_cluster = self._cls_cluster(p_id=x, p_visualize=self.get_visualization()) + related_cluster = self._cls_cluster(p_id=x, p_properties=self.C_CLUSTER_PROPERTIES, p_visualize=self.get_visualization()) if self.get_visualization(): related_cluster.init_plot(p_figure = self._figure, p_plot_settings=self._plot_settings) From c0fd035ca6d67e9d451ad073e945b4c77b2144c2 Mon Sep 17 00:00:00 2001 From: steveyuwono Date: Sat, 25 May 2024 13:14:03 +0200 Subject: [PATCH 03/12] Wrapper CA: Management of new cluster property 'size' #19 --- .../wrappers/clusteranalyzers/kmeans.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/mlpro_int_river/wrappers/clusteranalyzers/kmeans.py b/src/mlpro_int_river/wrappers/clusteranalyzers/kmeans.py index 69aeedb..3108352 100644 --- a/src/mlpro_int_river/wrappers/clusteranalyzers/kmeans.py +++ b/src/mlpro_int_river/wrappers/clusteranalyzers/kmeans.py @@ -28,10 +28,11 @@ ## -- 2024-04-30 1.2.0 DA Alignment with MLPro 2 ## -- 2024-05-05 1.3.0 DA Alignment with MLPro 2 ## -- 2024-05-07 1.4.0 DA Separated to own module +## -- 2024-05-25 1.4.1 SY Introduction of size as a property ## ------------------------------------------------------------------------------------------------- """ -Ver. 1.4.0 (2024-05-07) +Ver. 1.4.1 (2024-05-25) This module provides a wrapper class for the KMeans algorithm provided by River. @@ -133,16 +134,26 @@ def __init__(self, ## ------------------------------------------------------------------------------------------------- - def _update_clusters(self): + def _update_clusters(self, input_data): """ This method is to update the centroids of each introduced cluster. """ + + updated_cls = self._river_algo.predict_one(input_data) + for x in self._river_algo.centers.keys(): related_cluster = self._clusters[x] list_center = [] for y in range(len(self._river_algo.centers[x])): list_center.append(self._river_algo.centers[x][y+1]) related_cluster.centroid.value = list_center + + if x == updated_cls: + act_size = related_cluster.size._get() + if act_size is not None: + related_cluster.size.set(act_size+1) + else: + related_cluster.size.set(1) ## ------------------------------------------------------------------------------------------------- From 54a04ecce12e660c61a36309f20dc968dc2be67a Mon Sep 17 00:00:00 2001 From: steveyuwono Date: Sat, 25 May 2024 13:14:06 +0200 Subject: [PATCH 04/12] Wrapper CA: Management of new cluster property 'size' #19 --- .../wrappers/clusteranalyzers/streamkmeans.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/mlpro_int_river/wrappers/clusteranalyzers/streamkmeans.py b/src/mlpro_int_river/wrappers/clusteranalyzers/streamkmeans.py index db1fc57..b31b664 100644 --- a/src/mlpro_int_river/wrappers/clusteranalyzers/streamkmeans.py +++ b/src/mlpro_int_river/wrappers/clusteranalyzers/streamkmeans.py @@ -28,10 +28,11 @@ ## -- 2024-04-30 1.2.0 DA Alignment with MLPro 2 ## -- 2024-05-05 1.3.0 DA Alignment with MLPro 2 ## -- 2024-05-07 1.4.0 DA Separated to own module +## -- 2024-05-25 1.4.1 SY Introduction of size as a property ## ------------------------------------------------------------------------------------------------- """ -Ver. 1.4.0 (2024-05-07) +Ver. 1.4.1 (2024-05-25) This module provides a wrapper class for the STREAMKMeans algorithm provided by River. @@ -140,16 +141,25 @@ def __init__(self, ## ------------------------------------------------------------------------------------------------- - def _update_clusters(self): + def _update_clusters(self, input_data): """ This method is to update the centroids of each introduced cluster. """ + + updated_cls = self._river_algo.predict_one(input_data) + for x in self._river_algo.centers.keys(): try: related_cluster = self._clusters[x] list_center = [] for y in range(len(self._river_algo.centers[x])): list_center.append(self._river_algo.centers[x][y+1]) + if x == updated_cls: + act_size = related_cluster.size._get() + if act_size is not None: + related_cluster.size.set(act_size+1) + else: + related_cluster.size.set(1) try: related_cluster.centroid.value = list_center except: From 65f5ddc0c802855a4196f1a5503c8ec94b7772e3 Mon Sep 17 00:00:00 2001 From: steveyuwono Date: Sat, 25 May 2024 17:20:38 +0200 Subject: [PATCH 05/12] Wrapper CA: Management of new cluster property 'size' #19 --- .../wrappers/clusteranalyzers/dbstream.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/mlpro_int_river/wrappers/clusteranalyzers/dbstream.py b/src/mlpro_int_river/wrappers/clusteranalyzers/dbstream.py index e89ee33..f49d56b 100644 --- a/src/mlpro_int_river/wrappers/clusteranalyzers/dbstream.py +++ b/src/mlpro_int_river/wrappers/clusteranalyzers/dbstream.py @@ -28,10 +28,11 @@ ## -- 2024-04-30 1.2.0 DA Alignment with MLPro 2 ## -- 2024-05-05 1.3.0 DA Alignment with MLPro 2 ## -- 2024-05-07 1.4.0 DA Separated to own module +## -- 2024-05-25 1.4.1 SY Introduction of size as a property ## ------------------------------------------------------------------------------------------------- """ -Ver. 1.4.0 (2024-05-07) +Ver. 1.4.1 (2024-05-25) This module provides a wrapper class for the DBStream algorithm provided by River. @@ -105,8 +106,6 @@ class WrRiverDBStream2MLPro (WrClusterAnalyzerRiver2MLPro): C_TYPE = 'River Cluster Analyzer DBSTREAM' - C_CLUSTER_PROPERTIES = [ cprop_centroid ] - ## ------------------------------------------------------------------------------------------------- def __init__(self, p_name:str = None, @@ -138,14 +137,23 @@ def __init__(self, ## ------------------------------------------------------------------------------------------------- - def _update_clusters(self): + def _update_clusters(self, input_data): """ This method is to update the centroids of each introduced cluster. """ - for _, (key, val) in enumerate(self._river_algo.micro_clusters.items()): + updated_cls = self._river_algo.predict_one(input_data) + + for x, (key, val) in enumerate(self._river_algo.micro_clusters.items()): related_cluster = self._clusters[id(val)] related_cluster.centroid.value = list(self._river_algo.centers[key].values()) + + if x == updated_cls: + act_size = related_cluster.size._get() + if act_size is not None: + related_cluster.size.set(act_size+1) + else: + related_cluster.size.set(1) ## ------------------------------------------------------------------------------------------------- From 954469986838380e279c715dff35c10bfdddb73c Mon Sep 17 00:00:00 2001 From: steveyuwono Date: Sat, 25 May 2024 17:20:41 +0200 Subject: [PATCH 06/12] Wrapper CA: Management of new cluster property 'size' #19 --- .../wrappers/clusteranalyzers/denstream.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/mlpro_int_river/wrappers/clusteranalyzers/denstream.py b/src/mlpro_int_river/wrappers/clusteranalyzers/denstream.py index 5651575..53cfe69 100644 --- a/src/mlpro_int_river/wrappers/clusteranalyzers/denstream.py +++ b/src/mlpro_int_river/wrappers/clusteranalyzers/denstream.py @@ -28,10 +28,11 @@ ## -- 2024-04-30 1.2.0 DA Alignment with MLPro 2 ## -- 2024-05-05 1.3.0 DA Alignment with MLPro 2 ## -- 2024-05-07 1.4.0 DA Separated to own module +## -- 2024-05-25 1.4.1 SY Introduction of size as a property ## ------------------------------------------------------------------------------------------------- """ -Ver. 1.4.0 (2024-05-07) +Ver. 1.4.1 (2024-05-25) This module provides a wrapper class for the DenStream algorithm provided by River. @@ -142,21 +143,29 @@ def __init__(self, ## ------------------------------------------------------------------------------------------------- - def _update_clusters(self): + def _update_clusters(self, input_data): """ This method is to update the centroids of each introduced cluster. """ if self._river_algo.n_clusters != 0: + updated_cls = self._river_algo.predict_one(input_data) + for val in self._river_algo.p_micro_clusters.values(): related_cluster = self._clusters[id(val)] list_center = [] - for _, (_, val_center) in enumerate(val.x.items()): + for x, (_, val_center) in enumerate(val.x.items()): list_center.append(val_center) try: - related_cluster.centroid.value = list_center + related_cluster.centroid.value = list_center + if x == updated_cls: + act_size = related_cluster.size._get() + if act_size is not None: + related_cluster.size.set(act_size+1) + else: + related_cluster.size.set(1) except: pass From afc0e46eb3d689aa8caf82bca2a65f5f02783acb Mon Sep 17 00:00:00 2001 From: steveyuwono Date: Sat, 25 May 2024 17:20:48 +0200 Subject: [PATCH 07/12] Wrapper CA: Management of new cluster property 'size' #19 --- .../oa/howto_oa_wr_001_river_clusteranalyzer_dbstream.py | 8 +++++++- .../oa/howto_oa_wr_002_river_clusteranalyzer_clustream.py | 8 +++++++- .../oa/howto_oa_wr_003_river_clusteranalyzer_denstream.py | 8 +++++++- .../oa/howto_oa_wr_004_river_clusteranalyzer_kmeans.py | 8 +++++++- .../howto_oa_wr_005_river_clusteranalyzer_streamkmeans.py | 8 +++++++- 5 files changed, 35 insertions(+), 5 deletions(-) diff --git a/test/howtos/oa/howto_oa_wr_001_river_clusteranalyzer_dbstream.py b/test/howtos/oa/howto_oa_wr_001_river_clusteranalyzer_dbstream.py index f7281be..d2c3ac8 100644 --- a/test/howtos/oa/howto_oa_wr_001_river_clusteranalyzer_dbstream.py +++ b/test/howtos/oa/howto_oa_wr_001_river_clusteranalyzer_dbstream.py @@ -14,10 +14,11 @@ ## -- 2023-12-17 1.0.5 SY Refactoring unit test mode ## -- 2023-12-22 1.0.6 SY Refactoring ## -- 2024-04-30 1.1.0 DA Alignment with MLPro 2 +## -- 2024-05-25 1.1.1 SY Printing clusters' sizes ## ------------------------------------------------------------------------------------------------- """ -Ver. 1.1.0 (2024-04-30) +Ver. 1.1.1 (2024-05-25) This module demonstrates the principles of stream processing with MLPro. To this regard, a stream of a stream provider is combined with a stream workflow to a stream scenario. The workflow consists of @@ -185,6 +186,11 @@ def _setup(self, p_mode, p_ada: bool, p_visualize: bool, p_logging): for x in range(wr_n_clusters): if list(river_centers[x].values()) == list(myscenario.get_workflow()._tasks[0].get_clusters()[list_keys[x]].centroid.value): print("The center of cluster %s from river and mlpro matches!"%(x+1)) + cls_size = myscenario.get_workflow()._tasks[0].get_clusters()[list_keys[x]].size._get() + if cls_size is not None: + print("The size of cluster %s is %i"%(x+1,cls_size)) + else: + print("The size of cluster %s is 0"%(x+1)) else: print("The center of cluster %s from river and mlpro does not match!"%(x+1)) diff --git a/test/howtos/oa/howto_oa_wr_002_river_clusteranalyzer_clustream.py b/test/howtos/oa/howto_oa_wr_002_river_clusteranalyzer_clustream.py index f9faf34..cd33a38 100644 --- a/test/howtos/oa/howto_oa_wr_002_river_clusteranalyzer_clustream.py +++ b/test/howtos/oa/howto_oa_wr_002_river_clusteranalyzer_clustream.py @@ -11,10 +11,11 @@ ## -- 2023-12-17 1.0.2 SY Refactoring unit test mode ## -- 2023-12-22 1.0.3 SY Refactoring ## -- 2024-04-30 1.1.0 DA Alignment with MLPro 2 +## -- 2024-05-25 1.1.1 SY Printing clusters' sizes ## ------------------------------------------------------------------------------------------------- """ -Ver. 1.1.0 (2024-04-30) +Ver. 1.1.1 (2024-05-25) This module demonstrates the principles of stream processing with MLPro. To this regard, a stream of a stream provider is combined with a stream workflow to a stream scenario. The workflow consists of @@ -189,6 +190,11 @@ def _setup(self, p_mode, p_ada: bool, p_visualize: bool, p_logging): for x in range(wr_n_clusters): if list(river_centers[x].values()) == list(myscenario.get_workflow()._tasks[0].get_clusters()[x].centroid.value): print("The center of cluster %s from river and mlpro matches!"%(x+1)) + cls_size = myscenario.get_workflow()._tasks[0].get_clusters()[x].size._get() + if cls_size is not None: + print("The size of cluster %s is %i"%(x+1,cls_size)) + else: + print("The size of cluster %s is 0"%(x+1)) else: print("The center of cluster %s from river and mlpro does not match!"%(x+1)) diff --git a/test/howtos/oa/howto_oa_wr_003_river_clusteranalyzer_denstream.py b/test/howtos/oa/howto_oa_wr_003_river_clusteranalyzer_denstream.py index 9573a3b..d415832 100644 --- a/test/howtos/oa/howto_oa_wr_003_river_clusteranalyzer_denstream.py +++ b/test/howtos/oa/howto_oa_wr_003_river_clusteranalyzer_denstream.py @@ -12,10 +12,11 @@ ## -- 2023-12-22 1.0.3 SY Refactoring ## -- 2024-02-04 1.0.4 SY Refactoring ## -- 2024-04-30 1.1.0 DA Alignment with MLPro 2 +## -- 2024-05-25 1.1.1 SY Printing clusters' sizes ## ------------------------------------------------------------------------------------------------- """ -Ver. 1.1.0 (2024-04-30) +Ver. 1.1.1 (2024-05-25) This module demonstrates the principles of stream processing with MLPro. To this regard, a stream of a stream provider is combined with a stream workflow to a stream scenario. The workflow consists of @@ -193,6 +194,11 @@ def _setup(self, p_mode, p_ada: bool, p_visualize: bool, p_logging): for val in river_centers: if list(val.x.values()) == list(myscenario.get_workflow()._tasks[0].get_clusters()[id(val)].centroid.value): print("The center of cluster %s from river and mlpro matches!"%(id(val))) + cls_size = myscenario.get_workflow()._tasks[0].get_clusters()[id(val)].size._get() + if cls_size is not None: + print("The size of cluster %s is %i"%(id(val),cls_size)) + else: + print("The size of cluster %s is 0"%(id(val))) else: print("The center of cluster %s from river and mlpro does not match!"%(id(val) )) diff --git a/test/howtos/oa/howto_oa_wr_004_river_clusteranalyzer_kmeans.py b/test/howtos/oa/howto_oa_wr_004_river_clusteranalyzer_kmeans.py index cc682be..baf7a05 100644 --- a/test/howtos/oa/howto_oa_wr_004_river_clusteranalyzer_kmeans.py +++ b/test/howtos/oa/howto_oa_wr_004_river_clusteranalyzer_kmeans.py @@ -11,10 +11,11 @@ ## -- 2023-12-17 1.0.2 SY Refactoring unit test mode ## -- 2023-12-22 1.0.3 SY Refactoring ## -- 2024-04-30 1.1.0 DA Alignment with MLPro 2 +## -- 2024-05-25 1.1.1 SY Printing clusters' sizes ## ------------------------------------------------------------------------------------------------- """ -Ver. 1.1.0 (2024-04-30) +Ver. 1.1.1 (2024-05-25) This module demonstrates the principles of stream processing with MLPro. To this regard, a stream of a stream provider is combined with a stream workflow to a stream scenario. The workflow consists of @@ -187,6 +188,11 @@ def _setup(self, p_mode, p_ada: bool, p_visualize: bool, p_logging): for x in range(wr_n_clusters): if list(river_centers[x].values()) == list(myscenario.get_workflow()._tasks[0].get_clusters()[x].centroid.value): print("The center of cluster %s from river and mlpro matches!"%(x+1)) + cls_size = myscenario.get_workflow()._tasks[0].get_clusters()[x].size._get() + if cls_size is not None: + print("The size of cluster %s is %i"%(x+1,cls_size)) + else: + print("The size of cluster %s is 0"%(x+1)) else: print("The center of cluster %s from river and mlpro does not match!"%(x+1)) diff --git a/test/howtos/oa/howto_oa_wr_005_river_clusteranalyzer_streamkmeans.py b/test/howtos/oa/howto_oa_wr_005_river_clusteranalyzer_streamkmeans.py index 94030b5..6f9a828 100644 --- a/test/howtos/oa/howto_oa_wr_005_river_clusteranalyzer_streamkmeans.py +++ b/test/howtos/oa/howto_oa_wr_005_river_clusteranalyzer_streamkmeans.py @@ -11,10 +11,11 @@ ## -- 2023-12-17 1.0.2 SY Refactoring unit test mode ## -- 2023-12-22 1.0.3 SY Refactoring ## -- 2024-04-30 1.1.0 DA Alignment with MLPro 2 +## -- 2024-05-25 1.1.1 SY Printing clusters' sizes ## ------------------------------------------------------------------------------------------------- """ -Ver. 1.1.0 (2024-04-30) +Ver. 1.1.1 (2024-05-25) This module demonstrates the principles of stream processing with MLPro. To this regard, a stream of a stream provider is combined with a stream workflow to a stream scenario. The workflow consists of @@ -184,6 +185,11 @@ def _setup(self, p_mode, p_ada: bool, p_visualize: bool, p_logging): for x in range(wr_n_clusters): if list(river_centers[x].values()) == list(myscenario.get_workflow()._tasks[0].get_clusters()[x].centroid.value): print("The center of cluster %s from river and mlpro matches!"%(x+1)) + cls_size = myscenario.get_workflow()._tasks[0].get_clusters()[x].size._get() + if cls_size is not None: + print("The size of cluster %s is %i"%(x+1,cls_size)) + else: + print("The size of cluster %s is 0"%(x+1)) else: print("The center of cluster %s from river and mlpro does not match!"%(x+1)) From 3e5226f6ff8d77c60e7d28b45ee8d0140bca676f Mon Sep 17 00:00:00 2001 From: steveyuwono Date: Sun, 26 May 2024 19:17:13 +0200 Subject: [PATCH 08/12] OA-Streams: Introduction of Cluster's Size #22 --- src/mlpro_int_river/wrappers/clusteranalyzers/clustream.py | 6 +++--- src/mlpro_int_river/wrappers/clusteranalyzers/dbstream.py | 6 +++--- src/mlpro_int_river/wrappers/clusteranalyzers/denstream.py | 6 +++--- src/mlpro_int_river/wrappers/clusteranalyzers/kmeans.py | 6 +++--- .../wrappers/clusteranalyzers/streamkmeans.py | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/mlpro_int_river/wrappers/clusteranalyzers/clustream.py b/src/mlpro_int_river/wrappers/clusteranalyzers/clustream.py index 68c1dc5..f4650fb 100644 --- a/src/mlpro_int_river/wrappers/clusteranalyzers/clustream.py +++ b/src/mlpro_int_river/wrappers/clusteranalyzers/clustream.py @@ -168,11 +168,11 @@ def _update_clusters(self, input_data): related_cluster.centroid.value = list(self._river_algo.centers[x].values()) if x == updated_cls: - act_size = related_cluster.size._get() + act_size = related_cluster.size.value if act_size is not None: - related_cluster.size.set(act_size+1) + related_cluster.size.value = act_size+1 else: - related_cluster.size.set(1) + related_cluster.size.value = 1 ## ------------------------------------------------------------------------------------------------- diff --git a/src/mlpro_int_river/wrappers/clusteranalyzers/dbstream.py b/src/mlpro_int_river/wrappers/clusteranalyzers/dbstream.py index f49d56b..57d7866 100644 --- a/src/mlpro_int_river/wrappers/clusteranalyzers/dbstream.py +++ b/src/mlpro_int_river/wrappers/clusteranalyzers/dbstream.py @@ -149,11 +149,11 @@ def _update_clusters(self, input_data): related_cluster.centroid.value = list(self._river_algo.centers[key].values()) if x == updated_cls: - act_size = related_cluster.size._get() + act_size = related_cluster.size.value if act_size is not None: - related_cluster.size.set(act_size+1) + related_cluster.size.value = act_size+1 else: - related_cluster.size.set(1) + related_cluster.size.value = 1 ## ------------------------------------------------------------------------------------------------- diff --git a/src/mlpro_int_river/wrappers/clusteranalyzers/denstream.py b/src/mlpro_int_river/wrappers/clusteranalyzers/denstream.py index 53cfe69..6ffdd40 100644 --- a/src/mlpro_int_river/wrappers/clusteranalyzers/denstream.py +++ b/src/mlpro_int_river/wrappers/clusteranalyzers/denstream.py @@ -161,11 +161,11 @@ def _update_clusters(self, input_data): try: related_cluster.centroid.value = list_center if x == updated_cls: - act_size = related_cluster.size._get() + act_size = related_cluster.size.value if act_size is not None: - related_cluster.size.set(act_size+1) + related_cluster.size.value = act_size+1 else: - related_cluster.size.set(1) + related_cluster.size.value = 1 except: pass diff --git a/src/mlpro_int_river/wrappers/clusteranalyzers/kmeans.py b/src/mlpro_int_river/wrappers/clusteranalyzers/kmeans.py index 3108352..52d8a79 100644 --- a/src/mlpro_int_river/wrappers/clusteranalyzers/kmeans.py +++ b/src/mlpro_int_river/wrappers/clusteranalyzers/kmeans.py @@ -149,11 +149,11 @@ def _update_clusters(self, input_data): related_cluster.centroid.value = list_center if x == updated_cls: - act_size = related_cluster.size._get() + act_size = related_cluster.size.value if act_size is not None: - related_cluster.size.set(act_size+1) + related_cluster.size.value = act_size+1 else: - related_cluster.size.set(1) + related_cluster.size.value = 1 ## ------------------------------------------------------------------------------------------------- diff --git a/src/mlpro_int_river/wrappers/clusteranalyzers/streamkmeans.py b/src/mlpro_int_river/wrappers/clusteranalyzers/streamkmeans.py index b31b664..0c1be1a 100644 --- a/src/mlpro_int_river/wrappers/clusteranalyzers/streamkmeans.py +++ b/src/mlpro_int_river/wrappers/clusteranalyzers/streamkmeans.py @@ -155,11 +155,11 @@ def _update_clusters(self, input_data): for y in range(len(self._river_algo.centers[x])): list_center.append(self._river_algo.centers[x][y+1]) if x == updated_cls: - act_size = related_cluster.size._get() + act_size = related_cluster.size.value if act_size is not None: - related_cluster.size.set(act_size+1) + related_cluster.size.value = act_size+1 else: - related_cluster.size.set(1) + related_cluster.size.value = 1 try: related_cluster.centroid.value = list_center except: From 940cab38a3586430a0aa5a7886092737d0945796 Mon Sep 17 00:00:00 2001 From: steveyuwono Date: Sun, 26 May 2024 19:17:21 +0200 Subject: [PATCH 09/12] OA-Streams: Introduction of Cluster's Size #22 --- .../oa/howto_oa_wr_001_river_clusteranalyzer_dbstream.py | 2 +- .../oa/howto_oa_wr_002_river_clusteranalyzer_clustream.py | 2 +- .../oa/howto_oa_wr_003_river_clusteranalyzer_denstream.py | 5 ++--- .../oa/howto_oa_wr_004_river_clusteranalyzer_kmeans.py | 2 +- .../oa/howto_oa_wr_005_river_clusteranalyzer_streamkmeans.py | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/test/howtos/oa/howto_oa_wr_001_river_clusteranalyzer_dbstream.py b/test/howtos/oa/howto_oa_wr_001_river_clusteranalyzer_dbstream.py index d2c3ac8..561ca6d 100644 --- a/test/howtos/oa/howto_oa_wr_001_river_clusteranalyzer_dbstream.py +++ b/test/howtos/oa/howto_oa_wr_001_river_clusteranalyzer_dbstream.py @@ -186,7 +186,7 @@ def _setup(self, p_mode, p_ada: bool, p_visualize: bool, p_logging): for x in range(wr_n_clusters): if list(river_centers[x].values()) == list(myscenario.get_workflow()._tasks[0].get_clusters()[list_keys[x]].centroid.value): print("The center of cluster %s from river and mlpro matches!"%(x+1)) - cls_size = myscenario.get_workflow()._tasks[0].get_clusters()[list_keys[x]].size._get() + cls_size = myscenario.get_workflow()._tasks[0].get_clusters()[list_keys[x]].size.value if cls_size is not None: print("The size of cluster %s is %i"%(x+1,cls_size)) else: diff --git a/test/howtos/oa/howto_oa_wr_002_river_clusteranalyzer_clustream.py b/test/howtos/oa/howto_oa_wr_002_river_clusteranalyzer_clustream.py index cd33a38..b019a19 100644 --- a/test/howtos/oa/howto_oa_wr_002_river_clusteranalyzer_clustream.py +++ b/test/howtos/oa/howto_oa_wr_002_river_clusteranalyzer_clustream.py @@ -190,7 +190,7 @@ def _setup(self, p_mode, p_ada: bool, p_visualize: bool, p_logging): for x in range(wr_n_clusters): if list(river_centers[x].values()) == list(myscenario.get_workflow()._tasks[0].get_clusters()[x].centroid.value): print("The center of cluster %s from river and mlpro matches!"%(x+1)) - cls_size = myscenario.get_workflow()._tasks[0].get_clusters()[x].size._get() + cls_size = myscenario.get_workflow()._tasks[0].get_clusters()[x].size.value if cls_size is not None: print("The size of cluster %s is %i"%(x+1,cls_size)) else: diff --git a/test/howtos/oa/howto_oa_wr_003_river_clusteranalyzer_denstream.py b/test/howtos/oa/howto_oa_wr_003_river_clusteranalyzer_denstream.py index d415832..6159657 100644 --- a/test/howtos/oa/howto_oa_wr_003_river_clusteranalyzer_denstream.py +++ b/test/howtos/oa/howto_oa_wr_003_river_clusteranalyzer_denstream.py @@ -194,14 +194,13 @@ def _setup(self, p_mode, p_ada: bool, p_visualize: bool, p_logging): for val in river_centers: if list(val.x.values()) == list(myscenario.get_workflow()._tasks[0].get_clusters()[id(val)].centroid.value): print("The center of cluster %s from river and mlpro matches!"%(id(val))) - cls_size = myscenario.get_workflow()._tasks[0].get_clusters()[id(val)].size._get() + cls_size = myscenario.get_workflow()._tasks[0].get_clusters()[id(val)].size.value if cls_size is not None: print("The size of cluster %s is %i"%(id(val),cls_size)) else: print("The size of cluster %s is 0"%(id(val))) else: - print("The center of cluster %s from river and mlpro does not match!"%(id(val) - )) + print("The center of cluster %s from river and mlpro does not match!"%(id(val))) diff --git a/test/howtos/oa/howto_oa_wr_004_river_clusteranalyzer_kmeans.py b/test/howtos/oa/howto_oa_wr_004_river_clusteranalyzer_kmeans.py index baf7a05..1228d3e 100644 --- a/test/howtos/oa/howto_oa_wr_004_river_clusteranalyzer_kmeans.py +++ b/test/howtos/oa/howto_oa_wr_004_river_clusteranalyzer_kmeans.py @@ -188,7 +188,7 @@ def _setup(self, p_mode, p_ada: bool, p_visualize: bool, p_logging): for x in range(wr_n_clusters): if list(river_centers[x].values()) == list(myscenario.get_workflow()._tasks[0].get_clusters()[x].centroid.value): print("The center of cluster %s from river and mlpro matches!"%(x+1)) - cls_size = myscenario.get_workflow()._tasks[0].get_clusters()[x].size._get() + cls_size = myscenario.get_workflow()._tasks[0].get_clusters()[x].size.value if cls_size is not None: print("The size of cluster %s is %i"%(x+1,cls_size)) else: diff --git a/test/howtos/oa/howto_oa_wr_005_river_clusteranalyzer_streamkmeans.py b/test/howtos/oa/howto_oa_wr_005_river_clusteranalyzer_streamkmeans.py index 6f9a828..769fff2 100644 --- a/test/howtos/oa/howto_oa_wr_005_river_clusteranalyzer_streamkmeans.py +++ b/test/howtos/oa/howto_oa_wr_005_river_clusteranalyzer_streamkmeans.py @@ -185,7 +185,7 @@ def _setup(self, p_mode, p_ada: bool, p_visualize: bool, p_logging): for x in range(wr_n_clusters): if list(river_centers[x].values()) == list(myscenario.get_workflow()._tasks[0].get_clusters()[x].centroid.value): print("The center of cluster %s from river and mlpro matches!"%(x+1)) - cls_size = myscenario.get_workflow()._tasks[0].get_clusters()[x].size._get() + cls_size = myscenario.get_workflow()._tasks[0].get_clusters()[x].size.value if cls_size is not None: print("The size of cluster %s is %i"%(x+1,cls_size)) else: From 9b333a931e76e7475b05a3f132907f143ec1823f Mon Sep 17 00:00:00 2001 From: steveyuwono Date: Mon, 27 May 2024 11:08:45 +0200 Subject: [PATCH 10/12] OA-Streams: Introduction of Cluster's Size #22 --- test/howtos/oa/howto_oa_ca_001_run_kmeans_2d_static.py | 4 +++- test/howtos/oa/howto_oa_ca_002_run_kmeans_2d_dynamic.py | 4 +++- .../oa/howto_oa_ca_003_run_kmeans_2d_static_normalized.py | 4 +++- .../oa/howto_oa_ca_004_run_kmeans_2d_dynamic_normalized.py | 4 +++- test/howtos/oa/howto_oa_ca_005_run_kmeans_3d_static.py | 4 +++- test/howtos/oa/howto_oa_ca_006_run_kmeans_3d_dynamic.py | 4 +++- .../oa/howto_oa_ca_007_run_kmeans_3d_static_normalized.py | 4 +++- .../oa/howto_oa_ca_008_run_kmeans_3d_dynamic_normalized.py | 4 +++- 8 files changed, 24 insertions(+), 8 deletions(-) diff --git a/test/howtos/oa/howto_oa_ca_001_run_kmeans_2d_static.py b/test/howtos/oa/howto_oa_ca_001_run_kmeans_2d_static.py index 067eae5..c7c1b66 100644 --- a/test/howtos/oa/howto_oa_ca_001_run_kmeans_2d_static.py +++ b/test/howtos/oa/howto_oa_ca_001_run_kmeans_2d_static.py @@ -10,10 +10,11 @@ ## -- 2023-12-28 1.1.0 DA Exchange of benchmark stream and number of clouds ## -- 2024-04-30 1.2.0 DA Alignment with MLPro 2 ## -- 2024-05-05 1.3.0 DA Alignment with MLPro 2 +## -- 2024-05-27 1.3.1 SY Printing clusters' sizes ## ------------------------------------------------------------------------------------------------- """ -Ver. 1.3.0 (2024-05-05) +Ver. 1.3.1 (2024-05-27) This module demonstrates online cluster analysis of static 2D random point clouds using the wrapped River implementation of stream algorithm KMeans. To this regard, the systematics of sub-framework @@ -129,6 +130,7 @@ def _setup(self, p_mode, p_ada: bool, p_visualize: bool, p_logging): myscenario.log(Log.C_LOG_TYPE_I, 'Number of clusters: ', number_of_clusters) for x in range(number_of_clusters): myscenario.log(Log.C_LOG_TYPE_I, 'Center of Cluster ', str(x+1), ': ', list(clusters[x].centroid.value)) + myscenario.log(Log.C_LOG_TYPE_I, 'Size of Cluster ', str(x+1), ': ', clusters[x].size.value) myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') diff --git a/test/howtos/oa/howto_oa_ca_002_run_kmeans_2d_dynamic.py b/test/howtos/oa/howto_oa_ca_002_run_kmeans_2d_dynamic.py index cc2b692..876a19a 100644 --- a/test/howtos/oa/howto_oa_ca_002_run_kmeans_2d_dynamic.py +++ b/test/howtos/oa/howto_oa_ca_002_run_kmeans_2d_dynamic.py @@ -10,10 +10,11 @@ ## -- 2023-12-28 1.1.0 DA Exchange of benchmark stream and number of clouds ## -- 2024-01-05 1.1.1 SY Replace algorithm to StreamKMeans ## -- 2024-04-30 1.2.0 DA Alignment with MLPro 2 +## -- 2024-05-27 1.2.1 SY Printing clusters' sizes ## ------------------------------------------------------------------------------------------------- """ -Ver. 1.2.0 (2024-04-30) +Ver. 1.2.1 (2024-05-27) This module demonstrates online cluster analysis of dynamic 2D random point clouds using the wrapped River implementation of stream algorithm KMeans. To this regard, the systematics of sub-framework @@ -131,6 +132,7 @@ def _setup(self, p_mode, p_ada: bool, p_visualize: bool, p_logging): myscenario.log(Log.C_LOG_TYPE_I, 'Number of clusters: ', number_of_clusters) for x in range(number_of_clusters): myscenario.log(Log.C_LOG_TYPE_I, 'Center of Cluster ', str(x+1), ': ', list(clusters[x].centroid.value)) + myscenario.log(Log.C_LOG_TYPE_I, 'Size of Cluster ', str(x+1), ': ', clusters[x].size.value) myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') diff --git a/test/howtos/oa/howto_oa_ca_003_run_kmeans_2d_static_normalized.py b/test/howtos/oa/howto_oa_ca_003_run_kmeans_2d_static_normalized.py index bdc5fd0..3251311 100644 --- a/test/howtos/oa/howto_oa_ca_003_run_kmeans_2d_static_normalized.py +++ b/test/howtos/oa/howto_oa_ca_003_run_kmeans_2d_static_normalized.py @@ -14,10 +14,11 @@ ## -- 2023-12-21 1.1.1 SY Refactoring ## -- 2024-02-02 1.2.0 SY Parameters Optimization ## -- 2024-04-30 1.3.0 DA Alignment with MLPro 2 +## -- 2024-05-27 1.3.1 SY Printing clusters' sizes ## ------------------------------------------------------------------------------------------------- """ -Ver. 1.3.0 (2024-04-30) +Ver. 1.3.1 (2024-05-27) This module demonstrates online cluster analysis of normalized static 2D random point clouds using the wrapped River implementation of stream algorithm KMeans. To this regard, the systematics of sub-framework @@ -158,6 +159,7 @@ def _setup(self, p_mode, p_ada: bool, p_visualize: bool, p_logging): myscenario.log(Log.C_LOG_TYPE_I, 'Number of clusters: ', number_of_clusters) for x in range(number_of_clusters): myscenario.log(Log.C_LOG_TYPE_I, 'Center of Cluster ', str(x+1), ': ', list(clusters[x].centroid.value)) + myscenario.log(Log.C_LOG_TYPE_I, 'Size of Cluster ', str(x+1), ': ', clusters[x].size.value) myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') diff --git a/test/howtos/oa/howto_oa_ca_004_run_kmeans_2d_dynamic_normalized.py b/test/howtos/oa/howto_oa_ca_004_run_kmeans_2d_dynamic_normalized.py index 6456b16..af1f31f 100644 --- a/test/howtos/oa/howto_oa_ca_004_run_kmeans_2d_dynamic_normalized.py +++ b/test/howtos/oa/howto_oa_ca_004_run_kmeans_2d_dynamic_normalized.py @@ -12,10 +12,11 @@ ## -- - Add window to the workflow ## -- 2024-02-02 1.1.0 SY Parameters Optimization ## -- 2024-04-30 1.2.0 DA Alignment with MLPro 2 +## -- 2024-05-27 1.2.1 SY Printing clusters' sizes ## ------------------------------------------------------------------------------------------------- """ -Ver. 1.2.0 (2024-04-30) +Ver. 1.2.1 (2024-05-27) This module demonstrates online cluster analysis of normalized dynamic 2D random point clouds using the wrapped River implementation of stream algorithm KMeans. To this regard, the systematics of sub-framework @@ -165,6 +166,7 @@ def _setup(self, p_mode, p_ada: bool, p_visualize: bool, p_logging): myscenario.log(Log.C_LOG_TYPE_I, 'Number of clusters: ', number_of_clusters) for x in range(number_of_clusters): myscenario.log(Log.C_LOG_TYPE_I, 'Center of Cluster ', str(x+1), ': ', list(clusters[x].centroid.value)) + myscenario.log(Log.C_LOG_TYPE_I, 'Size of Cluster ', str(x+1), ': ', clusters[x].size.value) myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') diff --git a/test/howtos/oa/howto_oa_ca_005_run_kmeans_3d_static.py b/test/howtos/oa/howto_oa_ca_005_run_kmeans_3d_static.py index eb3d966..56adcc1 100644 --- a/test/howtos/oa/howto_oa_ca_005_run_kmeans_3d_static.py +++ b/test/howtos/oa/howto_oa_ca_005_run_kmeans_3d_static.py @@ -10,10 +10,11 @@ ## -- 2023-12-28 1.1.0 DA Exchange of benchmark stream and number of clouds ## -- 2023-12-29 1.2.0 DA Adjustments on cloud sizes and weights ## -- 2024-04-30 1.3.0 DA Alignment with MLPro 2 +## -- 2024-05-27 1.3.1 SY Printing clusters' sizes ## ------------------------------------------------------------------------------------------------- """ -Ver. 1.3.0 (2024-04-30) +Ver. 1.3.1 (2024-05-27) This module demonstrates online cluster analysis of static 3D random point clouds using the wrapped River implementation of stream algorithm KMeans. To this regard, the systematics of sub-framework @@ -132,6 +133,7 @@ def _setup(self, p_mode, p_ada: bool, p_visualize: bool, p_logging): myscenario.log(Log.C_LOG_TYPE_I, 'Number of clusters: ', number_of_clusters) for x in range(number_of_clusters): myscenario.log(Log.C_LOG_TYPE_I, 'Center of Cluster ', str(x+1), ': ', list(clusters[x].centroid.value)) + myscenario.log(Log.C_LOG_TYPE_I, 'Size of Cluster ', str(x+1), ': ', clusters[x].size.value) myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') diff --git a/test/howtos/oa/howto_oa_ca_006_run_kmeans_3d_dynamic.py b/test/howtos/oa/howto_oa_ca_006_run_kmeans_3d_dynamic.py index 2e416f2..bf2e07d 100644 --- a/test/howtos/oa/howto_oa_ca_006_run_kmeans_3d_dynamic.py +++ b/test/howtos/oa/howto_oa_ca_006_run_kmeans_3d_dynamic.py @@ -10,10 +10,11 @@ ## -- 2023-12-28 1.1.0 DA Exchange of benchmark stream and number of clouds ## -- 2024-01-05 1.1.1 SY Replace algorithm to StreamKMeans ## -- 2024-04-30 1.2.0 DA Alignment with MLPro 2 +## -- 2024-05-27 1.2.1 SY Printing clusters' sizes ## ------------------------------------------------------------------------------------------------- """ -Ver. 1.2.0 (2024-04-30) +Ver. 1.2.1 (2024-05-27) This module demonstrates online cluster analysis of dynamic 3D random point clouds using the wrapped River implementation of stream algorithm KMeans. To this regard, the systematics of sub-framework @@ -132,6 +133,7 @@ def _setup(self, p_mode, p_ada: bool, p_visualize: bool, p_logging): myscenario.log(Log.C_LOG_TYPE_I, 'Number of clusters: ', number_of_clusters) for x in range(number_of_clusters): myscenario.log(Log.C_LOG_TYPE_I, 'Center of Cluster ', str(x+1), ': ', list(clusters[x].centroid.value)) + myscenario.log(Log.C_LOG_TYPE_I, 'Size of Cluster ', str(x+1), ': ', clusters[x].size.value) myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') diff --git a/test/howtos/oa/howto_oa_ca_007_run_kmeans_3d_static_normalized.py b/test/howtos/oa/howto_oa_ca_007_run_kmeans_3d_static_normalized.py index d368107..6bf6936 100644 --- a/test/howtos/oa/howto_oa_ca_007_run_kmeans_3d_static_normalized.py +++ b/test/howtos/oa/howto_oa_ca_007_run_kmeans_3d_static_normalized.py @@ -14,10 +14,11 @@ ## -- 2023-12-21 1.1.1 SY Refactoring ## -- 2024-01-05 1.1.2 SY Updating KMeans parameters ## -- 2024-04-30 1.2.0 DA Alignment with MLPro 2 +## -- 2024-05-27 1.2.1 SY Printing clusters' sizes ## ------------------------------------------------------------------------------------------------- """ -Ver. 1.2.0 (2024-04-30) +Ver. 1.2.1 (2024-05-27) This module demonstrates online cluster analysis of normalized static 3D random point clouds using the wrapped River implementation of stream algorithm KMeans. To this regard, the systematics of sub-framework @@ -160,6 +161,7 @@ def _setup(self, p_mode, p_ada: bool, p_visualize: bool, p_logging): myscenario.log(Log.C_LOG_TYPE_I, 'Number of clusters: ', number_of_clusters) for x in range(number_of_clusters): myscenario.log(Log.C_LOG_TYPE_I, 'Center of Cluster ', str(x+1), ': ', list(clusters[x].centroid.value)) + myscenario.log(Log.C_LOG_TYPE_I, 'Size of Cluster ', str(x+1), ': ', clusters[x].size.value) myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') diff --git a/test/howtos/oa/howto_oa_ca_008_run_kmeans_3d_dynamic_normalized.py b/test/howtos/oa/howto_oa_ca_008_run_kmeans_3d_dynamic_normalized.py index f550cf2..c7757c8 100644 --- a/test/howtos/oa/howto_oa_ca_008_run_kmeans_3d_dynamic_normalized.py +++ b/test/howtos/oa/howto_oa_ca_008_run_kmeans_3d_dynamic_normalized.py @@ -14,10 +14,11 @@ ## -- 2023-12-21 1.1.1 SY Refactoring ## -- 2024-02-02 1.2.0 SY Parameters Optimization ## -- 2024-04-30 1.3.0 DA Alignment with MLPro 2 +## -- 2024-05-27 1.3.1 SY Printing clusters' sizes ## ------------------------------------------------------------------------------------------------- """ -Ver. 1.3.0 (2024-04-30) +Ver. 1.3.1 (2024-05-27) This module demonstrates online cluster analysis of normalized dynamic 3D random point clouds using the wrapped River implementation of stream algorithm KMeans. To this regard, the systematics of sub-framework @@ -159,6 +160,7 @@ def _setup(self, p_mode, p_ada: bool, p_visualize: bool, p_logging): myscenario.log(Log.C_LOG_TYPE_I, 'Number of clusters: ', number_of_clusters) for x in range(number_of_clusters): myscenario.log(Log.C_LOG_TYPE_I, 'Center of Cluster ', str(x+1), ': ', list(clusters[x].centroid.value)) + myscenario.log(Log.C_LOG_TYPE_I, 'Size of Cluster ', str(x+1), ': ', clusters[x].size.value) myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') From 8b17fe62b3727357b0b900d5d7c7c7b5ea61cca8 Mon Sep 17 00:00:00 2001 From: steveyuwono Date: Mon, 27 May 2024 11:09:02 +0200 Subject: [PATCH 11/12] OA-Streams: Introduction of Cluster's Size #22 --- test/howtos/oa/howto_oa_ca_011_run_streamkmeans_2d_static.py | 4 +++- test/howtos/oa/howto_oa_ca_012_run_streamkmeans_2d_dynamic.py | 4 +++- .../howto_oa_ca_013_run_streamkmeans_2d_static_normalized.py | 4 +++- .../howto_oa_ca_014_run_streamkmeans_2d_dynamic_normalized.py | 4 +++- test/howtos/oa/howto_oa_ca_015_run_streamkmeans_3d_static.py | 4 +++- test/howtos/oa/howto_oa_ca_016_run_streamkmeans_3d_dynamic.py | 4 +++- .../howto_oa_ca_017_run_streamkmeans_3d_static_normalized.py | 4 +++- .../howto_oa_ca_018_run_streamkmeans_3d_dynamic_normalized.py | 4 +++- 8 files changed, 24 insertions(+), 8 deletions(-) diff --git a/test/howtos/oa/howto_oa_ca_011_run_streamkmeans_2d_static.py b/test/howtos/oa/howto_oa_ca_011_run_streamkmeans_2d_static.py index f08513b..f7ab365 100644 --- a/test/howtos/oa/howto_oa_ca_011_run_streamkmeans_2d_static.py +++ b/test/howtos/oa/howto_oa_ca_011_run_streamkmeans_2d_static.py @@ -10,10 +10,11 @@ ## -- 2023-12-28 1.1.0 DA Exchange of benchmark stream and number of clouds ## -- 2024-02-23 1.1.1 SY Parameters Optimization ## -- 2024-04-30 1.2.0 DA Alignment with MLPro 2 +## -- 2024-05-27 1.2.1 SY Printing clusters' sizes ## ------------------------------------------------------------------------------------------------- """ -Ver. 1.2.0 (2024-04-30) +Ver. 1.2.1 (2024-05-27) This module demonstrates online cluster analysis of static 2D random point clouds using the wrapped River implementation of stream algorithm STREAMKMeans. To this regard, the systematics of sub-framework @@ -130,6 +131,7 @@ def _setup(self, p_mode, p_ada: bool, p_visualize: bool, p_logging): myscenario.log(Log.C_LOG_TYPE_I, 'Number of clusters: ', number_of_clusters) for x in range(number_of_clusters): myscenario.log(Log.C_LOG_TYPE_I, 'Center of Cluster ', str(x+1), ': ', list(clusters[x].centroid.value)) + myscenario.log(Log.C_LOG_TYPE_I, 'Size of Cluster ', str(x+1), ': ', clusters[x].size.value) myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') diff --git a/test/howtos/oa/howto_oa_ca_012_run_streamkmeans_2d_dynamic.py b/test/howtos/oa/howto_oa_ca_012_run_streamkmeans_2d_dynamic.py index 7102461..6238941 100644 --- a/test/howtos/oa/howto_oa_ca_012_run_streamkmeans_2d_dynamic.py +++ b/test/howtos/oa/howto_oa_ca_012_run_streamkmeans_2d_dynamic.py @@ -11,10 +11,11 @@ ## -- 2024-01-05 1.1.1 SY Replace algorithm to StreamKMeans ## -- 2024-02-23 1.1.2 SY Parameters Optimization ## -- 2024-04-30 1.2.0 DA Alignment with MLPro 2 +## -- 2024-05-27 1.2.1 SY Printing clusters' sizes ## ------------------------------------------------------------------------------------------------- """ -Ver. 1.2.0 (2024-04-30) +Ver. 1.2.1 (2024-05-27) This module demonstrates online cluster analysis of dynamic 2D random point clouds using the wrapped River implementation of stream algorithm STREAMKMeans. To this regard, the systematics of sub-framework @@ -132,6 +133,7 @@ def _setup(self, p_mode, p_ada: bool, p_visualize: bool, p_logging): myscenario.log(Log.C_LOG_TYPE_I, 'Number of clusters: ', number_of_clusters) for x in range(number_of_clusters): myscenario.log(Log.C_LOG_TYPE_I, 'Center of Cluster ', str(x+1), ': ', list(clusters[x].centroid.value)) + myscenario.log(Log.C_LOG_TYPE_I, 'Size of Cluster ', str(x+1), ': ', clusters[x].size.value) myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') diff --git a/test/howtos/oa/howto_oa_ca_013_run_streamkmeans_2d_static_normalized.py b/test/howtos/oa/howto_oa_ca_013_run_streamkmeans_2d_static_normalized.py index 18abfc3..d066e08 100644 --- a/test/howtos/oa/howto_oa_ca_013_run_streamkmeans_2d_static_normalized.py +++ b/test/howtos/oa/howto_oa_ca_013_run_streamkmeans_2d_static_normalized.py @@ -14,10 +14,11 @@ ## -- 2023-12-21 1.1.1 SY Refactoring ## -- 2024-02-23 1.1.2 SY Parameters Optimization ## -- 2024-04-30 1.2.0 DA Alignment with MLPro 2 +## -- 2024-05-27 1.2.1 SY Printing clusters' sizes ## ------------------------------------------------------------------------------------------------- """ -Ver. 1.2.0 (2024-04-30) +Ver. 1.2.1 (2024-05-27) This module demonstrates online cluster analysis of normalized static 2D random point clouds using the wrapped River implementation of stream algorithm STREAMKMeans. To this regard, the systematics of sub-framework @@ -160,6 +161,7 @@ def _setup(self, p_mode, p_ada: bool, p_visualize: bool, p_logging): myscenario.log(Log.C_LOG_TYPE_I, 'Number of clusters: ', number_of_clusters) for x in range(number_of_clusters): myscenario.log(Log.C_LOG_TYPE_I, 'Center of Cluster ', str(x+1), ': ', list(clusters[x].centroid.value)) + myscenario.log(Log.C_LOG_TYPE_I, 'Size of Cluster ', str(x+1), ': ', clusters[x].size.value) myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') diff --git a/test/howtos/oa/howto_oa_ca_014_run_streamkmeans_2d_dynamic_normalized.py b/test/howtos/oa/howto_oa_ca_014_run_streamkmeans_2d_dynamic_normalized.py index 7dcfc08..7940898 100644 --- a/test/howtos/oa/howto_oa_ca_014_run_streamkmeans_2d_dynamic_normalized.py +++ b/test/howtos/oa/howto_oa_ca_014_run_streamkmeans_2d_dynamic_normalized.py @@ -12,10 +12,11 @@ ## -- - Add window to the workflow ## -- 2024-02-23 1.0.3 SY Parameters Optimization ## -- 2024-04-30 1.1.0 DA Alignment with MLPro 2 +## -- 2024-05-27 1.1.1 SY Printing clusters' sizes ## ------------------------------------------------------------------------------------------------- """ -Ver. 1.1.0 (2024-04-30) +Ver. 1.1.1 (2024-05-27) This module demonstrates online cluster analysis of normalized dynamic 2D random point clouds using the wrapped River implementation of stream algorithm STREAMKMeans. To this regard, the systematics of sub-framework @@ -166,6 +167,7 @@ def _setup(self, p_mode, p_ada: bool, p_visualize: bool, p_logging): myscenario.log(Log.C_LOG_TYPE_I, 'Number of clusters: ', number_of_clusters) for x in range(number_of_clusters): myscenario.log(Log.C_LOG_TYPE_I, 'Center of Cluster ', str(x+1), ': ', list(clusters[x].centroid.value)) + myscenario.log(Log.C_LOG_TYPE_I, 'Size of Cluster ', str(x+1), ': ', clusters[x].size.value) myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') diff --git a/test/howtos/oa/howto_oa_ca_015_run_streamkmeans_3d_static.py b/test/howtos/oa/howto_oa_ca_015_run_streamkmeans_3d_static.py index 167e2c6..c418a57 100644 --- a/test/howtos/oa/howto_oa_ca_015_run_streamkmeans_3d_static.py +++ b/test/howtos/oa/howto_oa_ca_015_run_streamkmeans_3d_static.py @@ -11,10 +11,11 @@ ## -- 2023-12-29 1.2.0 DA Adjustments on cloud sizes and weights ## -- 2024-02-23 1.2.1 SY Parameters Optimization ## -- 2024-04-30 1.3.0 DA Alignment with MLPro 2 +## -- 2024-05-27 1.3.1 SY Printing clusters' sizes ## ------------------------------------------------------------------------------------------------- """ -Ver. 1.3.0 (2024-04-30) +Ver. 1.3.1 (2024-05-27) This module demonstrates online cluster analysis of static 3D random point clouds using the wrapped River implementation of stream algorithm STREAMKMeans. To this regard, the systematics of sub-framework @@ -133,6 +134,7 @@ def _setup(self, p_mode, p_ada: bool, p_visualize: bool, p_logging): myscenario.log(Log.C_LOG_TYPE_I, 'Number of clusters: ', number_of_clusters) for x in range(number_of_clusters): myscenario.log(Log.C_LOG_TYPE_I, 'Center of Cluster ', str(x+1), ': ', list(clusters[x].centroid.value)) + myscenario.log(Log.C_LOG_TYPE_I, 'Size of Cluster ', str(x+1), ': ', clusters[x].size.value) myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') diff --git a/test/howtos/oa/howto_oa_ca_016_run_streamkmeans_3d_dynamic.py b/test/howtos/oa/howto_oa_ca_016_run_streamkmeans_3d_dynamic.py index 6939392..4e1708d 100644 --- a/test/howtos/oa/howto_oa_ca_016_run_streamkmeans_3d_dynamic.py +++ b/test/howtos/oa/howto_oa_ca_016_run_streamkmeans_3d_dynamic.py @@ -11,10 +11,11 @@ ## -- 2024-01-05 1.1.1 SY Replace algorithm to StreamKMeans ## -- 2024-02-23 1.1.2 SY Parameters Optimization ## -- 2024-04-30 1.2.0 DA Alignment with MLPro 2 +## -- 2024-05-27 1.2.1 SY Printing clusters' sizes ## ------------------------------------------------------------------------------------------------- """ -Ver. 1.2.0 (2024-04-30) +Ver. 1.2.1 (2024-05-27) This module demonstrates online cluster analysis of dynamic 3D random point clouds using the wrapped River implementation of stream algorithm STREAMKMeans. To this regard, the systematics of sub-framework @@ -134,6 +135,7 @@ def _setup(self, p_mode, p_ada: bool, p_visualize: bool, p_logging): myscenario.log(Log.C_LOG_TYPE_I, 'Number of clusters: ', number_of_clusters) for x in range(number_of_clusters): myscenario.log(Log.C_LOG_TYPE_I, 'Center of Cluster ', str(x+1), ': ', list(clusters[x].centroid.value)) + myscenario.log(Log.C_LOG_TYPE_I, 'Size of Cluster ', str(x+1), ': ', clusters[x].size.value) myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') diff --git a/test/howtos/oa/howto_oa_ca_017_run_streamkmeans_3d_static_normalized.py b/test/howtos/oa/howto_oa_ca_017_run_streamkmeans_3d_static_normalized.py index 0fc67dc..fabc777 100644 --- a/test/howtos/oa/howto_oa_ca_017_run_streamkmeans_3d_static_normalized.py +++ b/test/howtos/oa/howto_oa_ca_017_run_streamkmeans_3d_static_normalized.py @@ -15,10 +15,11 @@ ## -- 2024-01-05 1.1.2 SY Updating KMeans parameters ## -- 2024-02-23 1.1.3 SY Parameters Optimization ## -- 2024-04-30 1.2.0 DA Alignment with MLPro 2 +## -- 2024-05-27 1.2.1 SY Printing clusters' sizes ## ------------------------------------------------------------------------------------------------- """ -Ver. 1.2.0 (2024-04-30) +Ver. 1.2.1 (2024-05-27) This module demonstrates online cluster analysis of normalized static 3D random point clouds using the wrapped River implementation of stream algorithm STREAMKMeans. To this regard, the systematics of sub-framework @@ -161,6 +162,7 @@ def _setup(self, p_mode, p_ada: bool, p_visualize: bool, p_logging): myscenario.log(Log.C_LOG_TYPE_I, 'Number of clusters: ', number_of_clusters) for x in range(number_of_clusters): myscenario.log(Log.C_LOG_TYPE_I, 'Center of Cluster ', str(x+1), ': ', list(clusters[x].centroid.value)) + myscenario.log(Log.C_LOG_TYPE_I, 'Size of Cluster ', str(x+1), ': ', clusters[x].size.value) myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') diff --git a/test/howtos/oa/howto_oa_ca_018_run_streamkmeans_3d_dynamic_normalized.py b/test/howtos/oa/howto_oa_ca_018_run_streamkmeans_3d_dynamic_normalized.py index 3943ebd..1f53345 100644 --- a/test/howtos/oa/howto_oa_ca_018_run_streamkmeans_3d_dynamic_normalized.py +++ b/test/howtos/oa/howto_oa_ca_018_run_streamkmeans_3d_dynamic_normalized.py @@ -14,10 +14,11 @@ ## -- 2023-12-21 1.1.1 SY Refactoring ## -- 2024-02-23 1.1.2 SY Parameters Optimization ## -- 2024-04-30 1.2.0 DA Alignment with MLPro 2 +## -- 2024-05-27 1.2.1 SY Printing clusters' sizes ## ------------------------------------------------------------------------------------------------- """ -Ver. 1.2.0 (2024-04-30) +Ver. 1.2.1 (2024-05-27) This module demonstrates online cluster analysis of normalized dynamic 3D random point clouds using the wrapped River implementation of stream algorithm STREAMKMeans. To this regard, the systematics of sub-framework @@ -159,6 +160,7 @@ def _setup(self, p_mode, p_ada: bool, p_visualize: bool, p_logging): myscenario.log(Log.C_LOG_TYPE_I, 'Number of clusters: ', number_of_clusters) for x in range(number_of_clusters): myscenario.log(Log.C_LOG_TYPE_I, 'Center of Cluster ', str(x+1), ': ', list(clusters[x].centroid.value)) + myscenario.log(Log.C_LOG_TYPE_I, 'Size of Cluster ', str(x+1), ': ', clusters[x].size.value) myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') From 336e2f8cfe6d49dae344f66527b84d04a8c51302 Mon Sep 17 00:00:00 2001 From: steveyuwono Date: Mon, 27 May 2024 11:09:07 +0200 Subject: [PATCH 12/12] OA-Streams: Introduction of Cluster's Size #22 --- test/howtos/oa/howto_oa_ca_021_run_clustream_2d_static.py | 4 +++- test/howtos/oa/howto_oa_ca_022_run_clustream_2d_dynamic.py | 4 +++- test/howtos/oa/howto_oa_ca_031_run_dbstream_2d_static.py.off | 4 +++- test/howtos/oa/howto_oa_ca_041_run_denstream_2d_static.py.off | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/test/howtos/oa/howto_oa_ca_021_run_clustream_2d_static.py b/test/howtos/oa/howto_oa_ca_021_run_clustream_2d_static.py index 38a2275..fd77395 100644 --- a/test/howtos/oa/howto_oa_ca_021_run_clustream_2d_static.py +++ b/test/howtos/oa/howto_oa_ca_021_run_clustream_2d_static.py @@ -8,10 +8,11 @@ ## -- 2024-02-09 0.0.0 SY Creation ## -- 2024-02-09 1.0.0 SY First version release ## -- 2024-04-30 1.1.0 DA Alignment with MLPro 2 +## -- 2024-05-27 1.1.1 SY Printing clusters' sizes ## ------------------------------------------------------------------------------------------------- """ -Ver. 1.1.0 (2024-04-30) +Ver. 1.1.1 (2024-05-27) This module demonstrates online cluster analysis of static 2D random point clouds using the wrapped River implementation of stream algorithm CluStream. To this regard, the systematics of sub-framework @@ -133,6 +134,7 @@ def _setup(self, p_mode, p_ada: bool, p_visualize: bool, p_logging): myscenario.log(Log.C_LOG_TYPE_I, 'Number of clusters: ', number_of_clusters) for x in range(number_of_clusters): myscenario.log(Log.C_LOG_TYPE_I, 'Center of Cluster ', str(x+1), ': ', list(clusters[x].centroid.value)) + myscenario.log(Log.C_LOG_TYPE_I, 'Size of Cluster ', str(x+1), ': ', clusters[x].size.value) myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') diff --git a/test/howtos/oa/howto_oa_ca_022_run_clustream_2d_dynamic.py b/test/howtos/oa/howto_oa_ca_022_run_clustream_2d_dynamic.py index 2ad3466..0a8ccbc 100644 --- a/test/howtos/oa/howto_oa_ca_022_run_clustream_2d_dynamic.py +++ b/test/howtos/oa/howto_oa_ca_022_run_clustream_2d_dynamic.py @@ -8,10 +8,11 @@ ## -- 2024-02-09 0.0.0 SY Creation ## -- 2024-02-09 1.0.0 SY First version release ## -- 2024-04-30 1.1.0 DA Alignment with MLPro 2 +## -- 2024-05-27 1.1.1 SY Printing clusters' sizes ## ------------------------------------------------------------------------------------------------- """ -Ver. 1.1.0 (2024-04-30) +Ver. 1.1.1 (2024-05-27) This module demonstrates online cluster analysis of dynamic 2D random point clouds using the wrapped River implementation of stream algorithm CluStream. To this regard, the systematics of sub-framework @@ -134,6 +135,7 @@ def _setup(self, p_mode, p_ada: bool, p_visualize: bool, p_logging): myscenario.log(Log.C_LOG_TYPE_I, 'Number of clusters: ', number_of_clusters) for x in range(number_of_clusters): myscenario.log(Log.C_LOG_TYPE_I, 'Center of Cluster ', str(x+1), ': ', list(clusters[x].centroid.value)) + myscenario.log(Log.C_LOG_TYPE_I, 'Size of Cluster ', str(x+1), ': ', clusters[x].size.value) myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') diff --git a/test/howtos/oa/howto_oa_ca_031_run_dbstream_2d_static.py.off b/test/howtos/oa/howto_oa_ca_031_run_dbstream_2d_static.py.off index 36b6226..0c21a17 100644 --- a/test/howtos/oa/howto_oa_ca_031_run_dbstream_2d_static.py.off +++ b/test/howtos/oa/howto_oa_ca_031_run_dbstream_2d_static.py.off @@ -8,10 +8,11 @@ ## -- 2024-02-23 0.0.0 SY Creation ## -- 2024-02-23 1.0.0 SY First version release ## -- 2024-04-30 1.1.0 DA Alignment with MLPro 2 +## -- 2024-05-27 1.1.1 SY Printing clusters' sizes ## ------------------------------------------------------------------------------------------------- """ -Ver. 1.1.0 (2024-04-30) +Ver. 1.1.1 (2024-05-27) This module demonstrates online cluster analysis of static 2D random point clouds using the wrapped River implementation of stream algorithm CluStream. To this regard, the systematics of sub-framework @@ -129,6 +130,7 @@ myscenario.log(Log.C_LOG_TYPE_I, 'Here is the recap of the cluster analyzer') myscenario.log(Log.C_LOG_TYPE_I, 'Number of clusters: ', number_of_clusters) for x in range(number_of_clusters): myscenario.log(Log.C_LOG_TYPE_I, 'Center of Cluster ', str(x+1), ': ', list(clusters[list_keys[x]].centroid.value)) + myscenario.log(Log.C_LOG_TYPE_I, 'Size of Cluster ', str(x+1), ': ', clusters[list_keys[x]].size.value) myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') diff --git a/test/howtos/oa/howto_oa_ca_041_run_denstream_2d_static.py.off b/test/howtos/oa/howto_oa_ca_041_run_denstream_2d_static.py.off index 6018bc8..f5e43d1 100644 --- a/test/howtos/oa/howto_oa_ca_041_run_denstream_2d_static.py.off +++ b/test/howtos/oa/howto_oa_ca_041_run_denstream_2d_static.py.off @@ -8,10 +8,11 @@ ## -- 2024-02-23 0.0.0 SY Creation ## -- 2024-02-23 1.0.0 SY First version release ## -- 2024-04-30 1.1.0 DA Alignment with MLPro 2 +## -- 2024-05-27 1.1.1 SY Printing clusters' sizes ## ------------------------------------------------------------------------------------------------- """ -Ver. 1.1.0 (2024-04-30) +Ver. 1.1.1 (2024-05-27) This module demonstrates online cluster analysis of static 2D random point clouds using the wrapped River implementation of stream algorithm CluStream. To this regard, the systematics of sub-framework @@ -129,6 +130,7 @@ myscenario.log(Log.C_LOG_TYPE_I, 'Here is the recap of the cluster analyzer') myscenario.log(Log.C_LOG_TYPE_I, 'Number of clusters: ', number_of_clusters) for x in range(number_of_clusters): myscenario.log(Log.C_LOG_TYPE_I, 'Center of Cluster ', str(x+1), ': ', list(clusters[x].centroid.value)) + myscenario.log(Log.C_LOG_TYPE_I, 'Size of Cluster ', str(x+1), ': ', clusters[x].size.value) myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------') myscenario.log(Log.C_LOG_TYPE_I, '-------------------------------------------------------')