Skip to content

Commit

Permalink
improve (microsoft#340)
Browse files Browse the repository at this point in the history
* Update README.zh-cn.md

* Update README.zh-cn.md

* Update assignment.zh-cn.md

* Update README.zh-cn.md

* Update README.zh-cn.md

* Update README.ru.md

* Update README.it.md

* Update README.ko.md

* Update README.ko.md

* Update README.md

* Update README.zh-cn.md

* Update README.ko.md

* Update README.it.md

* Update README.md

* Update README.zh-cn.md
  • Loading branch information
ChungZH authored Sep 12, 2021
1 parent 5c181f3 commit f0eabb3
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 51 deletions.
29 changes: 16 additions & 13 deletions 5-Clustering/1-Visualize/translations/README.zh-cn.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# 介绍聚类

聚类是一种无监督学习,它假定数据集未标记或其输入与预定义的输出不匹配。它使用各种算法对未标记的数据进行排序,并根据它在数据中识别的模式提供分组。

[![No One Like You by PSquare](https://img.youtube.com/vi/ty2advRiWJM/0.jpg)](https://youtu.be/ty2advRiWJM "No One Like You by PSquare")

> 🎥 点击上面的图片观看视频。当您通过聚类学习机器学习时,请欣赏一些尼日利亚舞厅曲目 - 这是2014 年PSquare上高度评价的歌曲。
> 🎥 点击上面的图片观看视频。当您通过聚类学习机器学习时,请欣赏一些尼日利亚舞厅曲目 - 这是 2014 年 PSquare 上高度评价的歌曲。
## [课前测验](https://white-water-09ec41f0f.azurestaticapps.net/quiz/27/)

### 介绍

[聚类](https://link.springer.com/referenceworkentry/10.1007%2F978-0-387-30164-8_124)对于数据探索非常有用。让我们看看它是否有助于发现尼日利亚观众消费音乐的趋势和模式。
Expand All @@ -29,7 +32,7 @@

## 聚类入门

[Scikit-learn ](https://scikit-learn.org/stable/modules/clustering.html)提供了大量的方法来执行聚类。您选择的类型将取决于您的用例。根据文档,每种方法都有不同的好处。以下是 Scikit-learn 支持的方法及其适当用例的简化表:
[Scikit-learn](https://scikit-learn.org/stable/modules/clustering.html) 提供了大量的方法来执行聚类。您选择的类型将取决于您的用例。根据文档,每种方法都有不同的好处。以下是 Scikit-learn 支持的方法及其适当用例的简化表:

| 方法名称 | 用例 |
| ---------------------------- | -------------------------------------------------- |
Expand Down Expand Up @@ -83,13 +86,13 @@

![Hierarchical clustering Infographic](../images/hierarchical.png)

> [Dasani Madipalli ](https://twitter.com/dasani_decoded)作图
> [Dasani Madipalli](https://twitter.com/dasani_decoded) 作图
- **质心聚类**。这种流行的算法需要选择“k”或要形成的聚类数量,然后算法确定聚类的中心点并围绕该点收集数据。[K-means 聚类](https://wikipedia.org/wiki/K-means_clustering)是质心聚类的流行版本。中心由最近的平均值确定,因此叫做质心。与聚类的平方距离被最小化。

![Centroid clustering Infographic](../images/centroid.png)

> [Dasani Madipalli](https://twitter.com/dasani_decoded)作图
> [Dasani Madipalli](https://twitter.com/dasani_decoded) 作图
- **基于分布的聚类**。基于统计建模,基于分布的聚类中心确定一个数据点属于一个聚类的概率,并相应地分配它。高斯混合方法属于这种类型。

Expand All @@ -103,15 +106,15 @@

适当的可视化对聚类作为一种技术有很大帮助,所以让我们从可视化我们的音乐数据开始。这个练习将帮助我们决定我们应该最有效地使用哪种聚类方法来处理这些数据的性质。

1. 打开此文件夹中的*notebook.ipynb*文件。
1. 打开此文件夹中的 *notebook.ipynb* 文件。

1. 导入`Seaborn`包以获得良好的数据可视化。
1. 导入 `Seaborn` 包以获得良好的数据可视化。

```python
!pip install seaborn
```

1. 附加来自*nigerian-songs.csv*的歌曲数据。加载包含有关歌曲的一些数据的数据帧。准备好通过导入库和转储数据来探索这些数据:
1. 附加来自 *nigerian-songs.csv* 的歌曲数据。加载包含有关歌曲的一些数据的数据帧。准备好通过导入库和转储数据来探索这些数据:

```python
import matplotlib.pyplot as plt
Expand All @@ -131,7 +134,7 @@
| 3 | Confident / Feeling Cool | Enjoy Your Life | Lady Donli | nigerian pop | 2019 | 175135 | 14 | 0.894 | 0.798 | 0.611 | 0.000187 | 0.0964 | -4.961 | 0.113 | 111.087 | 4 |
| 4 | wanted you | rare. | Odunsi (The Engine) | afropop | 2018 | 152049 | 25 | 0.702 | 0.116 | 0.833 | 0.91 | 0.348 | -6.044 | 0.0447 | 105.115 | 4 |

1. 获取有关数据帧的一些信息,调用`info()`
1. 获取有关数据帧的一些信息,调用 `info()`

```python
df.info()
Expand Down Expand Up @@ -165,7 +168,7 @@
memory usage: 66.4+ KB
```

1. 通过调用`isnull()`和验证总和为 0 来仔细检查空值:
1. 通过调用 `isnull()` 和验证总和为 0 来仔细检查空值:

```python
df.isnull().sum()
Expand Down Expand Up @@ -243,11 +246,11 @@
plt.title('Top genres',color = 'blue')
```

现在重新检查genres
现在重新检查 genres

![most popular](../images/all-genres.png)

1. 到目前为止,前三大流派主导了这个数据集。让我们专注于`afro dancehall`, `afropop`, 和`nigerian pop`,另外过滤数据集以删除任何具有 0 流行度值的内容(这意味着它在数据集中没有被归类为流行度并且可以被视为我们的目的的噪音):
1. 到目前为止,前三大流派主导了这个数据集。让我们专注于 `afro dancehall``afropop``nigerian pop`,另外过滤数据集以删除任何具有 0 流行度值的内容(这意味着它在数据集中没有被归类为流行度并且可以被视为我们的目的的噪音):

```python
df = df[(df['artist_top_genre'] == 'afro dancehall') | (df['artist_top_genre'] == 'afropop') | (df['artist_top_genre'] == 'nigerian pop')]
Expand All @@ -269,13 +272,13 @@

![correlations](../images/correlation.png)

> 唯一强相关性是`energy`和之间`loudness`,这并不奇怪,因为嘈杂的音乐通常非常有活力。否则,相关性相对较弱。看看聚类算法可以如何处理这些数据会很有趣。
> 唯一强相关性是 `energy` 和之间 `loudness`,这并不奇怪,因为嘈杂的音乐通常非常有活力。否则,相关性相对较弱。看看聚类算法可以如何处理这些数据会很有趣。
>
> > 🎓请注意,相关性并不意味着因果关系!我们有相关性的证据,但没有因果关系的证据。一个[有趣的网站](https://tylervigen.com/spurious-correlations)有一些强调这一点的视觉效果。

这个数据集是否围绕歌曲的流行度和可舞性有任何收敛?FacetGrid 显示无论流派如何,都有同心圆排列。对于这种类型,尼日利亚人的口味是否会在某种程度的可舞性上趋于一致?

✅尝试不同的数据点(能量、响度、语音)和更多或不同的音乐类型。你能发现什么?查看`df.describe()`表格以了解数据点的一般分布。
尝试不同的数据点(能量、响度、语音)和更多或不同的音乐类型。你能发现什么?查看 `df.describe()` 表格以了解数据点的一般分布。

### 练习 - 数据分布

Expand Down
4 changes: 2 additions & 2 deletions 5-Clustering/1-Visualize/translations/assignment.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

## 说明

在本节课中,您使用了一些可视化技术来掌握绘制数据图,为聚类数据做准备。散点图在寻找一组对象时尤其有用。研究不同的方法和不同的库来创建散点图,并在notebook上记录你的工作。你可以使用这节课的数据,其他课的数据,或者你自己的数据(但是,请把它的来源记在你的notebook上)。用散点图绘制一些数据,并解释你的发现。
在本节课中,您使用了一些可视化技术来掌握绘制数据图,为聚类数据做准备。散点图在寻找一组对象时尤其有用。研究不同的方法和不同的库来创建散点图,并在 notebook 上记录你的工作。你可以使用这节课的数据,其他课的数据,或者你自己的数据但是,请把它的来源记在你的 notebook 上)。用散点图绘制一些数据,并解释你的发现。

## 评判规则


| 评判标准 | 优秀 | 中规中矩 | 仍需努力 |
| -------- | -------------------------------- | ----------------------------------------------- | -------------------- |
| | notebook上有五个详细文档的散点图 | notebook上的散点图少于5个,而且文档写得不太详细 | 一个不完整的notebook |
| | notebook 上有五个详细文档的散点图 | notebook 上的散点图少于 5 个,而且文档写得不太详细 | 一个不完整的 notebook |

2 changes: 1 addition & 1 deletion 5-Clustering/2-K-Means/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ Hint: Try to scale your data. There's commented code in the notebook that adds s

Take a look at a K-Means Simulator [such as this one](https://user.ceng.metu.edu.tr/~akifakkus/courses/ceng574/k-means/). You can use this tool to visualize sample data points and determine its centroids. You can edit the data's randomness, numbers of clusters and numbers of centroids. Does this help you get an idea of how the data can be grouped?

Also, take a look at [this handout on k-means](https://stanford.edu/~cpiech/cs221/handouts/kmeans.html) from Stanford.
Also, take a look at [this handout on K-Means](https://stanford.edu/~cpiech/cs221/handouts/kmeans.html) from Stanford.

## Assignment

Expand Down
2 changes: 1 addition & 1 deletion 5-Clustering/2-K-Means/translations/README.it.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ Suggerimento: provare a ridimensionare i dati. C'è un codice commentato nel not

Dare un'occhiata a un simulatore di K-Means [tipo questo](https://user.ceng.metu.edu.tr/~akifakkus/courses/ceng574/k-means/). È possibile utilizzare questo strumento per visualizzare i punti dati di esempio e determinarne i centroidi. Questo aiuta a farsi un'idea di come i dati possono essere raggruppati?

Inoltre, dare un'occhiata a [questa dispensa sui k-means](https://stanford.edu/~cpiech/cs221/handouts/kmeans.html) di Stanford.
Inoltre, dare un'occhiata a [questa dispensa sui K-Means](https://stanford.edu/~cpiech/cs221/handouts/kmeans.html) di Stanford.

## Compito

Expand Down
2 changes: 1 addition & 1 deletion 5-Clustering/2-K-Means/translations/README.ko.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ Variance는 "the average of the squared differences from the Mean."으로 정의

[such as this one](https://user.ceng.metu.edu.tr/~akifakkus/courses/ceng574/k-means/)같은 K-Means 시뮬레이터를 찾아봅니다. 이 도구로 샘플 데이터 포인트를 시각화하고 무게 중심을 결정할 수 있습니다. 데이터의 랜덤성, 클러스터 수와 무게 중심 수를 고칠 수 있습니다. 데이터를 그룹으로 묶기 위한 아이디어를 얻는 게 도움이 되나요?

또한, Stanford의 [this handout on k-means](https://stanford.edu/~cpiech/cs221/handouts/kmeans.html)을 찾아봅니다.
또한, Stanford 의 [this handout on K-Means](https://stanford.edu/~cpiech/cs221/handouts/kmeans.html) 을 찾아봅니다.

## 과제

Expand Down
28 changes: 14 additions & 14 deletions 5-Clustering/2-K-Means/translations/README.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

## 介绍

[K-Means Clustering](https://wikipedia.org/wiki/K-means_clustering)是一种源自信号处理领域的方法。它用于使用一系列观察将数据组划分和划分为“k”个聚类。每个观察都用于对最接近其最近“平均值”或聚类中心点的给定数据点进行分组。
[K-Means Clustering](https://wikipedia.org/wiki/K-means_clustering) 是一种源自信号处理领域的方法。它用于使用一系列观察将数据组划分和划分为“k”个聚类。每个观察都用于对最接近其最近“平均值”或聚类中心点的给定数据点进行分组。

聚类可以可视化为[Voronoi 图](https://wikipedia.org/wiki/Voronoi_diagram),其中包括一个点(或“种子”)及其相应的区域。
聚类可以可视化为 [Voronoi 图](https://wikipedia.org/wiki/Voronoi_diagram),其中包括一个点(或“种子”)及其相应的区域。

![voronoi diagram](../images/voronoi.png)

Expand All @@ -36,13 +36,13 @@ K-Means 聚类过程[分三步执行](https://scikit-learn.org/stable/modules/cl

## 前置条件

您将使用本课的*notebook.ipynb*文件,其中包含您在上一课中所做的数据导入和初步清理。
您将使用本课的 *notebook.ipynb* 文件,其中包含您在上一课中所做的数据导入和初步清理。

## 练习 - 准备

首先再看看歌曲数据。

1. 创建一个箱线图,`boxplot()`为每一列调用:
1. 创建一个箱线图,`boxplot()` 为每一列调用:

```python
plt.figure(figsize=(20,20), dpi=200)
Expand Down Expand Up @@ -90,7 +90,7 @@ K-Means 聚类过程[分三步执行](https://scikit-learn.org/stable/modules/cl

您可以浏览数据集并删除这些异常值,但这会使数据非常少。

1. 现在,选择您将用于聚类练习的列。选择具有相似范围的那些并将`artist_top_genre`列编码为数字类型的数据:
1. 现在,选择您将用于聚类练习的列。选择具有相似范围的那些并将 `artist_top_genre` 列编码为数字类型的数据:

```python
from sklearn.preprocessing import LabelEncoder
Expand Down Expand Up @@ -136,11 +136,11 @@ K-Means 聚类过程[分三步执行](https://scikit-learn.org/stable/modules/cl

寻找接近 1 的轮廓分数。该分数从 -11 不等,如果分数为 1,则该聚类密集且与其他聚类分离良好。接近 0 的值表示重叠聚类,样本非常接近相邻聚类的决策边界。[来源](https://dzone.com/articles/kmeans-silhouette-score-explained-with-python-exam)。

我们的分数是**0.53**,所以正好在中间。这表明我们的数据不是特别适合这种类型的聚类,但让我们继续。
我们的分数是 **0.53**,所以正好在中间。这表明我们的数据不是特别适合这种类型的聚类,但让我们继续。

### 练习 - 建立模型

1. 导入`KMeans`并启动聚类过程。
1. 导入 `KMeans` 并启动聚类过程。

```python
from sklearn.cluster import KMeans
Expand All @@ -157,17 +157,17 @@ K-Means 聚类过程[分三步执行](https://scikit-learn.org/stable/modules/cl

> 🎓 range:这些是聚类过程的迭代

> 🎓random_state:“确定质心初始化的随机数生成。” [来源](https://scikit-learn.org/stable/modules/generated/sklearn.cluster.KMeans.html#sklearn.cluster.KMeans)
> 🎓 random_state:“确定质心初始化的随机数生成。” [来源](https://scikit-learn.org/stable/modules/generated/sklearn.cluster.KMeans.html#sklearn.cluster.KMeans)

> 🎓WCSS:“聚类内平方和”测量聚类内所有点到聚类质心的平方平均距离。[来源](https://medium.com/@ODSC/unsupervised-learning-evaluating-clusters-bd47eed175ce)。
> 🎓 WCSS:“聚类内平方和”测量聚类内所有点到聚类质心的平方平均距离。[来源](https://medium.com/@ODSC/unsupervised-learning-evaluating-clusters-bd47eed175ce)。

> 🎓Inertia:K-Means 算法尝试选择质心以最小化“惯性”,“惯性是衡量内部相干程度的一种方法”。[来源](https://scikit-learn.org/stable/modules/clustering.html)。该值在每次迭代时附加到 wcss 变量。
> 🎓 Inertia:K-Means 算法尝试选择质心以最小化“惯性”,“惯性是衡量内部相干程度的一种方法”。[来源](https://scikit-learn.org/stable/modules/clustering.html)。该值在每次迭代时附加到 wcss 变量。

> 🎓k-means++:在[Scikit-learn 中,](https://scikit-learn.org/stable/modules/clustering.html#k-means)您可以使用“k-means++”优化,它“将质心初始化为(通常)彼此远离,导致可能比随机初始化更好的结果。
> 🎓 k-means++:在 [Scikit-learn 中,](https://scikit-learn.org/stable/modules/clustering.html#k-means)您可以使用“k-means++”优化,它“将质心初始化为(通常)彼此远离,导致可能比随机初始化更好的结果。

### 手肘方法

之前,您推测,因为您已经定位了 3 个歌曲genre,所以您应该选择 3 个聚类。但真的是这样吗?
之前,您推测,因为您已经定位了 3 个歌曲 genre,所以您应该选择 3 个聚类。但真的是这样吗?

1. 使用手肘方法来确认。

Expand All @@ -180,7 +180,7 @@ K-Means 聚类过程[分三步执行](https://scikit-learn.org/stable/modules/cl
plt.show()
```

使用`wcss`您在上一步中构建的变量创建一个图表,显示肘部“弯曲”的位置,这表示最佳聚类数。也许****3
使用 `wcss` 您在上一步中构建的变量创建一个图表,显示肘部“弯曲”的位置,这表示最佳聚类数。也许**** 3

![elbow method](../images/elbow.png)

Expand Down Expand Up @@ -245,7 +245,7 @@ K-Means 聚类过程[分三步执行](https://scikit-learn.org/stable/modules/cl

看看[像这样](https://user.ceng.metu.edu.tr/~akifakkus/courses/ceng574/k-means/)的 K-Means 模拟器。您可以使用此工具来可视化样本数据点并确定其质心。您可以编辑数据的随机性、聚类数和质心数。这是否有助于您了解如何对数据进行分组?

另外,看看斯坦福大学的[k-means 讲义](https://stanford.edu/~cpiech/cs221/handouts/kmeans.html)。
另外,看看斯坦福大学的 [K-Means 讲义](https://stanford.edu/~cpiech/cs221/handouts/kmeans.html)。

## 作业

Expand Down
6 changes: 4 additions & 2 deletions 5-Clustering/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,21 @@ Nigeria's diverse audience has diverse musical tastes. Using data scraped from S

![A turntable](./images/turntable.jpg)

Photo by <a href="https://unsplash.com/@marcelalaskoski?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Marcela Laskoski</a> on <a href="https://unsplash.com/s/photos/nigerian-music?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>
> Photo by <a href="https://unsplash.com/@marcelalaskoski?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Marcela Laskoski</a> on <a href="https://unsplash.com/s/photos/nigerian-music?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>
In this series of lessons, you will discover new ways to analyze data using clustering techniques. Clustering is particularly useful when your dataset lacks labels. If it does have labels, then classification techniques such as those you learned in previous lessons might be more useful. But in cases where you are looking to group unlabelled data, clustering is a great way to discover patterns.

> There are useful low-code tools that can help you learn about working with clustering models. Try [Azure ML for this task](https://docs.microsoft.com/learn/modules/create-clustering-model-azure-machine-learning-designer/?WT.mc_id=academic-15963-cxa)
## Lessons

1. [Introduction to clustering](1-Visualize/README.md)
2. [K-Means clustering](2-K-Means/README.md)

## Credits

These lessons were written with 🎶 by [Jen Looper](https://www.twitter.com/jenlooper) with helpful reviews by [Rishit Dagli](https://rishit_dagli) and [Muhammad Sakib Khan Inan](https://twitter.com/Sakibinan).

The [Nigerian Songs](https://www.kaggle.com/sootersaalu/nigerian-songs-spotify) dataset was sourced from Kaggle as scraped from Spotify.

Useful K-Means examples that aided in creating this lesson include this [iris exploration](https://www.kaggle.com/bburns/iris-exploration-pca-k-means-and-gmm-clustering), this [introductory notebook](https://www.kaggle.com/prashant111/k-means-clustering-with-python), and this [hypothetical NGO example](https://www.kaggle.com/ankandash/pca-k-means-clustering-hierarchical-clustering).
Useful K-Means examples that aided in creating this lesson include this [iris exploration](https://www.kaggle.com/bburns/iris-exploration-pca-k-means-and-gmm-clustering), this [introductory notebook](https://www.kaggle.com/prashant111/k-means-clustering-with-python), and this [hypothetical NGO example](https://www.kaggle.com/ankandash/pca-k-means-clustering-hierarchical-clustering).
Loading

0 comments on commit f0eabb3

Please sign in to comment.