diff python/tests/ml.txt @ 980:23f98ebb113f

first tests for clustering algo
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Mon, 19 Feb 2018 16:32:59 -0500
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/python/tests/ml.txt	Mon Feb 19 16:32:59 2018 -0500
@@ -0,0 +1,11 @@
+>>> from math import fabs
+>>> from numpy import ones
+>>> from ml import prototypeCluster
+
+>>> nTrajectories = 7
+>>> similarityFunc = lambda x, y: 1.-fabs(x-y)/(nTrajectories-1)
+>>> similarities = -ones((nTrajectories, nTrajectories))
+>>> prototypeIndices = prototypeCluster(range(nTrajectories), similarities, 1., similarityFunc, optimizeCentroid = True) # too large to be similar
+>>> len(prototypeIndices) == nTrajectories
+True
+>>> # could use lists to have a length