基于距离的聚类工具
yacluster的Python项目详细描述
yacluster是一个python库,它对二维点进行基于距离的聚类。官方只支持Python3.4+,不过其他版本也可以工作。该项目使用“语义版本控制”,并在“mit许可证”下获得许可。
usage
----
>主要实用程序是“y a cluster.cluster”函数,它接受两个参数:
*一个iterable,它生成两个元素点元组,每个元组包含:
-一个具有x和y坐标的两元素元组;
-实际的被聚集的对象(或其标识符);
*距离阈值;如果一个点被包含在一个簇中,它必须比这个值更接近它的质心。
*属于群集的对象列表。
群集的质心定义为群集成员的平均坐标。
示例
----
代码块:python
((1,1.0,“foo”),
((1.0,2,“bar”),
((2.0,2.0,“baz”),
((1.0,2.0,“baz”),
阈值=1.1
预期结果=[
((1.0,1.0,1.5),['foo”,“bar'],
((2.0,2.0,2.0),['baz']),
((2.0,2.0,2.0),['baz']),
,
]
assert expected_result==list(cluster(points,threshold))
development
----
开发需求列在``requirements development.txt``文件中。
要运行测试,请执行``./tests.py`。
_基于距离的集群:https://developers.google.com/maps/articles/toomanymarkers distance based clustering
。_ flake8 3.x:http://flake8.pycqa.org/en/latest/
。_语义版本控制:http://semver.org
…_麻省理工执照:执照
usage
----
>主要实用程序是“y a cluster.cluster”函数,它接受两个参数:
*一个iterable,它生成两个元素点元组,每个元组包含:
-一个具有x和y坐标的两元素元组;
-实际的被聚集的对象(或其标识符);
*距离阈值;如果一个点被包含在一个簇中,它必须比这个值更接近它的质心。
*属于群集的对象列表。
群集的质心定义为群集成员的平均坐标。
示例
----
代码块:python
((1,1.0,“foo”),
((1.0,2,“bar”),
((2.0,2.0,“baz”),
((1.0,2.0,“baz”),
阈值=1.1
预期结果=[
((1.0,1.0,1.5),['foo”,“bar'],
((2.0,2.0,2.0),['baz']),
((2.0,2.0,2.0),['baz']),
,
]
assert expected_result==list(cluster(points,threshold))
development
----
开发需求列在``requirements development.txt``文件中。
要运行测试,请执行``./tests.py`。
_基于距离的集群:https://developers.google.com/maps/articles/toomanymarkers distance based clustering
。_ flake8 3.x:http://flake8.pycqa.org/en/latest/
。_语义版本控制:http://semver.org
…_麻省理工执照:执照