Mercurial Hosting > traffic-intelligence
diff python/ml.py @ 917:89cc05867c4c
reorg and work in progress
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Tue, 04 Jul 2017 18:00:01 -0400 |
parents | 7345f0d51faa |
children | d6c1c05d11f5 |
line wrap: on
line diff
--- a/python/ml.py Tue Jul 04 17:36:24 2017 -0400 +++ b/python/ml.py Tue Jul 04 18:00:01 2017 -0400 @@ -266,7 +266,7 @@ print('Mean overall similarity: {}'.format((similarities[cluster][:,cluster].sum()+n)/(n*(n-1)))) # Gaussian Mixture Models -def plotGMM(mean, covariance, num, fig, color, alpha = 0.3): +def plotGMM(mean, covariance, gmmId, fig, color, alpha = 0.3): v, w = np.linalg.eigh(covariance) angle = 180*np.arctan2(w[0][1], w[0][0])/np.pi v *= 4 @@ -275,7 +275,7 @@ ell.set_alpha(alpha) fig.axes[0].add_artist(ell) plt.plot([mean[0]], [mean[1]], 'x'+color) - plt.annotate(str(num), xy=(mean[0]+1, mean[1]+1)) + plt.annotate(str(gmmId), xy=(mean[0]+1, mean[1]+1)) def plotGMMClusters(model, labels = None, dataset = None, fig = None, colors = utils.colors, nUnitsPerPixel = 1., alpha = 0.3): '''plot the ellipse corresponding to the Gaussians