Mercurial Hosting > traffic-intelligence
changeset 1204:a12d126346ff
merge
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Wed, 22 Mar 2023 22:01:12 -0400 |
parents | 7b3384a8e409 (current diff) 4356065ed3ca (diff) |
children | 3905b393ade0 |
files | trafficintelligence/storage.py |
diffstat | 3 files changed, 8 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/trafficintelligence/storage.py Wed Mar 22 15:40:33 2023 -0400 +++ b/trafficintelligence/storage.py Wed Mar 22 22:01:12 2023 -0400 @@ -756,7 +756,7 @@ 'weight': row[7], 'precisions': array(literal_eval(row[8]))}) if len(gmm) > 0: - tmp = mixture.GaussianMixture(len(gmm), covarianceType) + tmp = mixture.GaussianMixture(n_components=len(gmm), covariance_type=covarianceType) tmp.means_ = array([gaussian['mean'] for gaussian in gmm]) tmp.covariances_ = array([gaussian['covar'] for gaussian in gmm]) tmp.weights_ = array([gaussian['weight'] for gaussian in gmm])
--- a/trafficintelligence/tests/storage.txt Wed Mar 22 15:40:33 2023 -0400 +++ b/trafficintelligence/tests/storage.txt Wed Mar 22 22:01:12 2023 -0400 @@ -9,6 +9,7 @@ >>> nonexistentFilename = "nonexistent" >>> loadTrajectoriesFromSqlite(nonexistentFilename, 'feature') +Impossible to load from non-existing file nonexistent [] >>> o1 = MovingObject.generate(2, Point(0.,0.), Point(1.,0.), TimeInterval(0,10)) @@ -116,7 +117,7 @@ >>> from numpy.random import random_sample >>> nPoints = 50 >>> points = random_sample(nPoints*2).reshape(nPoints,2) ->>> gmm = GaussianMixture(4, covariance_type = 'full') +>>> gmm = GaussianMixture(n_components = 4, covariance_type = 'full') >>> tmp = gmm.fit(points) >>> gmmId = 0 >>> savePOIsToSqlite('pois-tmp.sqlite', gmm, 'end', gmmId)
--- a/trafficintelligence/utils.py Wed Mar 22 15:40:33 2023 -0400 +++ b/trafficintelligence/utils.py Wed Mar 22 22:01:12 2023 -0400 @@ -431,15 +431,13 @@ smoothed[point] = max(set(window_values), key=window_values.count) return smoothed -def filterMovingWindow(inputSignal, halfWidth): +def filterMovingWindow(inputSignal, halfWidth, mode = 'valid'): '''Returns an array obtained after the smoothing of the input by a moving average - The first and last points are copied from the original.''' - width = float(halfWidth*2+1) + The size of the output depends on the mode: 'full', 'same', 'valid' + See https://numpy.org/doc/stable/reference/generated/numpy.convolve.html.''' + width = min(len(inputSignal), int(halfWidth*2+1)) win = ones(width,'d') - result = convolve(win/width,array(inputSignal),'same') - result[:halfWidth] = inputSignal[:halfWidth] - result[-halfWidth:] = inputSignal[-halfWidth:] - return result + return convolve(win/width, array(inputSignal), mode) def linearRegression(x, y, deg = 1, plotData = False): '''returns the least square estimation of the linear regression of y = ax+b