def main(): config = read_config() dbc = DBScanner(config) data = get_data(config) dbc.dbscan(data)
def main(): config = {'eps': 2.5, 'min_pts': 2, 'dim': 2} dbc = DBScanner(config) data = get_data(config) dbc.dbscan(data)
def post(self): args = parser.parse_args() data = {'points': args['points']} def jsonTransformLib(s): return json.loads(str(s).replace("'", '"')) def libTransformDbScan(s): return dict(id = int(s['nro_oc']), value = [float(s['lat']), float(s['lng'])]) map_iterator = map(jsonTransformLib, data['points']) output_list = list(map_iterator) lib_iterator = map(libTransformDbScan, output_list) lib_list = list(lib_iterator) config = read_config() dbc = DBScanner(config) dbc.dbscan(lib_list) msg = dbc.getData() return msg, 201
def main(): config = read_config() dbc = DBScanner(config) data = get_data(config) print('data') print(data) dbc.dbscan(data) dbc.export()
config = {} try: with open(CONFIG, 'rb') as file_obj: for line in file_obj: if line[0] != '#' and line.strip() != '': key, value = line.split('=') if '.' in value.strip(): config[key.strip()] = float(value.strip()) else: config[key.strip()] = int(value.strip()) except: print("Error reading the configuration file.\ expected lines: param = value \n param = {eps, min_pts, dim}, \ value = {float, int, int}") sys.exit() return config if __name__ == "__main__": CONFIG = 'config.txt' DATA = 'data/abc.csv' # DATA = 'data/jain.csv' # DATA = 'data/dummy.csv' config = read_config() dbc = DBScanner(config) data = get_data(config) dbc.dbscan(data) dbc.export()
if __name__ == "__main__": # 参数初始化 min_pts = 4 # 最少有6个点 l = 4 slope = 0.1 filepath = 'abc.csv' data = readData(filepath) distanceMatrix = calDistanceMatrix(data) distanceList = getKdistance(min_pts, distanceMatrix) x = range(len(distanceList)) plt.figure() plt.plot(x, distanceList) #plt.show() epsCandidate = calEpsCandidate(distanceList, l, slope) while len(epsCandidate) == 0: l = input("请输入向前找的点数") slope = input("请输入期望的斜率阈值") epsCandidate = calEpsCandidate(distanceList, l, slope) # 现在参数确定了,min_pts还有eps已知,data已知,可以来DBSCAN聚类了 eps = epsCandidate[int(len(epsCandidate) / 2)] config = {'eps': eps, 'min_pts': min_pts, 'dim': 2} dbc = DBScanner(config) dbc.dbscan(data)