Mercurial Hosting > traffic-intelligence
annotate trafficintelligence/tests/ml.txt @ 1029:c6cf75a2ed08
reorganization of imports
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Mon, 18 Jun 2018 22:50:59 -0400 |
parents | cc5cb04b04b0 |
children | aafbc0bab925 |
rev | line source |
---|---|
980
23f98ebb113f
first tests for clustering algo
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
1 >>> from math import fabs |
23f98ebb113f
first tests for clustering algo
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
2 >>> from numpy import ones |
23f98ebb113f
first tests for clustering algo
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
3 >>> from ml import prototypeCluster |
23f98ebb113f
first tests for clustering algo
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
4 |
23f98ebb113f
first tests for clustering algo
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
5 >>> nTrajectories = 7 |
23f98ebb113f
first tests for clustering algo
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
6 >>> similarityFunc = lambda x, y: 1.-fabs(x-y)/(nTrajectories-1) |
23f98ebb113f
first tests for clustering algo
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
7 >>> similarities = -ones((nTrajectories, nTrajectories)) |
23f98ebb113f
first tests for clustering algo
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
8 >>> prototypeIndices = prototypeCluster(range(nTrajectories), similarities, 1., similarityFunc, optimizeCentroid = True) # too large to be similar |
23f98ebb113f
first tests for clustering algo
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
9 >>> len(prototypeIndices) == nTrajectories |
23f98ebb113f
first tests for clustering algo
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
10 True |
23f98ebb113f
first tests for clustering algo
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
11 >>> # could use lists to have a length |