Mercurial Hosting > traffic-intelligence
comparison scripts/learn-poi.py @ 916:7345f0d51faa
added display of paths
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Tue, 04 Jul 2017 17:36:24 -0400 |
parents | 13434f5017dd |
children | c030f735c594 |
comparison
equal
deleted
inserted
replaced
915:13434f5017dd | 916:7345f0d51faa |
---|---|
15 parser.add_argument('-norigins', dest = 'nOriginClusters', help = 'number of clusters for trajectory origins', required = True, type = int) | 15 parser.add_argument('-norigins', dest = 'nOriginClusters', help = 'number of clusters for trajectory origins', required = True, type = int) |
16 parser.add_argument('-ndestinations', dest = 'nDestinationClusters', help = 'number of clusters for trajectory destinations (=norigins if not provided)', type = int) | 16 parser.add_argument('-ndestinations', dest = 'nDestinationClusters', help = 'number of clusters for trajectory destinations (=norigins if not provided)', type = int) |
17 parser.add_argument('--covariance-type', dest = 'covarianceType', help = 'type of covariance of Gaussian model', default = "full") | 17 parser.add_argument('--covariance-type', dest = 'covarianceType', help = 'type of covariance of Gaussian model', default = "full") |
18 parser.add_argument('-w', dest = 'worldImageFilename', help = 'filename of the world image') | 18 parser.add_argument('-w', dest = 'worldImageFilename', help = 'filename of the world image') |
19 parser.add_argument('-u', dest = 'unitsPerPixel', help = 'number of units of distance per pixel', type = float, default = 1.) | 19 parser.add_argument('-u', dest = 'unitsPerPixel', help = 'number of units of distance per pixel', type = float, default = 1.) |
20 parser.add_argument('--display', dest = 'display', help = 'display points of interests', action = 'store_true') # default is manhattan distance | 20 parser.add_argument('--display', dest = 'display', help = 'displays points of interests', action = 'store_true') # default is manhattan distance |
21 parser.add_argument('--assign', dest = 'assign', help = 'display points of interests', action = 'store_true') | 21 parser.add_argument('--assign', dest = 'assign', help = 'assigns the trajectories to the POIs and saves the assignments', action = 'store_true') |
22 parser.add_argument('--display-paths', dest = 'displayPaths', help = 'displays all possible origin destination if assignment is done', action = 'store_true') | |
22 | 23 |
23 # TODO test Variational Bayesian Gaussian Mixture BayesianGaussianMixture | 24 # TODO test Variational Bayesian Gaussian Mixture BayesianGaussianMixture |
24 | 25 |
25 args = parser.parse_args() | 26 args = parser.parse_args() |
26 | 27 |
74 o.od[1] = l | 75 o.od[1] = l |
75 gmmId += 1 | 76 gmmId += 1 |
76 | 77 |
77 if args.assign: | 78 if args.assign: |
78 storage.savePOIAssignments(args.databaseFilename, objects) | 79 storage.savePOIAssignments(args.databaseFilename, objects) |
80 if args.displayPaths: | |
81 for i in xrange(args.nOriginClusters): | |
82 for j in xrange(args.nDestinationClusters): | |
83 odObjects = [o for o in objects if o.od[0] == i and o.od[1] == j] | |
84 if len(odObjects) > 0: | |
85 fig = plt.figure() | |
86 ax = fig.add_subplot(111) | |
87 ml.plotGMM(models['beginning'].means_[i], models['beginning'].covariances_[i], i, fig, 'b') | |
88 ml.plotGMM(models['end'].means_[j], models['end'].covariances_[j], j, fig, 'r') | |
89 for o in odObjects: | |
90 o.plot(withOrigin = True) | |
91 plt.title('OD {} to {}'.format(i,j)) | |
92 plt.axis('equal') | |
93 plt.show() | |
94 | |
79 | 95 |
80 if args.display: | 96 if args.display: |
81 plt.axis('equal') | 97 plt.axis('equal') |
82 plt.show() | 98 plt.show() |