Skip to content

Commit

Permalink
Update interface.py
Browse files Browse the repository at this point in the history
  • Loading branch information
seungwook-kim-wizontech authored Oct 11, 2023
1 parent cd3e263 commit 194802a
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions clust/ML/clustering/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 194802a

Please sign in to comment.