From 194802ac3791f0fe1656d021340ae79e2ec231f9 Mon Sep 17 00:00:00 2001 From: seungwook-kim-wizontech <100195254+seungwook-kim-wizontech@users.noreply.github.com> Date: Wed, 11 Oct 2023 14:42:42 +0900 Subject: [PATCH] Update interface.py --- clust/ML/clustering/interface.py | 60 ++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/clust/ML/clustering/interface.py b/clust/ML/clustering/interface.py index 40d3583..cad9062 100644 --- a/clust/ML/clustering/interface.py +++ b/clust/ML/clustering/interface.py @@ -85,4 +85,64 @@ def clusteringByMethod(data, parameter, model_path): return data_series, result, plt1 +def clusteringByCDM(data, parameter, model_path): + """ make clustering result of multiple dataset + + Retrieves rows pertaining to the given keys from the Table instance + represented by table_handle. String keys will be UTF-8 encoded. + + Args: + data (dataFrame): list of multiple dataframe inputs to be clustered (each column : individual data, index : time sequence data) + model(int): clust model name to be applied modelList = ['som'] + x(int): x length + y(int): y length + + Returns: + Dictionary: result (A dict mapping keys to the corresponding clustering result number) + + **Return Result Example**:: + + result = { b'ICW0W2000011': '5', + b'ICW0W2000013': '4', + b'ICW0W2000014': '6'... } + """ + + result = None + param = parameter['param'] + model_name = parameter['method'] + data_series = '' + if (len(data.columns) > 0): + # Train/Test 클래스 생성 + # 모델 저장/로드 경로 + if model_name == "som": + clust_train = SomTrain() + clust_train.set_param(param) + clust_test = SomTest() + elif model_name == "kmeans": + clust_train = KMeansTrain() + clust_train.set_param(param) + clust_test = KMeansTest() + + # 1. 데이터 준비 + data_series = DF_to_series(data) + + + # 2. Train + clust_train.set_param(param) + clust_train.train(data_series) + + # 3. model save + save_pickle_model(clust_train.model, model_path) + + # 4. model load + model = load_pickle_model(model_path) + + # 5. predict + clust_test.set_model(model) + result = clust_test.predict(data_series) + + else: + result = None + + return data_series, result