基于分布的聚类(Distribution

您所在的位置:网站首页 spss群集成员 基于分布的聚类(Distribution

基于分布的聚类(Distribution

2023-10-29 22:43| 来源: 网络整理| 查看: 265

The clustering model most closely related to statistics is based on distribution models. Clusters can then easily be defined as objects belonging most likely to the same distribution. A convenient property of this approach is that this closely resembles the way artificial data sets are generated: by sampling random objects from a distribution. --wiki

在聚类模型中与统计学最相关的是基于分布的模型。然后可以将集群定义为最有可能属于同一分布的对象。这样做有一个好处就是,这与人工数据集的生成方式非常地相似,通过从分布中采样随机对象来进行。

上一期谈到的k-means聚类模型相对来说是比较简单和容易理解的。也正是因为这种简单,它在应用方面会面临一些挑战。尤其是,k均值的非概率性质及其使用简单的到集群中心距离来分配该集群成员的方法导致了k-means在现实应用场景中表现得很差。

例如,我们有一些简单的数据点,k-means算法可以快速地给那些聚类以某种方式分类,并且分类结果和我们肉眼判别的结果很接近:

%matplotlib inline import matplotlib.pyplot as plt import seaborn as sns; sns.set() import numpy as np #generate the same data from sklearn.datasets.samples_generator import make_blobs X, y_true = make_blobs(n_samples=400, centers=4, cluster_std=0.60, random_state=0) X = X[:, ::-1] # flip axes for better plotting # Plot the data with k-means labels from sklearn.cluster import KMeans kmeans = KMeans(4, random_state=0) labels = kmeans.fit(X).predict(X) plt.scatter(X[:, 0], X[:, 1], c=labels, s=40, cmap='viridis')

在这里插入图片描述 从直观上来看,我们可能期望有些点在分配给某一个聚类的时候,比其他的点要更确定一些,例如,在两个聚类中间的那些点在分类上会显得有些重叠。因此我们可能不能完全自信地确定分类那些点到附近的哪个类别中。而且,k-means模型没有内在的概率度量,或者,集群分配的不确定性。为此,我们必须考虑对模型进行泛化。

对于k-means模型的另外一种看待方式是,它放置一个圆(或者更高维度,一个超球体)在每个聚类的中心,其半径由集群中最远的点到这个聚类的中心。

在训练集中,该半径充当训练集中的聚类分配的硬截止(可以联想一下支持向量机SVM中的硬边界和软边界):该圆以外的任何点均不被视为集群的成员。我们可以使用以下函数可视化此集群模型。

from sklearn.cluster import KMeans from scipy.spatial.distance import cdist def plot_kmeans(kmeans, X, n_clusters=4, rseed=0, ax=None): labels = kmeans.fit_predict(X) # plot the input data ax = ax or plt.gca() ax.axis('equal') ax.scatter(X[:, 0], X[:, 1], c=labels, s=40, cmap='viridis', zorder=2) # plot the representation of the k-means model centers = kmeans.cluster_centers_ radii = [cdist


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3