-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdbscanCal.py
82 lines (68 loc) · 2 KB
/
dbscanCal.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
import sys
import time
import logging
import getopt
from util.dbscanPOI import DBScanPOI
def processTask(directory, clusterNum, eps, min_samples, msfile, msOptSubFix):
PROP = {
'clusterNum': clusterNum,
'IDIRECTORY': directory,
'ODIRECTORY': directory,
'msFile': msfile,
'msOptSubFix': msOptSubFix
}
task = DBScanPOI(PROP)
task.run(eps, min_samples)
def usage():
"""
使用说明函数
"""
print "python test.py -d /datasets -m 6 -e 0.01 -s 10 -f meanshiftResult_c12_t1_quan_0.020000_sam_500"
def main(argv):
"""
主入口函数
:param argv:
city 表示城市, directory 表示路径
eps, sample 分别为 DBScan 的两个入参
msfile 表示 meanshift 文件名
mstype 为 meanshift 聚类数据源类型,例如c12_t1
msopts 为 meanshift 参数设置拼接字符串,例如quan_0.020000_sam_500
"""
try:
argsArray = ["help", "city=", 'directory=', "msnum=", "eps=", "sample=", "msfile"]
opts, args = getopt.getopt(argv, "hc:d:m:e:s:f:", argsArray)
except getopt.GetoptError as err:
print str(err)
usage()
sys.exit(2)
city, directory = 'beijing', '/home/tao.jiang/datasets/JingJinJi/records'
msnum = 6
eps, min_samples = 0.01, 10
msfile = "meanshiftResult_c12_t1_quan_0.020000_sam_500"
msOptSubFix = "_c12_t1_quan_0.020000_sam_500"
for opt, arg in opts:
if opt == '-h':
usage()
sys.exit()
elif opt in ("-c", "--city"):
city = arg
elif opt in ("-d", "--directory"):
directory = arg
elif opt in ('-m', '--msnum'):
msnum = int(arg)
elif opt in ("-e", "--eps"):
eps = float(arg)
elif opt in ('-s', '--sample'):
min_samples = int(arg)
elif opt in ("-f", "--msfile"):
msfile = arg
STARTTIME = time.time()
print "%s: Start approach at %s" % (city, STARTTIME)
processTask(directory, msnum, eps, min_samples, msfile, msOptSubFix)
print "END TIME: %s" % time.time()
if __name__ == '__main__':
logging.basicConfig(filename='logger-dbscancal.log', level=logging.DEBUG)
main(sys.argv[1:])