- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- """
- Created on Thu Nov 2 18:38:32 2017
- @author: lu
- """
-
- import time
-
- import pandas as pd
- from sklearn.cluster import KMeans
- """
- programmer_1-->进行聚类离散化
- programmer_2-->None
- find_rule-->定义关联规则
- connect_string-->字符串连接
- """
-
-
- def programmer_1():
-
- datafile = "data/data.xls"
- processedfile = "tmp/data_processed.xls"
- typelabel = {
- u"肝气郁结证型系数": "A",
- u"热毒蕴结证型系数": "B",
- u"冲任失调证型系数": "C",
- u"气血两虚证型系数": "D",
- u"脾胃虚弱证型系数": "E",
- u"肝肾阴虚证型系数": "F",
- }
- k = 4
-
- data = pd.read_excel(datafile)
- result = pd.DataFrame()
-
- for key, item in typelabel.items():
- print(u"正在进行“%s”的聚类..." % key)
- # 进行聚类离散化
- kmodel = KMeans(n_clusters&#