python中kmeans用的是什么距离_sklearn的kmeans使用的是哪种距离度量?

sklearn的dbscan等其他算法都会有一个metric参数来指定距离度量。

为什么kmeans没有这样的参数。

看了好久源码也没弄懂它默认的是哪种度量。

sklearn的源码如下:

class KMeans(BaseEstimator, ClusterMixin, TransformerMixin):

"""K-Means clustering

Read more in the :ref:`User Guide `.

Parameters

----------

n_clusters : int, optional, default: 8

The number of clusters to form as well as the number of

centroids to generate.

max_iter : int, default: 300

Maximum number of iterations of the k-means algorithm for a

single run.

n_init : int, default: 10

Number of time the k-means algorithm will be run with different

centroid seeds. The final results will be the best output of

n_init consecutive runs in terms of inertia.

init : {'k-means++', 'random' or an ndarray}

Method for initialization, defaults to 'k-means++':

'k-means++' : selects initial cluster centers for k-mean

clustering in a smart way to speed up convergence. See section

Notes in k_init for more details.

'random': choose k observations (rows) at random from data for

the initial centroids.

If an ndarray is passed, it should be of shape (n_clusters, n_features)

and gives the initial centers.

algorithm : "auto", "full" or "elkan", default="auto"

K-means algorithm to use. The classical EM-style algorithm is "full".

The "elkan" variation is more efficient by using the triangle

inequality, but currently doesn't support sparse data. "auto" chooses

"elkan" for dense data and "full" for sparse data.

precompute_distances : {'auto', True, False}

Precompute distances (faster but takes more memory).

'auto' : do not precompute distances if n_samples * n_clusters > 12

million. This corresponds to about 100MB overhead per job using

double precision.

True : always precompute distances<

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值