百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
K

kmeans-clusterer

> 编程语言
开源

Ruby 中的 k-均值聚类

99 stars0 点赞3 次浏览
访问官网GitHub

工具介绍

Ruby 中的 k-均值聚类

KMeansClusterer

k-means clustering in Ruby. Uses NArray under the hood for fast calculations.

Jump to the examples directory to see this in action.

Features

  • Runs multiple clustering attempts to find optimal solution (single runs are susceptible to falling into non-optimal local minima)
  • Initializes centroids via k-means++ algorithm, for faster convergence
  • Calculates silhouette score for evaluation
  • Option to scale data before clustering, so that output isn't biased by different feature scales
  • Works with high-dimensional data

Install

gem install kmeans-clusterer

Usage

Simple example:

…

Output of simple example:

0. New York, Baltimore, Washington DC [39.63, -75.89]
1. Los Angeles, Portland, Las Vegas [38.56, -118.7]

Closest cluster to Chicago: 0

Silhouette score: 0.91

Options

The following options can be passed in to KMeansClusterer.run:

option default description
:labels nil optional array of Ruby objects to collate with data array
:runs 10 number of times to run kmeans
:log false print stats after each run
:init :kmpp algorithm for picking initial cluster centroids. Accepts :kmpp, :random, or an array of k centroids
:scale_data false scales features before clustering using formula (data - mean) / std
:float_precision :double float precision to use. :double or :single
:max_iter 300 max iterations per run

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rubyclusteringkmeans-clusteringrubyrubyml

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言