forked from hcc226/UrbanMotionAnalysis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmeanshiftCal.py
More file actions
75 lines (60 loc) · 1.62 KB
/
meanshiftCal.py
File metadata and controls
75 lines (60 loc) · 1.62 KB
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
import sys
import time
import logging
import getopt
from util.meanshiftPOI import MeanshiftPOI
def processTask(mstype, directory, quantile, n_samples):
PROP = {
'mstype': mstype,
'IDIRECTORY': directory,
'ODIRECTORY': directory
}
task = MeanshiftPOI(PROP)
task.run(quantile, n_samples)
def usage():
"""
使用说明函数
"""
print "python test.py -d /datasets -t c12_t1 -q 0.2 -n 500"
def main(argv):
"""
主入口函数
:param argv:
city 表示城市, directory 表示路径
type 为 meanshift 聚类数据源类型
quantile, n_samples 分为别 Meanshift 两个入参
"""
try:
argsArray = ["help", "city=", 'directory=', "type=", "quantile=", "n_samples="]
opts, args = getopt.getopt(argv, "hc:d:t:q:n:", argsArray)
except getopt.GetoptError as err:
print str(err)
usage()
sys.exit(2)
city, directory = 'beijing', '/home/tao.jiang/datasets/JingJinJi/records'
mstype = 'c12_t1'
quantile, n_samples = 0.2, 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 ('-t', '--type'):
mstype = arg
elif opt in ("-q", "--quantile"):
quantile = float(arg)
elif opt in ('-n', '--n_samples'):
n_samples = int(arg)
STARTTIME = time.time()
print "%s: Start approach at %s" % (city, STARTTIME)
processTask(mstype, directory, quantile, n_samples)
print "END TIME: %s" % time.time()
if __name__ == '__main__':
logging.basicConfig(filename='logger-meanshiftcal.log', level=logging.DEBUG)
main(sys.argv[1:])