Mercurial > hg > nsaunier > traffic-intelligence
comparison trafficintelligence/tests/ml.txt @ 1028:cc5cb04b04b0
major update using the trafficintelligence package name and install through pip
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Fri, 15 Jun 2018 11:19:10 -0400 |
| parents | python/tests/ml.txt@23f98ebb113f |
| children | aafbc0bab925 |
comparison
equal
deleted
inserted
replaced
| 1027:6129296848d3 | 1028:cc5cb04b04b0 |
|---|---|
| 1 >>> from math import fabs | |
| 2 >>> from numpy import ones | |
| 3 >>> from ml import prototypeCluster | |
| 4 | |
| 5 >>> nTrajectories = 7 | |
| 6 >>> similarityFunc = lambda x, y: 1.-fabs(x-y)/(nTrajectories-1) | |
| 7 >>> similarities = -ones((nTrajectories, nTrajectories)) | |
| 8 >>> prototypeIndices = prototypeCluster(range(nTrajectories), similarities, 1., similarityFunc, optimizeCentroid = True) # too large to be similar | |
| 9 >>> len(prototypeIndices) == nTrajectories | |
| 10 True | |
| 11 >>> # could use lists to have a length |
