Clustering¶
Clustering module: ezdxf.math.clustering
- ezdxf.math.clustering.average_cluster_radius(clusters: list[list[Union[ezdxf.math._vector.Vec2, ezdxf.math._vector.Vec3]]]) float ¶
Returns the average cluster radius.
- ezdxf.math.clustering.average_intra_cluster_distance(clusters: list[list[Union[ezdxf.math._vector.Vec2, ezdxf.math._vector.Vec3]]]) float ¶
Returns the average point-to-point intra cluster distance.
- ezdxf.math.clustering.dbscan(points: list[Union[ezdxf.math._vector.Vec2, ezdxf.math._vector.Vec3]], *, radius: float, min_points: int = 4, rtree: Optional[RTree] = None, max_node_size: int = 5) list[list[Union[ezdxf.math._vector.Vec2, ezdxf.math._vector.Vec3]]] ¶
DBSCAN clustering.
https://en.wikipedia.org/wiki/DBSCAN
- Parameters
points – list of points to cluster
radius – radius of the dense regions
min_points – minimum number of points that needs to be within the radius for a point to be a core point (must be >= 2)
rtree – optional
RTree
max_node_size – max node size for internally created RTree
- Returns
list of clusters, each cluster is a list of points
- ezdxf.math.clustering.k_means(points: list[Union[ezdxf.math._vector.Vec2, ezdxf.math._vector.Vec3]], k: int, max_iter: int = 10) list[list[Union[ezdxf.math._vector.Vec2, ezdxf.math._vector.Vec3]]] ¶
K-means clustering.
https://en.wikipedia.org/wiki/K-means_clustering
- Parameters
points – list of points to cluster
k – number of clusters
max_iter – max iterations
- Returns
list of clusters, each cluster is a list of points