未验证 提交 f817acee 编写于 作者: L loopyme 提交者: GitHub

Merge pull request #348 from loopyme/master

更新调整1,2章
......@@ -18,7 +18,6 @@
* 便于理解和解释。树的结构可以可视化出来。
* 训练需要的数据少。其他机器学习模型通常需要数据规范化,比如构建虚拟变量和移除缺失值,不过请注意,这种模型不支持缺失值。
>
* 由于训练决策树的数据点的数量导致了决策树的使用开销呈指数分布(训练树模型的时间复杂度是参与训练数据点的对数值)。
* 能够处理数值型数据和分类数据。其他的技术通常只能用来专门分析某一种变量类型的数据集。详情请参阅算法。
* 能够处理多路输出的问题。
......
......@@ -12,7 +12,7 @@
        [@文谊](https://github.com/apachecn/scikit-learn-doc-zh)
        [@t9UhoI](https://github.com/apachecn/scikit-learn-doc-zh)
`注意,在本文中 bagging 和 boosting 为了更好的保留原文意图,不进行翻译` `estimator:估计器  base estimator:基估计器`
>注意:在本文中 bagging 和 boosting 为了更好的保留原文意图,不进行翻译```estimator:估计器  base estimator:基估计器```
**集成方法** 的目标是把多个使用给定学习算法构建的基估计器的预测结果结合起来,从而获得比单个估计器更好的泛化能力/鲁棒性。
......
......@@ -3,34 +3,21 @@
校验者:
        [@溪流-十四号](https://github.com/apachecn/scikit-learn-doc-zh)
        [@大魔王飞仙](https://github.com/apachecn/scikit-learn-doc-zh)
[@Loopy](https://github.com/loopyme)
翻译者:
        [@v](https://github.com/apachecn/scikit-learn-doc-zh)
Warning
All classifiers in scikit-learn do multiclass classification out-of-the-box. You don’t need to use the [`sklearn.multiclass`](classes.html#module-sklearn.multiclass "sklearn.multiclass") module unless you want to experiment with different multiclass strategies.
> **警告** scikit-learn中的所有分类器都可以开箱即用进行多类分类。除非您想尝试不同的多类策略,否则无需使用[`sklearn.multiclass`](classes.html#module-sklearn.multiclass "sklearn.multiclass")模块。
[`sklearn.multiclass`](classes.html#module-sklearn.multiclass "sklearn.multiclass") 模块采用了 _元评估器_ ,通过把``多类```多标签` 分类问题分解为 二元分类问题去解决。这同样适用于多目标回归问题。
* **Multiclass classification** **多类分类** 意味着一个分类任务需要对多于两个类的数据进行分类。比如,对一系列的橘子,
苹果或者梨的图片进行分类。多类分类假设每一个样本有且仅有一个标签:一个水果可以被归类为苹果,也可以 是梨,但不能同时被归类为两类。
* **Multilabel classification** **多标签分类** 给每一个样本分配一系列标签。这可以被认为是预测不
相互排斥的数据点的属性,例如与文档类型相关的主题。一个文本可以归类为任意类别,例如可以同时为政治、金融、 教育相关或者不属于以上任何类别。
* **Multioutput regression** **多输出分类** 为每个样本分配一组目标值。这可以认为是预测每一个样本的多个属性,
比如说一个具体地点的风的方向和大小。
* **Multiclass classification** **多类分类** 意味着一个分类任务需要对多于两个类的数据进行分类。比如,对一系列的橘子,苹果或者梨的图片进行分类。多类分类假设每一个样本有且仅有一个标签:一个水果可以被归类为苹果,也可以 是梨,但不能同时被归类为两类。
* **Multioutput-multiclass classification** and **multi-task classification** [**](#id2)多输出-多类分类和
* **Multilabel classification** **多标签分类** 给每一个样本分配一系列标签。这可以被认为是预测不相互排斥的数据点的属性,例如与文档类型相关的主题。一个文本可以归类为任意类别,例如可以同时为政治、金融、 教育相关或者不属于以上任何类别。
```py
多任务分类** 意味着单个的评估器要解决多个联合的分类任务这是只考虑二分类的 multi-label classification
```
* **Multioutput regression** **多输出分类** 为每个样本分配一组目标值。这可以认为是预测每一个样本的多个属性,比如说一个具体地点的风的方向和大小。
> 和 multi-class classification 任务的推广。 _此类问题输出的格式是一个二维数组或者一个稀疏矩阵。_
* **Multioutput-multiclass classification** and **multi-task classification** **多输出-多类分类和多任务分类** 意味着单个的评估器要解决多个联合的分类任务。这是只考虑二分类的 multi-label classification 和 multi-class classification 任务的推广。 *此类问题输出的格式是一个二维数组或者一个稀疏矩阵*
每个输出变量的标签集合可以是各不相同的。比如说,一个样本可以将“梨”作为一个输出变量的值,这个输出变 量在一个含有“梨”、“苹果”等水果种类的有限集合中取可能的值;将“蓝色”或者“绿色”作为第二个输出变量的值, 这个输出变量在一个含有“绿色”、“红色”、“蓝色”等颜色种类的有限集合中取可能的值…
......@@ -90,9 +77,7 @@ All classifiers in scikit-learn do multiclass classification out-of-the-box. You
* [`sklearn.neighbors.RadiusNeighborsClassifier`](https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.RadiusNeighborsClassifier.html#sklearn.neighbors.RadiusNeighborsClassifier "sklearn.neighbors.RadiusNeighborsClassifier")
* [`sklearn.ensemble.RandomForestClassifier`](https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestClassifier.html#sklearn.ensemble.RandomForestClassifier "sklearn.ensemble.RandomForestClassifier")
Warning
At present, no metric in [`sklearn.metrics`](classes.html#module-sklearn.metrics "sklearn.metrics") supports the multioutput-multiclass classification task.
>**警告**:目前,[`sklearn.metrics`](classes.html#module-sklearn.metrics "sklearn.metrics")中没有评估方法能够支持多输出多类分类任务。
## 1.12.1\. 多标签分类格式
......@@ -105,10 +90,10 @@ At present, no metric in [`sklearn.metrics`](classes.html#module-sklearn.metrics
>>> y = [[2, 3, 4], [2], [0, 1, 3], [0, 1, 2, 3, 4], [0, 1, 2]]
>>> MultiLabelBinarizer().fit_transform(y)
array([[0, 0, 1, 1, 1],
[0, 0, 1, 0, 0],
[1, 1, 0, 1, 0],
[1, 1, 1, 1, 1],
[1, 1, 1, 0, 0]])
[0, 0, 1, 0, 0],
[1, 1, 0, 1, 0],
[1, 1, 1, 1, 1],
[1, 1, 1, 0, 0]])
```
......@@ -128,12 +113,12 @@ array([[0, 0, 1, 1, 1],
>>> X, y = iris.data, iris.target
>>> OneVsRestClassifier(LinearSVC(random_state=0)).fit(X, y).predict(X)
array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2])
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2])
```
......@@ -143,9 +128,8 @@ array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
[![http://sklearn.apachecn.org/cn/0.19.0/_images/sphx_glr_plot_multilabel_0011.png](img/2e06713c93719ff874fb9f4fab7a6fbf.jpg)](https://scikit-learn.org/stable/auto_examples/plot_multilabel.html)
示例:
* [Multilabel classification](https://scikit-learn.org/stable/auto_examples/plot_multilabel.html#sphx-glr-auto-examples-plot-multilabel-py)
>示例:
>* [Multilabel classification](https://scikit-learn.org/stable/auto_examples/plot_multilabel.html#sphx-glr-auto-examples-plot-multilabel-py)
## 1.12.3\. 1对1
......@@ -155,7 +139,7 @@ array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
### 1.12.3.1\. 多类别学习
Below is an example of multiclass learning using OvO:
下面是一个使用OvO进行多类别学习的例子:
```py
>>> from sklearn import datasets
......@@ -165,18 +149,17 @@ Below is an example of multiclass learning using OvO:
>>> X, y = iris.data, iris.target
>>> OneVsOneClassifier(LinearSVC(random_state=0)).fit(X, y).predict(X)
array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2])
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2])
```
参考文献:
* “Pattern Recognition and Machine Learning. Springer”, Christopher M. Bishop, page 183, (First Edition)
>参考文献:
>* “Pattern Recognition and Machine Learning. Springer”, Christopher M. Bishop, page 183, (First Edition)
## 1.12.4\. 误差校正输出代码
......@@ -192,7 +175,7 @@ array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
### 1.12.4.1\. 多类别学习
Below is an example of multiclass learning using Output-Codes:
下面是一个使用Output-Codes进行多类别学习的例子:
```py
>>> from sklearn import datasets
......@@ -213,13 +196,10 @@ array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
```
参考文献:
* “Solving multiclass learning problems via error-correcting output codes”, Dietterich T., Bakiri G., Journal of Artificial Intelligence Research 2, 1995.
| [[3]](#id11) | “The error coding method and PICTs”, James G., Hastie T., Journal of Computational and Graphical statistics 7, 1998. |
* “The Elements of Statistical Learning”, Hastie T., Tibshirani R., Friedman J., page 606 (second-edition) 2008.
>参考文献:
>* “Solving multiclass learning problems via error-correcting output codes”, Dietterich T., Bakiri G., Journal of Artificial Intelligence Research 2, 1995.
>* [3] “The error coding method and PICTs”, James G., Hastie T., Journal of Computational and Graphical statistics 7, 1998.
>* “The Elements of Statistical Learning”, Hastie T., Tibshirani R., Friedman J., page 606 (second-edition) 2008.
## 1.12.5\. 多输出回归
......@@ -234,15 +214,15 @@ array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
>>> X, y = make_regression(n_samples=10, n_targets=3, random_state=1)
>>> MultiOutputRegressor(GradientBoostingRegressor(random_state=0)).fit(X, y).predict(X)
array([[-154.75474165, -147.03498585, -50.03812219],
[ 7.12165031, 5.12914884, -81.46081961],
[-187.8948621 , -100.44373091, 13.88978285],
[-141.62745778, 95.02891072, -191.48204257],
[ 97.03260883, 165.34867495, 139.52003279],
[ 123.92529176, 21.25719016, -7.84253 ],
[-122.25193977, -85.16443186, -107.12274212],
[ -30.170388 , -94.80956739, 12.16979946],
[ 140.72667194, 176.50941682, -17.50447799],
[ 149.37967282, -81.15699552, -5.72850319]])
[ 7.12165031, 5.12914884, -81.46081961],
[-187.8948621 , -100.44373091, 13.88978285],
[-141.62745778, 95.02891072, -191.48204257],
[ 97.03260883, 165.34867495, 139.52003279],
[ 123.92529176, 21.25719016, -7.84253 ],
[-122.25193977, -85.16443186, -107.12274212],
[ -30.170388 , -94.80956739, 12.16979946],
[ 140.72667194, 176.50941682, -17.50447799],
[ 149.37967282, -81.15699552, -5.72850319]])
```
......@@ -269,15 +249,15 @@ Multioutput classification 支持能够被添加到任何带有 `MultiOutputClas
>>> multi_target_forest = MultiOutputClassifier(forest, n_jobs=-1)
>>> multi_target_forest.fit(X, Y).predict(X)
array([[2, 2, 0],
[1, 2, 1],
[2, 1, 0],
[0, 0, 2],
[0, 2, 1],
[0, 0, 2],
[1, 1, 0],
[1, 1, 1],
[0, 0, 2],
[2, 0, 0]])
[1, 2, 1],
[2, 1, 0],
[0, 0, 2],
[0, 2, 1],
[0, 0, 2],
[1, 1, 0],
[1, 1, 1],
[0, 0, 2],
[2, 0, 0]])
```
......@@ -291,10 +271,5 @@ Classifier chains (查看 `ClassifierChain`) 是一种集合多个二分类器
很明显,链的顺序是十分重要的。链上的第一个模型没有关于其他标签的信息,而链上的最后一个模型将会具有所有其他标签的信息。 在一般情况下,我们并不知道链上模型最优的顺序,因此通常会使用许多随机的顺序,将他们的预测求平均。
参考文献:
```py
Jesse Read, Bernhard Pfahringer, Geoff Holmes, Eibe Frank,
```
“Classifier Chains for Multi-label Classification”, 2009.
>参考文献:
>* Jesse Read, Bernhard Pfahringer, Geoff Holmes, Eibe Frank,“Classifier Chains for Multi-label Classification”, 2009.
此差异已折叠。
......@@ -2,25 +2,24 @@
校验者:
        [@STAN,废柴0.1](https://github.com/apachecn/scikit-learn-doc-zh)
[@Loopy](https://github.com/loopyme)
翻译者:
        [@那伊抹微笑](https://github.com/apachecn/scikit-learn-doc-zh)
[半监督学习](https://en.wikipedia.org/wiki/Semi-supervised_learning) 适用于在训练数据上的一些样本数据没有贴上标签的情况。 [`sklearn.semi_supervised`](classes.html#module-sklearn.semi_supervised "sklearn.semi_supervised") 中的半监督估计, 能够利用这些附加的未标记数据来更好地捕获底层数据分布的形状,并将其更好地类推到新的样本。 当我们有非常少量的已标签化的点和大量的未标签化的点时,这些算法表现均良好。
*y* 中含有未标记的数据
在使用 `fit` 方法训练数据时, 将标识符与已标签化的数据一起分配给未标签化的点是尤其重要的. 实现该标记的方法是使用整数值 ![-1](img/8b3be66a25e0c33787b341667b261360.jpg).
> *y* 中含有未标记的数据
>
>在使用 `fit` 方法训练数据时, 将标识符与已标签化的数据一起分配给未标签化的点是尤其重要的. 实现该标记的方法是使用整数值 ![-1](img/8b3be66a25e0c33787b341667b261360.jpg).
## 1.14.1\. 标签传播
标签传播表示半监督图推理算法的几个变体。
```py
该模型的一些特性如下:
```
*该模型的一些特性如下:*
* 可用于分类和回归任务
* Kernel methods to project data into alternate dimensional spaces
* 使用内核方法将数据投影到备用维度空间
*scikit-learn* 提供了两种标签传播模型: [`LabelPropagation`](https://scikit-learn.org/stable/modules/generated/sklearn.semi_supervised.LabelPropagation.html#sklearn.semi_supervised.LabelPropagation "sklearn.semi_supervised.LabelPropagation")[`LabelSpreading`](https://scikit-learn.org/stable/modules/generated/sklearn.semi_supervised.LabelSpreading.html#sklearn.semi_supervised.LabelSpreading "sklearn.semi_supervised.LabelSpreading") 。 两者都通过在输入的 dataset(数据集)中的所有 items(项)上构建 similarity graph (相似图)来进行工作。
......@@ -34,19 +33,17 @@
标签传播模型有两种内置的 kernel methods(核函数)。 kernel (核)的选择会影响算法的可扩展性和性能。 以下是可用的:
> * rbf (![\exp(-\gamma |x-y|^2), \gamma > 0](img/26f66401927461c0129b7f4ad33e5322.jpg)). ![\gamma](img/6552bde3d3999c1a9728016416932af7.jpg) 通过关键字 gamma 来指定。
> * knn (![1[x' \in kNN(x)]](img/6db85b1ad926d9ad860d58629ff5f235.jpg)). ![k](img/f93871977da52a6d11045d57c3e18728.jpg) 通过关键字 n_neighbors 来指定。
* rbf (![\exp(-\gamma |x-y|^2), \gamma > 0](img/26f66401927461c0129b7f4ad33e5322.jpg)). ![\gamma](img/6552bde3d3999c1a9728016416932af7.jpg) 通过关键字 gamma 来指定。
* knn (![1[x' \in kNN(x)]](img/6db85b1ad926d9ad860d58629ff5f235.jpg)). ![k](img/f93871977da52a6d11045d57c3e18728.jpg) 通过关键字 n_neighbors 来指定。
RBF 核将产生一个完全连接的图形, 它通过密集矩阵在内存中表示。 该矩阵可能非常大, 与算法的每次迭代执行全矩阵乘法计算的成本相结合可导致超长的运行时间。 在另一方面, KNN 核将产生更多的内存友好的稀疏矩阵, 这样可以大幅度的减少运行时间。
例子
* [Decision boundary of label propagation versus SVM on the Iris dataset](https://scikit-learn.org/stable/auto_examples/semi_supervised/plot_label_propagation_versus_svm_iris.html#sphx-glr-auto-examples-semi-supervised-plot-label-propagation-versus-svm-iris-py)
* [Label Propagation learning a complex structure](https://scikit-learn.org/stable/auto_examples/semi_supervised/plot_label_propagation_structure.html#sphx-glr-auto-examples-semi-supervised-plot-label-propagation-structure-py)
* [Label Propagation digits active learning](https://scikit-learn.org/stable/auto_examples/semi_supervised/plot_label_propagation_digits_active_learning.html#sphx-glr-auto-examples-semi-supervised-plot-label-propagation-digits-active-learning-py)
参考
[1] Yoshua Bengio, Olivier Delalleau, Nicolas Le Roux. In Semi-Supervised Learning (2006), pp. 193-216
>示例
>
>* [Decision boundary of label propagation versus SVM on the Iris dataset](https://scikit-learn.org/stable/auto_examples/semi_supervised/plot_label_propagation_versus_svm_iris.html#sphx-glr-auto-examples-semi-supervised-plot-label-propagation-versus-svm-iris-py)
>* [Label Propagation learning a complex structure](https://scikit-learn.org/stable/auto_examples/semi_supervised/plot_label_propagation_structure.html#sphx-glr-auto-examples-semi-supervised-plot-label-propagation-structure-py)
>* [Label Propagation digits active learning](https://scikit-learn.org/stable/auto_examples/semi_supervised/plot_label_propagation_digits_active_learning.html#sphx-glr-auto-examples-semi-supervised-plot-label-propagation-digits-active-learning-py)
[2] Olivier Delalleau, Yoshua Bengio, Nicolas Le Roux. Efficient Non-Parametric Function Induction in Semi-Supervised Learning. AISTAT 2005 [http://research.microsoft.com/en-us/people/nicolasl/efficient_ssl.pdf](http://research.microsoft.com/en-us/people/nicolasl/efficient_ssl.pdf)
\ No newline at end of file
>参考
>* [1] Yoshua Bengio, Olivier Delalleau, Nicolas Le Roux. In Semi-Supervised Learning (2006), pp. 193-216
>* [2] Olivier Delalleau, Yoshua Bengio, Nicolas Le Roux. Efficient Non-Parametric Function Induction in Semi-Supervised Learning. AISTAT 2005 [http://research.microsoft.com/en-us/people/nicolasl/efficient_ssl.pdf](http://research.microsoft.com/en-us/people/nicolasl/efficient_ssl.pdf)
......@@ -7,10 +7,10 @@
[`IsotonicRegression`](https://scikit-learn.org/stable/modules/generated/sklearn.isotonic.IsotonicRegression.html#sklearn.isotonic.IsotonicRegression "sklearn.isotonic.IsotonicRegression") 类对数据进行非降函数拟合. 它解决了如下的问题:
> 最小化 ![\sum_i w_i (y_i - \hat{y}_i)^2](img/156554c81cfe5f0230627ac0487fd07f.jpg)
>
> 服从于 ![\hat{y}_{min} = \hat{y}_1 \le \hat{y}_2 ... \le \hat{y}_n = \hat{y}_{max}](img/6c446734a6837b7541db12e2b55f1a2b.jpg)
* 最小化 ![\sum_i w_i (y_i - \hat{y}_i)^2](img/156554c81cfe5f0230627ac0487fd07f.jpg)
* 服从于 ![\hat{y}_{min} = \hat{y}_1 \le \hat{y}_2 ... \le \hat{y}_n = \hat{y}_{max}](img/6c446734a6837b7541db12e2b55f1a2b.jpg)
其中每一个 ![w_i](img/6689aa593e8e42bb5c2caa474e642b5f.jpg) 是 strictly 正数而且每个 ![y_i](img/4a22ca544916918b2358e5fc7c71b8e6.jpg) 是任意实 数. 它生成一个由平方误差接近的不减元素组成的向量.实际上这一些元素形成 一个分段线性的函数.
[![http://sklearn.apachecn.org/cn/0.19.0/_images/sphx_glr_plot_isotonic_regression_0011.png](img/87ae31ef4f2e7b4385b9a25aa8fed533.jpg)](https://scikit-learn.org/stable/auto_examples/plot_isotonic_regression.html)
\ No newline at end of file
[![http://sklearn.apachecn.org/cn/0.19.0/_images/sphx_glr_plot_isotonic_regression_0011.png](img/87ae31ef4f2e7b4385b9a25aa8fed533.jpg)](https://scikit-learn.org/stable/auto_examples/plot_isotonic_regression.html)
......@@ -16,7 +16,7 @@
* [`GaussianNB`](https://scikit-learn.org/stable/modules/generated/sklearn.naive_bayes.GaussianNB.html#sklearn.naive_bayes.GaussianNB "sklearn.naive_bayes.GaussianNB") 往往将概率推到 0 或 1(注意直方图中的计数). 这主要是因为它假设特征在给定类别的条件下是独立的, 在该数据集中不包含 2 个冗余特征.
* [`RandomForestClassifier`](https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestClassifier.html#sklearn.ensemble.RandomForestClassifier "sklearn.ensemble.RandomForestClassifier") 解释了相反的行为:直方图在约 0.2 和 0.9 的概率时显示峰值, 而接近 0 或 1 的概率非常罕见. Niculescu-Mizil 和 Caruana [4] 给出了一个解释:”诸如 bagging 和 random forests(随机森林)的方法, 从基本模型的平均预测中可能难以将预测置于 0 和 1 附近, 因为基础模型的变化会偏离预测值, 它们应该接近于零或偏离这些值, 因为预测被限制在 [0,1] 的间隔, 由方差引起的误差往往是靠近 0 和 1 的一边, 例如,如果一个模型应该对于一个案例,预测 p = 0,bagging 可以实现的唯一方法是假设所有的 bagging 树预测为零. 如果我们在 bagging 树上增加噪声, 这种噪声将导致一些树预测大于 0 的值, 因此将 bagging 的平均预测从 0 移开. 我们用随机森林最强烈地观察到这种效应, 因为用随机森林训练的 base-level 树由于特征划分而具有相对较高的方差. 因此,校准曲线也被称为可靠性图 (Wilks 1995 [5] _) 显示了一种典型的 sigmoid 形状, 表明分类器可以更多地信任其 “直觉”, 并通常将接近 0 或 1 的概率返回.
* [`RandomForestClassifier`](https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestClassifier.html#sklearn.ensemble.RandomForestClassifier "sklearn.ensemble.RandomForestClassifier") 解释了相反的行为:直方图在约 0.2 和 0.9 的概率时显示峰值, 而接近 0 或 1 的概率非常罕见. Niculescu-Mizil 和 Caruana [4] 给出了一个解释:”诸如 bagging 和 random forests(随机森林)的方法, 从基本模型的平均预测中可能难以将预测置于 0 和 1 附近, 因为基础模型的变化会偏离预测值, 它们应该接近于零或偏离这些值, 因为预测被限制在 [0,1] 的间隔, 由方差引起的误差往往是靠近 0 和 1 的一边, 例如,如果一个模型应该对于一个案例,预测 p = 0,bagging 可以实现的唯一方法是假设所有的 bagging 树预测为零. 如果我们在 bagging 树上增加噪声, 这种噪声将导致一些树预测大于 0 的值, 因此将 bagging 的平均预测从 0 移开. 我们用随机森林最强烈地观察到这种效应, 因为用随机森林训练的 base-level 树由于特征划分而具有相对较高的方差. 因此,校准曲线也被称为可靠性图 (Wilks 1995 [5] ) 显示了一种典型的 sigmoid 形状, 表明分类器可以更多地信任其 “直觉”, 并通常将接近 0 或 1 的概率返回.
* 线性支持向量分类 ([`LinearSVC`](https://scikit-learn.org/stable/modules/generated/sklearn.svm.LinearSVC.html#sklearn.svm.LinearSVC "sklearn.svm.LinearSVC")) 显示了作为 RandomForestClassifier 更多的 Sigmoid 曲线, 这是经典的最大边距方法 (compare Niculescu-Mizil and Caruana [[4]](#id3)), 其重点是靠近决策边界的 hard samples(支持向量).
......@@ -54,12 +54,9 @@
该校准导致较低的 log-loss(对数损失). 请注意,替代方案是增加基准估计量的数量, 这将导致对数损失类似的减少.
参考:
* Obtaining calibrated probability estimates from decision trees and naive Bayesian classifiers, B. Zadrozny & C. Elkan, ICML 2001
* Transforming Classifier Scores into Accurate Multiclass Probability Estimates, B. Zadrozny & C. Elkan, (KDD 2002)
* Probabilistic Outputs for Support Vector Machines and Comparisons to Regularized Likelihood Methods, J. Platt, (1999)
| [[4]](#id2) | Predicting Good Probabilities with Supervised Learning, A. Niculescu-Mizil & R. Caruana, ICML 2005 |
| [5] | On the combination of forecast probabilities for consecutive precipitation periods. Wea. Forecasting, 5, 640–650., Wilks, D. S., 1990a |
\ No newline at end of file
>参考:
>* Obtaining calibrated probability estimates from decision trees and naive Bayesian classifiers, B. Zadrozny & C. Elkan, ICML 2001
>* Transforming Classifier Scores into Accurate Multiclass Probability Estimates, B. Zadrozny & C. Elkan, (KDD 2002)
>* Probabilistic Outputs for Support Vector Machines and Comparisons to Regularized Likelihood Methods, J. Platt, (1999)
>* [4] Predicting Good Probabilities with Supervised Learning, A. Niculescu-Mizil & R. Caruana, ICML 2005
>* [5] On the combination of forecast probabilities for consecutive precipitation periods. Wea. Forecasting, 5, 640–650., Wilks, D. S., 1990a
......@@ -3,12 +3,13 @@
校验者:
        [@tiantian1412](https://github.com/tiantian1412)
        [@火星](https://github.com/apachecn/scikit-learn-doc-zh)
[@Loopy](https://github.com/loopyme)
翻译者:
        [@A](https://github.com/apachecn/scikit-learn-doc-zh)
Warning
此实现不适用于大规模数据应用。 特别是 scikit-learn 不支持 GPU。如果想要提高运行速度并使用基于 GPU 的实现以及为构建深度学习架构提供更多灵活性的框架,请参阅 [Related Projects](../related_projects.html#related-projects)
>**警告**
>
>此实现不适用于大规模数据应用。 特别是 scikit-learn 不支持 GPU。如果想要提高运行速度并使用基于 GPU 的实现以及为构建深度学习架构提供更多灵活性的框架,请参阅 [Related Projects](https://scikit-learn.org/stable/related_projects.html#related-projects) 。
## 1.17.1\. 多层感知器
......@@ -24,20 +25,20 @@ Warning
多层感知器的优点:
> * 可以学习得到非线性模型。
> * 使用``partial_fit`` 可以学习得到实时模型(在线学习)。
* 可以学习得到非线性模型。
* 使用``partial_fit`` 可以学习得到实时模型(在线学习)。
多层感知器(MLP)的缺点:
> * 具有隐藏层的 MLP 具有非凸的损失函数,它有不止一个的局部最小值。 因此不同的随机权重初始化会导致不同的验证集准确率。
> * MLP 需要调试一些超参数,例如隐藏层神经元的数量、层数和迭代轮数。
> * MLP 对特征归一化很敏感.
* 具有隐藏层的 MLP 具有非凸的损失函数,它有不止一个的局部最小值。 因此不同的随机权重初始化会导致不同的验证集准确率。
* MLP 需要调试一些超参数,例如隐藏层神经元的数量、层数和迭代轮数。
* MLP 对特征归一化很敏感.
解决这些缺点的方法请参阅 [实用使用技巧](#mlp-tips) 部分。
解决这些缺点的方法请参阅 [实用使用技巧](#_1178-实用技巧) 部分。
## 1.17.2\. 分类
> [`MLPClassifier`](https://scikit-learn.org/stable/modules/generated/sklearn.neural_network.MLPClassifier.html#sklearn.neural_network.MLPClassifier "sklearn.neural_network.MLPClassifier") 类实现了通过 [Backpropagation](http://ufldl.stanford.edu/wiki/index.php/Backpropagation_Algorithm) 进行训练的多层感知器(MLP)算法。
[`MLPClassifier`](https://scikit-learn.org/stable/modules/generated/sklearn.neural_network.MLPClassifier.html#sklearn.neural_network.MLPClassifier "sklearn.neural_network.MLPClassifier") 类实现了通过 [Backpropagation](http://ufldl.stanford.edu/wiki/index.php/Backpropagation_Algorithm) 进行训练的多层感知器(MLP)算法。
MLP 在两个 array 上进行训练:大小为 (n_samples, n_features) 的 array X 储存表示训练样本的浮点型特征向量; 大小为 (n_samples,) 的 array y 储存训练样本的目标值(类别标签):
......@@ -50,13 +51,13 @@ MLP 在两个 array 上进行训练:大小为 (n_samples, n_features) 的 array
...
>>> clf.fit(X, y)
MLPClassifier(activation='relu', alpha=1e-05, batch_size='auto',
beta_1=0.9, beta_2=0.999, early_stopping=False,
epsilon=1e-08, hidden_layer_sizes=(5, 2), learning_rate='constant',
learning_rate_init=0.001, max_iter=200, momentum=0.9,
nesterovs_momentum=True, power_t=0.5, random_state=1, shuffle=True,
solver='lbfgs', tol=0.0001, validation_fraction=0.1, verbose=False,
warm_start=False)
beta_1=0.9, beta_2=0.999, early_stopping=False,
epsilon=1e-08, hidden_layer_sizes=(5, 2),
learning_rate='constant', learning_rate_init=0.001,
max_iter=200, momentum=0.9, n_iter_no_change=10,
nesterovs_momentum=True, power_t=0.5, random_state=1,
shuffle=True, solver='lbfgs', tol=0.0001,
validation_fraction=0.1, verbose=False, warm_start=False)
```
拟合(训练)后,该模型可以预测新样本的标签:
......@@ -98,12 +99,13 @@ array([[ 1.967...e-04, 9.998...-01],
...
>>> clf.fit(X, y)
MLPClassifier(activation='relu', alpha=1e-05, batch_size='auto',
beta_1=0.9, beta_2=0.999, early_stopping=False,
epsilon=1e-08, hidden_layer_sizes=(15,), learning_rate='constant',
learning_rate_init=0.001, max_iter=200, momentum=0.9,
nesterovs_momentum=True, power_t=0.5, random_state=1, shuffle=True,
solver='lbfgs', tol=0.0001, validation_fraction=0.1, verbose=False,
warm_start=False)
beta_1=0.9, beta_2=0.999, early_stopping=False,
epsilon=1e-08, hidden_layer_sizes=(15,),
learning_rate='constant', learning_rate_init=0.001,
max_iter=200, momentum=0.9, n_iter_no_change=10,
nesterovs_momentum=True, power_t=0.5, random_state=1,
shuffle=True, solver='lbfgs', tol=0.0001,
validation_fraction=0.1, verbose=False, warm_start=False)
>>> clf.predict([[1., 2.]])
array([[1, 1]])
>>> clf.predict([[0., 0.]])
......@@ -113,10 +115,9 @@ array([[0, 1]])
更多内容请参阅下面的示例和文档 [`MLPClassifier.fit`](https://scikit-learn.org/stable/modules/generated/sklearn.neural_network.MLPClassifier.html#sklearn.neural_network.MLPClassifier.fit "sklearn.neural_network.MLPClassifier.fit")
示例:
* [Compare Stochastic learning strategies for MLPClassifier](https://scikit-learn.org/stable/auto_examples/neural_networks/plot_mlp_training_curves.html#sphx-glr-auto-examples-neural-networks-plot-mlp-training-curves-py)
* [Visualization of MLP weights on MNIST](https://scikit-learn.org/stable/auto_examples/neural_networks/plot_mnist_filters.html#sphx-glr-auto-examples-neural-networks-plot-mnist-filters-py)
>示例:
>* [Compare Stochastic learning strategies for MLPClassifier](https://scikit-learn.org/stable/auto_examples/neural_networks/plot_mlp_training_curves.html#sphx-glr-auto-examples-neural-networks-plot-mlp-training-curves-py)
>* [Visualization of MLP weights on MNIST](https://scikit-learn.org/stable/auto_examples/neural_networks/plot_mnist_filters.html#sphx-glr-auto-examples-neural-networks-plot-mnist-filters-py)
## 1.17.3\. 回归
......@@ -132,22 +133,20 @@ array([[0, 1]])
详细信息,请参阅下面的示例。
示例:
* [Varying regularization in Multi-layer Perceptron](https://scikit-learn.org/stable/auto_examples/neural_networks/plot_mlp_alpha.html#sphx-glr-auto-examples-neural-networks-plot-mlp-alpha-py)
>示例:
>* [Varying regularization in Multi-layer Perceptron](https://scikit-learn.org/stable/auto_examples/neural_networks/plot_mlp_alpha.html#sphx-glr-auto-examples-neural-networks-plot-mlp-alpha-py)
## 1.17.5\. 算法
MLP 使用 [Stochastic Gradient Descent(随机梯度下降)(SGD)](https://en.wikipedia.org/wiki/Stochastic_gradient_descent), [Adam](http://arxiv.org/abs/1412.6980), 或者 [L-BFGS](https://en.wikipedia.org/wiki/Limited-memory_BFGS) 进行训练。 随机梯度下降(SGD) 使用关于需要适应的一个参数的损失函数的梯度来更新参数,即
![w \leftarrow w - \eta (\alpha \frac{\partial R(w)}{\partial w}
+ \frac{\partial Loss}{\partial w})](img/cdc5ef75d769259ef0537940296ab0b4.jpg)
![w \leftarrow w - \eta (\alpha \frac{\partial R(w)}{\partial w}+ \frac{\partial Loss}{\partial w})](img/cdc5ef75d769259ef0537940296ab0b4.jpg)
其中 ![\eta](img/fe1d79339349f9b6263e123094ffce7b.jpg) 是控制训练过程参数更新步长的学习率(learning rate)。 ![Loss](img/16622481c2bbb001363e20660b549ae9.jpg) 是损失函数(loss function)。
更多细节可以在这个文档中找到 [SGD](http://scikit-learn.org/stable/modules/sgd.html)
更多细节可以在这个文档中找到 [SGD](docs/6)
Adam 类似于 SGD,因为它是 stochastic optimizer (随机优化器),但它可以根据低阶矩的自适应估计自动调整参数更新的量。
......@@ -199,27 +198,20 @@ MLP 根据特定问题使用不同的损失函数。 二分类问题的损失函
## 1.17.8\. 实用技巧
> * 多层感知器对特征的缩放是敏感的,所以它强烈建议您归一化你的数据。 例如,将输入向量 X 的每个属性放缩到到 [0, 1] 或 [-1,+1] ,或者将其标准化使它具有 0 均值和方差 1。
>
> 注意,为了得到有意义的结果,您必须对测试集也应用 _相同的_ 尺度缩放。 您可以使用 `StandardScaler` 进行标准化。
>
> > ```py
> > >>> from sklearn.preprocessing import StandardScaler
> > >>> scaler = StandardScaler()
> > >>> # Don't cheat - fit only on training data
> > >>> scaler.fit(X_train)
> > >>> X_train = scaler.transform(X_train)
> > >>> # apply same transformation to test data
> > >>> X_test = scaler.transform(X_test)
> >
> > ```
> >
> > 另一个推荐的方法是在 `Pipeline` 中使用的 `StandardScaler` 。
>
> * 最好使用 `GridSearchCV` 找到一个合理的正则化参数 ![\alpha](img/d8b3d5242d513369a44f8bf0c6112744.jpg) ,通常范围是在 `10.0 ** -np.arange(1, 7)` 。
> * 据经验可知,我们观察到 *L-BFGS* 收敛速度是更快的并且是小数据集上更好的解决方案。对于规模相对比较大的数据集,*Adam* 是非常鲁棒的。 它通常会迅速收敛,并得到相当不错的表现。
>
> 另一方面,如果学习率调整得正确, 使用 momentum 或 nesterov’s momentum 的 *SGD* 可以比这两种算法更好。
* 多层感知器对特征的缩放是敏感的,所以它强烈建议您归一化你的数据。 例如,将输入向量 X 的每个属性放缩到到 [0, 1] 或 [-1,+1] ,或者将其标准化使它具有 0 均值和方差 1。注意,为了得到有意义的结果,您必须对测试集也应用 *相同的* 尺度缩放。 您可以使用 `StandardScaler` 进行标准化。
```py
from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
# Don't cheat - fit only on training data
scaler.fit(X_train)
X_train = scaler.transform(X_train)
# apply same transformation to test data
X_test = scaler.transform(X_test)
```
另一个推荐的方法是在 `Pipeline` 中使用的 `StandardScaler`
* 最好使用 `GridSearchCV` 找到一个合理的正则化参数 ![\alpha](img/d8b3d5242d513369a44f8bf0c6112744.jpg) ,通常范围是在 `10.0 ** -np.arange(1, 7)`
* 据经验可知,我们观察到 *L-BFGS* 收敛速度是更快的并且是小数据集上更好的解决方案。对于规模相对比较大的数据集,*Adam* 是非常鲁棒的。 它通常会迅速收敛,并得到相当不错的表现。另一方面,如果学习率调整得正确, 使用 momentum 或 nesterov’s momentum 的 *SGD* 可以比这两种算法更好。
## 1.17.9\. 使用 warm_start 的更多控制
......@@ -231,15 +223,15 @@ MLP 根据特定问题使用不同的损失函数。 二分类问题的损失函
>>> clf = MLPClassifier(hidden_layer_sizes=(15,), random_state=1, max_iter=1, warm_start=True)
>>> for i in range(10):
... clf.fit(X, y)
... # additional monitoring / inspection
... # additional monitoring / inspection
MLPClassifier(...
```
参考文献:
* [“Learning representations by back-propagating errors.”](http://www.iro.umontreal.ca/~pift6266/A06/refs/backprop_old.pdf) Rumelhart, David E., Geoffrey E. Hinton, and Ronald J. Williams.
* [“Stochastic Gradient Descent”](http://leon.bottou.org/projects/sgd) L. Bottou - Website, 2010.
* [“Backpropagation”](http://ufldl.stanford.edu/wiki/index.php/Backpropagation_Algorithm) Andrew Ng, Jiquan Ngiam, Chuan Yu Foo, Yifan Mai, Caroline Suen - Website, 2011.
* [“Efficient BackProp”](http://yann.lecun.com/exdb/publis/pdf/lecun-98b.pdf) Y. LeCun, L. Bottou, G. Orr, K. Müller - In Neural Networks: Tricks of the Trade 1998.
* [“Adam: A method for stochastic optimization.”](http://arxiv.org/pdf/1412.6980v8.pdf) Kingma, Diederik, and Jimmy Ba. arXiv preprint arXiv:1412.6980 (2014).
\ No newline at end of file
>参考文献:
>
>* [“Learning representations by back-propagating errors.”](http://www.iro.umontreal.ca/~pift6266/A06/refs/backprop_old.pdf) Rumelhart, David E., Geoffrey E. Hinton, and Ronald J. Williams.
>* [“Stochastic Gradient Descent”](http://leon.bottou.org/projects/sgd) L. Bottou - Website, 2010.
>* [“Backpropagation”](http://ufldl.stanford.edu/wiki/index.php/Backpropagation_Algorithm) Andrew Ng, Jiquan Ngiam, Chuan Yu Foo, Yifan Mai, Caroline Suen - Website, 2011.
>* [“Efficient BackProp”](http://yann.lecun.com/exdb/publis/pdf/lecun-98b.pdf) Y. LeCun, L. Bottou, G. Orr, K. Müller - In Neural Networks: Tricks of the Trade 1998.
>* [“Adam: A method for stochastic optimization.”](http://arxiv.org/pdf/1412.6980v8.pdf) Kingma, Diederik, and Jimmy Ba. arXiv preprint arXiv:1412.6980 (2014).
......@@ -3,14 +3,15 @@
校验者:
        [@why2lyj](https://github.com/why2lyj)
        [@Shao Y.](https://github.com/apachecn/scikit-learn-doc-zh)
[@Loopy](https://github.com/loopyme)
翻译者:
        [@glassy](https://github.com/apachecn/scikit-learn-doc-zh)
`sklearn.mixture` 是一个应用高斯混合模型进行非监督学习的包,支持 diagonal,spherical,tied,full 四种协方差矩阵 (注:diagonal 指每个分量有各自不同对角协方差矩阵, spherical 指每个分量有各自不同的简单协方差矩阵, tied 指所有分量有相同的标准协方差矩阵, full 指每个分量有各自不同的标准协方差矩阵),它对数据进行抽样,并且根据数据估计模型。同时包也提供了相关支持,来帮助用户决定合适的分量数(分量个数)。 _(译注:在高斯混合模型中,我们将每一个高斯分布称为一个分量,即 component )_
> [![http://sklearn.apachecn.org/cn/0.19.0/_images/sphx_glr_plot_gmm_pdf_0011.png](img/ac23b915eb44e4fa668b8d56785e2c20.jpg)](https://scikit-learn.org/stable/auto_examples/mixture/plot_gmm_pdf.html)
>
> **二分量高斯混合模型:** _数据点,以及模型的等概率线。_
[![http://sklearn.apachecn.org/cn/0.19.0/_images/sphx_glr_plot_gmm_pdf_0011.png](img/ac23b915eb44e4fa668b8d56785e2c20.jpg)](https://scikit-learn.org/stable/auto_examples/mixture/plot_gmm_pdf.html)
**二分量高斯混合模型:** _数据点,以及模型的等概率线。_
高斯混合模型是一个假设所有的数据点都是生成于一个混合的有限数量的并且未知参数的高斯分布的概率模型。 我们可以将混合模型看作是 k-means 聚类算法的推广,它利用了关于数据的协方差结构以及潜在高斯中心的信息。
......@@ -18,7 +19,7 @@
## 2.1.1\. 高斯混合
> [`GaussianMixture`](https://scikit-learn.org/stable/modules/generated/sklearn.mixture.GaussianMixture.html#sklearn.mixture.GaussianMixture "sklearn.mixture.GaussianMixture") 对象实现了用来拟合高斯混合模型的 [期望最大化](#expectation-maximization) (EM) 算法。它还可以为多变量模型绘制置信区间,同时计算 BIC(Bayesian Information Criterion,贝叶斯信息准则)来评估数据中聚类的数量。 [`GaussianMixture.fit`](https://scikit-learn.org/stable/modules/generated/sklearn.mixture.GaussianMixture.html#sklearn.mixture.GaussianMixture.fit "sklearn.mixture.GaussianMixture.fit") 提供了从训练数据中学习高斯混合模型的方法。
[`GaussianMixture`](https://scikit-learn.org/stable/modules/generated/sklearn.mixture.GaussianMixture.html#sklearn.mixture.GaussianMixture "sklearn.mixture.GaussianMixture") 对象实现了用来拟合高斯混合模型的 [期望最大化](#expectation-maximization) (EM) 算法。它还可以为多变量模型绘制置信区间,同时计算 BIC(Bayesian Information Criterion,贝叶斯信息准则)来评估数据中聚类的数量。 [`GaussianMixture.fit`](https://scikit-learn.org/stable/modules/generated/sklearn.mixture.GaussianMixture.html#sklearn.mixture.GaussianMixture.fit "sklearn.mixture.GaussianMixture.fit") 提供了从训练数据中学习高斯混合模型的方法。
给定测试数据,通过使用 [`GaussianMixture.predict`](https://scikit-learn.org/stable/modules/generated/sklearn.mixture.GaussianMixture.html#sklearn.mixture.GaussianMixture.predict "sklearn.mixture.GaussianMixture.predict") 方法,可以为每个样本分配最有可能对应的高斯分布。
......@@ -26,38 +27,30 @@
[![http://sklearn.apachecn.org/cn/0.19.0/_images/sphx_glr_plot_gmm_covariances_0011.png](img/8cc09b4045e2fece3222e52d7333c1e5.jpg)](https://scikit-learn.org/stable/auto_examples/mixture/plot_gmm_covariances.html)
示例:
* 一个利用高斯混合模型在鸢尾花卉数据集(IRIS 数据集)上做聚类的协方差实例,请查阅 [GMM covariances](https://scikit-learn.org/stable/auto_examples/mixture/plot_gmm_covariances.html#sphx-glr-auto-examples-mixture-plot-gmm-covariances-py)
* 一个绘制密度估计的例子,请查阅 [Density Estimation for a Gaussian mixture](https://scikit-learn.org/stable/auto_examples/mixture/plot_gmm_pdf.html#sphx-glr-auto-examples-mixture-plot-gmm-pdf-py)
>示例:
>* 一个利用高斯混合模型在鸢尾花卉数据集(IRIS 数据集)上做聚类的协方差实例,请查阅 [GMM covariances](https://scikit-learn.org/stable/auto_examples/mixture/plot_gmm_covariances.html#sphx-glr-auto-examples-mixture-plot-gmm-covariances-py)
>* 一个绘制密度估计的例子,请查阅 [Density Estimation for a Gaussian mixture](https://scikit-learn.org/stable/auto_examples/mixture/plot_gmm_pdf.html#sphx-glr-auto-examples-mixture-plot-gmm-pdf-py)
### 2.1.1.1\. 优缺点 [`GaussianMixture`](https://scikit-learn.org/stable/modules/generated/sklearn.mixture.GaussianMixture.html#sklearn.mixture.GaussianMixture "sklearn.mixture.GaussianMixture")
#### 2.1.1.1.1\. 优点
* **速度:** 是混合模型学习算法中最快的算法.
* **无偏差性:** 这个算法仅仅只是最大化可能性,并不会使均值偏向于0,或是使聚类大小偏向于可能适用或者可能不适用的特殊结构。
| 速度: | 是混合模型学习算法中最快的算法。 |
| --- | --- |
| 无偏差性: | 这个算法仅仅只是最大化可能性,并不会使均值偏向于0,或是使聚类大小偏向于可能适用或者可能不适用的特殊结构。 |
| --- | --- |
#### 2.1.1.1.2\. 缺点
* **奇异性:** 当每个混合模型没有足够多的点时,估算协方差变得困难起来,同时算法会发散并且找具有无穷大似然函数值的解,除非人为地对协方差进行正则化。
* **分量的数量:** 这个算法将会总是用所有它能用的分量,所以在没有外部线索的情况下需要留存数据或者用信息理论标准来决定用多少分量。
| 奇异性: | 当每个混合模型没有足够多的点时,估算协方差变得困难起来,同时算法会发散并且找具有无穷大似然函数值的解,除非人为地对协方差进行正则化。 |
| --- | --- |
| 分量的数量: | 这个算法将会总是用所有它能用的分量,所以在没有外部线索的情况下需要留存数据或者用信息理论标准来决定用多少分量。 |
| --- | --- |
### 2.1.1.2\. 选择经典高斯混合模型中分量的个数
一种高效的方法是利用 BIC(贝叶斯信息准则)来选择高斯混合的分量数。 理论上,它仅当在近似状态下可以恢复正确的分量数(即如果有大量数据可用,并且假设这些数据实际上是一个混合高斯模型独立同分布生成的)。注意:使用 [变分贝叶斯高斯混合](#bgmm) 可以避免高斯混合模型中分量数的选择。
[![http://sklearn.apachecn.org/cn/0.19.0/_images/sphx_glr_plot_gmm_selection_0011.png](img/8615ac5c8ea1fb8ae6e726f7659a29e9.jpg)](https://scikit-learn.org/stable/auto_examples/mixture/plot_gmm_selection.html)
示例:
* 一个用典型的高斯混合进行的模型选择的例子,请查阅 [Gaussian Mixture Model Selection](https://scikit-learn.org/stable/auto_examples/mixture/plot_gmm_selection.html#sphx-glr-auto-examples-mixture-plot-gmm-selection-py)
>示例:
>* 一个用典型的高斯混合进行的模型选择的例子,请查阅 [Gaussian Mixture Model Selection](https://scikit-learn.org/stable/auto_examples/mixture/plot_gmm_selection.html#sphx-glr-auto-examples-mixture-plot-gmm-selection-py)
### 2.1.1.3\. 估计算法期望最大化(EM)
......@@ -65,7 +58,7 @@
## 2.1.2\. 变分贝叶斯高斯混合
> [`BayesianGaussianMixture`](https://scikit-learn.org/stable/modules/generated/sklearn.mixture.BayesianGaussianMixture.html#sklearn.mixture.BayesianGaussianMixture "sklearn.mixture.BayesianGaussianMixture") 对象实现了具有变分的高斯混合模型的变体推理算法。 这个API和 [`GaussianMixture`](https://scikit-learn.org/stable/modules/generated/sklearn.mixture.GaussianMixture.html#sklearn.mixture.GaussianMixture "sklearn.mixture.GaussianMixture") 相似。
[`BayesianGaussianMixture`](https://scikit-learn.org/stable/modules/generated/sklearn.mixture.BayesianGaussianMixture.html#sklearn.mixture.BayesianGaussianMixture "sklearn.mixture.BayesianGaussianMixture") 对象实现了具有变分的高斯混合模型的变体推理算法。 这个API和 [`GaussianMixture`](https://scikit-learn.org/stable/modules/generated/sklearn.mixture.GaussianMixture.html#sklearn.mixture.GaussianMixture "sklearn.mixture.GaussianMixture") 相似。
### 2.1.2.1\. 估计算法: 变分推断(variational inference)
......@@ -85,40 +78,32 @@
[![http://sklearn.apachecn.org/cn/0.19.0/_images/sphx_glr_plot_gmm_sin_0011.png](img/d2b34f499ce1bbd28a276bc0d7afdde1.jpg)](https://scikit-learn.org/stable/auto_examples/mixture/plot_gmm_sin.html)
示例:
>示例:
> * 一个用 [`GaussianMixture`](https://scikit-learn.org/stable/modules/generated/sklearn.mixture.GaussianMixture.html#sklearn.mixture.GaussianMixture "sklearn.mixture.GaussianMixture") 和 [`BayesianGaussianMixture`](https://scikit-learn.org/stable/modules/generated/sklearn.mixture.BayesianGaussianMixture.html#sklearn.mixture.BayesianGaussianMixture "sklearn.mixture.BayesianGaussianMixture") 绘制置信椭圆体的例子, 请查阅 [Gaussian Mixture Model Ellipsoids](https://scikit-learn.org/stable/auto_examples/mixture/plot_gmm.html#sphx-glr-auto-examples-mixture-plot-gmm-py)
> * [Gaussian Mixture Model Sine Curve](https://scikit-learn.org/stable/auto_examples/mixture/plot_gmm_sin.html#sphx-glr-auto-examples-mixture-plot-gmm-sin-py) 这个例子展示了用 [`GaussianMixture`](https://scikit-learn.org/stable/modules/generated/sklearn.mixture.GaussianMixture.html#sklearn.mixture.GaussianMixture "sklearn.mixture.GaussianMixture") 和 [`BayesianGaussianMixture`](https://scikit-learn.org/stable/modules/generated/sklearn.mixture.BayesianGaussianMixture.html#sklearn.mixture.BayesianGaussianMixture "sklearn.mixture.BayesianGaussianMixture") 来拟合正弦波。
> * 一个使用不同的 `weight_concentration_prior_type` 用以不同的 `weight_concentration_prior` 参数值的:class:*BayesianGaussianMixture* 来绘制置信椭圆体的例子。 请查阅 [Concentration Prior Type Analysis of Variation Bayesian Gaussian Mixture](https://scikit-learn.org/stable/auto_examples/mixture/plot_concentration_prior.html#sphx-glr-auto-examples-mixture-plot-concentration-prior-py)
[`BayesianGaussianMixture`](https://scikit-learn.org/stable/modules/generated/sklearn.mixture.BayesianGaussianMixture.html#sklearn.mixture.BayesianGaussianMixture "sklearn.mixture.BayesianGaussianMixture") 下的变分推理的优缺点
### 2.1.2.2. [`BayesianGaussianMixture`](https://scikit-learn.org/stable/modules/generated/sklearn.mixture.BayesianGaussianMixture.html#sklearn.mixture.BayesianGaussianMixture "sklearn.mixture.BayesianGaussianMixture") 下的变分推理的优缺点
* * *
#### 2.1.2.2.1\. 优点
#### 2.1.2.1.1\. 优点
* **自动选择:**`weight_concentration_prior` 足够小以及 `n_components` 比模型需要的更大时,变分贝叶斯混合模型计算的结果可以让一些混合权重值趋近 0。 这让模型可以自动选择合适的有效分量数。这仅仅需要提供分量的数量上限。但是请注意,“理想” 的激活分量数只在应用场景中比较明确,在数据挖掘参数设置中通常并不明确。
* **对参数数量的敏感度较低:** 与总是用尽可以用的分量,因而将为不同数量的组件产生不同的解决方案有限模型不同,变分推理狄利克雷过程先验变分推理( `weight_concentration_prior_type='dirichlet_process'` )改变参数后结果并不会改变太多,使之更稳定和更少的调优。
* **正则化:** 由于结合了先验信息,变分的解比期望最大化(EM)的解有更少的病理特征(pathological special cases)。
| 自动选择: | 当 `weight_concentration_prior` 足够小以及 `n_components` 比模型需要的更大时,变分贝叶斯混合模型计算的结果可以让一些混合权重值趋近 0。 这让模型可以自动选择合适的有效分量数。这仅仅需要提供分量的数量上限。但是请注意,“理想” 的激活分量数只在应用场景中比较明确,在数据挖掘参数设置中通常并不明确。 |
| --- | --- |
| 对参数数量的敏感度较低: | 与总是用尽可以用的分量,因而将为不同数量的组件产生不同的解决方案有限模型不同,变分推理狄利克雷过程先验变分推理( `weight_concentration_prior_type='dirichlet_process'` )改变参数后结果并不会改变太多,使之更稳定和更少的调优。 |
| --- | --- |
| 正则化: | 由于结合了先验信息,变分的解比期望最大化(EM)的解有更少的病理特征(pathological special cases)。 |
| --- | --- |
#### 2.1.2.2.2\. 缺点
#### 2.1.2.1.2\. 缺点
* **速度:** 变分推理所需要的额外参数化使推理速度变慢,尽管并没有慢很多。
* **超参数:** 这个算法需要一个额外的可能需要通过交叉验证进行实验调优的超参数。
* **偏差:** 在推理算法存在许多隐含的偏差(如果用到狄利克雷过程也会有偏差), 每当这些偏差和数据之间不匹配时,用有限模型可能可以拟合更好的模型。
| 速度: | 变分推理所需要的额外参数化使推理速度变慢,尽管并没有慢很多。 |
| --- | --- |
| 超参数: | 这个算法需要一个额外的可能需要通过交叉验证进行实验调优的超参数。 |
| --- | --- |
| 偏差: | 在推理算法存在许多隐含的偏差(如果用到狄利克雷过程也会有偏差), 每当这些偏差和数据之间不匹配时,用有限模型可能可以拟合更好的模型。 |
| --- | --- |
### 2.1.2.2\. The Dirichlet Process(狄利克雷过程)
### 2.1.2.3\. The Dirichlet Process(狄利克雷过程)
这里我们描述了狄利克雷过程混合的变分推理算法。狄利克雷过程是在 _具有无限大,无限制的分区数的聚类_ 上的先验概率分布。相比于有限高斯混合模型,变分技术让我们在推理时间几乎没有惩罚(penalty)的情况下纳入了高斯混合模型的先验结构。
一个重要的问题是狄利克雷过程是如何实现用无限的,无限制的聚类数,并且结果仍然是一致的。 本文档不做出完整的解释,但是你可以看这里 [stick breaking process](https://en.wikipedia.org/wiki/Dirichlet_process#The_stick-breaking_process) 来帮助你理解它。折棍(stick breaking)过程是狄利克雷过程的衍生。我们每次从一个单位长度的 stick 开始,且每一步都折断剩下的一部分。每次,我们把每个 stick 的长度联想成落入一组混合的点的比例。 最后,为了表示无限混合,我们联想成最后每个 stick 的剩下的部分到没有落入其他组的点的比例。 每段的长度是随机变量,概率与浓度参数成比例。较小的浓度值将单位长度分成较大的 stick 段(即定义更集中的分布)。较高的浓度值将生成更小的 stick 段(即增加非零权重的分量数)。
狄利克雷过程的变分推理技术,在对该无限混合模型进行有限近似情形下,仍然可以运用。 用户不必事先指定想要的分量数,只需要指定浓度参数和混合分量数的上界(假定上界高于“真实”的分量数,仅仅影响算法复杂度,而不是实际上使用的分量数)。
\ No newline at end of file
狄利克雷过程的变分推理技术,在对该无限混合模型进行有限近似情形下,仍然可以运用。 用户不必事先指定想要的分量数,只需要指定浓度参数和混合分量数的上界(假定上界高于“真实”的分量数,仅仅影响算法复杂度,而不是实际上使用的分量数)。
......@@ -4,10 +4,16 @@
        [@XuJianzhi](https://github.com/XuJianzhi)
        [@RyanZhiNie](https://github.com/RyanZhiNie)
        [@羊三](https://github.com/apachecn/scikit-learn-doc-zh)
[@Loopy](https://github.com/loopyme)
翻译者:
        [@XuJianzhi](https://github.com/XuJianzhi)
        [@羊三](https://github.com/apachecn/scikit-learn-doc-zh)
Look for the bare necessitiesThe simple bare necessitiesForget about your worries and your strifeI mean the bare necessitiesOld Mother Nature’s recipesThat bring the bare necessities of life– Baloo的歌 [奇幻森林][![http://sklearn.apachecn.org/cn/0.19.0/_images/sphx_glr_plot_compare_methods_0011.png](img/fe9e5bb155154914f761d6497915e9cb.jpg)](https://scikit-learn.org/stable/auto_examples/manifold/plot_compare_methods.html)
>Look for the bare necessitiesThe simple bare necessitiesForget about your worries and your strifeI mean the bare necessitiesOld Mother Nature’s recipesThat bring the bare necessities of life
>
>– Baloo的歌 [奇幻森林]
[![http://sklearn.apachecn.org/cn/0.19.0/_images/sphx_glr_plot_compare_methods_0011.png](img/fe9e5bb155154914f761d6497915e9cb.jpg)](https://scikit-learn.org/stable/auto_examples/manifold/plot_compare_methods.html)
流形学习是一种非线性降维方法。其算法基于的思想是:许多数据集的维度过高只是由人为导致的。
......@@ -25,10 +31,9 @@ Look for the bare necessitiesThe simple bare necessitiesForget about your worrie
流形学习可以被认为是一种将线性框架(如 PCA )推广为对数据中非线性结构敏感的尝试。 虽然存在监督变量,但是典型的流形学习问题是无监督的:它从数据本身学习数据的高维结构,而不使用预定的分类。
例子:
* 参见 [Manifold learning on handwritten digits: Locally Linear Embedding, Isomap…](https://scikit-learn.org/stable/auto_examples/manifold/plot_lle_digits.html#sphx-glr-auto-examples-manifold-plot-lle-digits-py) ,手写数字降维的例子。
* 参见 [Comparison of Manifold Learning methods](https://scikit-learn.org/stable/auto_examples/manifold/plot_compare_methods.html#sphx-glr-auto-examples-manifold-plot-compare-methods-py) ,玩具 “S曲线” 数据集降维的例子。
>例子:
>* 参见 [Manifold learning on handwritten digits: Locally Linear Embedding, Isomap…](https://scikit-learn.org/stable/auto_examples/manifold/plot_lle_digits.html#sphx-glr-auto-examples-manifold-plot-lle-digits-py) ,手写数字降维的例子。
>* 参见 [Comparison of Manifold Learning methods](https://scikit-learn.org/stable/auto_examples/manifold/plot_compare_methods.html#sphx-glr-auto-examples-manifold-plot-compare-methods-py) ,玩具 “S曲线” 数据集降维的例子。
以下概述了 scikit-learn 中可用的流形学习实现
......@@ -53,9 +58,8 @@ Isomap 的整体复杂度是 ![O[D \log(k) N \log(N)] + O[N^2(k + \log(N))] + O[
* ![k](img/f93871977da52a6d11045d57c3e18728.jpg) : 最近邻的个数
* ![d](img/adf83056bc2bd05628e24c40cb728b3d.jpg) : 输出维度
参考文献:
* [“A global geometric framework for nonlinear dimensionality reduction”](http://science.sciencemag.org/content/290/5500/2319.full) Tenenbaum, J.B.; De Silva, V.; & Langford, J.C. Science 290 (5500)
>参考文献:
>* [“A global geometric framework for nonlinear dimensionality reduction”](http://science.sciencemag.org/content/290/5500/2319.full) Tenenbaum, J.B.; De Silva, V.; & Langford, J.C. Science 290 (5500)
## 2.2.3\. 局部线性嵌入
......@@ -80,9 +84,8 @@ Isomap 的整体复杂度是 ![O[D \log(k) N \log(N)] + O[N^2(k + \log(N))] + O[
* ![k](img/f93871977da52a6d11045d57c3e18728.jpg) : 最近邻的个数
* ![d](img/adf83056bc2bd05628e24c40cb728b3d.jpg) : 输出维度
参考文献:
* [“Nonlinear dimensionality reduction by locally linear embedding”](http://www.sciencemag.org/content/290/5500/2323.full) Roweis, S. & Saul, L. Science 290:2323 (2000)
>参考文献:
>* [“Nonlinear dimensionality reduction by locally linear embedding”](http://www.sciencemag.org/content/290/5500/2323.full) Roweis, S. & Saul, L. Science 290:2323 (2000)
## 2.2.4\. 改进型局部线性嵌入(MLLE)
......@@ -107,9 +110,8 @@ MLLE 算法分为三部分:
* ![k](img/f93871977da52a6d11045d57c3e18728.jpg) : 最近邻域的个数
* ![d](img/adf83056bc2bd05628e24c40cb728b3d.jpg) : 输出的维度
参考文献:
* [“MLLE: Modified Locally Linear Embedding Using Multiple Weights”](http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.70.382) Zhang, Z. & Wang, J.
>参考文献:
>* [“MLLE: Modified Locally Linear Embedding Using Multiple Weights”](http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.70.382) Zhang, Z. & Wang, J.
## 2.2.5\. 黑塞特征映射(HE)
......@@ -132,9 +134,8 @@ HLLE 算法分为三部分:
* ![k](img/f93871977da52a6d11045d57c3e18728.jpg) : 最近邻域的个数
* ![d](img/adf83056bc2bd05628e24c40cb728b3d.jpg) : 输出的维度
参考文献:
* [“Hessian Eigenmaps: Locally linear embedding techniques for high-dimensional data”](http://www.pnas.org/content/100/10/5591) Donoho, D. & Grimes, C. Proc Natl Acad Sci USA. 100:5591 (2003)
>参考文献:
>* [“Hessian Eigenmaps: Locally linear embedding techniques for high-dimensional data”](http://www.pnas.org/content/100/10/5591) Donoho, D. & Grimes, C. Proc Natl Acad Sci USA. 100:5591 (2003)
## 2.2.6\. 谱嵌入
......@@ -155,9 +156,8 @@ HLLE 算法分为三部分:
* ![k](img/f93871977da52a6d11045d57c3e18728.jpg) : 最近邻域的个数
* ![d](img/adf83056bc2bd05628e24c40cb728b3d.jpg) : 输出的维度
参考文献:
* [“Laplacian Eigenmaps for Dimensionality Reduction and Data Representation”](http://web.cse.ohio-state.edu/~mbelkin/papers/LEM_NC_03.pdf) M. Belkin, P. Niyogi, Neural Computation, June 2003; 15 (6):1373-1396
>参考文献:
>* [“Laplacian Eigenmaps for Dimensionality Reduction and Data Representation”](http://web.cse.ohio-state.edu/~mbelkin/papers/LEM_NC_03.pdf) M. Belkin, P. Niyogi, Neural Computation, June 2003; 15 (6):1373-1396
## 2.2.7\. 局部切空间对齐(LTSA)
......@@ -180,9 +180,8 @@ LTSA 算法含三部分:
* ![k](img/f93871977da52a6d11045d57c3e18728.jpg) : 最近邻域的个数
* ![d](img/adf83056bc2bd05628e24c40cb728b3d.jpg) : 输出的维度
参考文献:
* [“Principal manifolds and nonlinear dimensionality reduction via tangent space alignment”](http://citeseer.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.3693) Zhang, Z. & Zha, H. Journal of Shanghai Univ. 8:406 (2004)
>参考文献:
>* [“Principal manifolds and nonlinear dimensionality reduction via tangent space alignment”](http://citeseer.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.3693) Zhang, Z. & Zha, H. Journal of Shanghai Univ. 8:406 (2004)
## 2.2.8\. 多维尺度分析(MDS)
......@@ -210,11 +209,10 @@ MDS算法有2类:度量和非度量。在 scikit-learn 中, [`MDS`](https://
[![http://sklearn.apachecn.org/cn/0.19.0/_images/sphx_glr_plot_mds_0011.png](img/fe62193b4391c9f60e373f03623696ac.jpg)](https://scikit-learn.org/stable/auto_examples/manifold/plot_mds.html)
参考文献:
* [“Modern Multidimensional Scaling - Theory and Applications”](http://www.springer.com/fr/book/9780387251509) Borg, I.; Groenen P. Springer Series in Statistics (1997)
* [“Nonmetric multidimensional scaling: a numerical method”](http://link.springer.com/article/10.1007%2FBF02289694) Kruskal, J. Psychometrika, 29 (1964)
* [“Multidimensional scaling by optimizing goodness of fit to a nonmetric hypothesis”](http://link.springer.com/article/10.1007%2FBF02289565) Kruskal, J. Psychometrika, 29, (1964)
>参考文献:
>* [“Modern Multidimensional Scaling - Theory and Applications”](http://www.springer.com/fr/book/9780387251509) Borg, I.; Groenen P. Springer Series in Statistics (1997)
>* [“Nonmetric multidimensional scaling: a numerical method”](http://link.springer.com/article/10.1007%2FBF02289694) Kruskal, J. Psychometrika, 29 (1964)
>* [“Multidimensional scaling by optimizing goodness of fit to a nonmetric hypothesis”](http://link.springer.com/article/10.1007%2FBF02289565) Kruskal, J. Psychometrika, 29, (1964)
## 2.2.9\. t 分布随机邻域嵌入(t-SNE)
......@@ -268,11 +266,10 @@ t-SNE 的主要目的是实现高维数据的可视化。因此,当数据将
还要注意,数字 label 与 t-SNE 发现的自然聚类大致匹配,而 PCA 模型的线性 2D 投影产生标签区域在很大程度上重叠的表示。这是一个强有力的线索,表明该数据可以通过关注局部结构的非线性方法(例如,具有高斯 RBF 核的 SVM )很好地分离。然而,如果不能在二维中用 t-SNE 来可视化分离良好的均匀标记组,并不一定意味着数据不能被监督模型正确地分类。可能是因为 2 维不够低,无法准确表示数据的内部结构。
参考文献:
* [“Visualizing High-Dimensional Data Using t-SNE”](http://jmlr.org/papers/v9/vandermaaten08a.html) van der Maaten, L.J.P.; Hinton, G. Journal of Machine Learning Research (2008)
* [“t-Distributed Stochastic Neighbor Embedding”](http://lvdmaaten.github.io/tsne/) van der Maaten, L.J.P.
* [“Accelerating t-SNE using Tree-Based Algorithms.”](https://lvdmaaten.github.io/publications/papers/JMLR_2014.pdf) L.J.P. van der Maaten. Journal of Machine Learning Research 15(Oct):3221-3245, 2014.
>参考文献:
>* [“Visualizing High-Dimensional Data Using t-SNE”](http://jmlr.org/papers/v9/vandermaaten08a.html) van der Maaten, L.J.P.; Hinton, G. Journal of Machine Learning Research (2008)
>* [“t-Distributed Stochastic Neighbor Embedding”](http://lvdmaaten.github.io/tsne/) van der Maaten, L.J.P.
>* [“Accelerating t-SNE using Tree-Based Algorithms.”](https://lvdmaaten.github.io/publications/papers/JMLR_2014.pdf) L.J.P. van der Maaten. Journal of Machine Learning Research 15(Oct):3221-3245, 2014.
## 2.2.10\. 实用技巧
......@@ -281,6 +278,4 @@ t-SNE 的主要目的是实现高维数据的可视化。因此,当数据将
* 注意,噪声数据可以对流形造成“短路”,其实质上充当了一个桥梁,用于连接流形的不同部分,否则(没有这样的“桥梁”)这些流形将被很好地划分开。噪声和/或不完全数据的流形学习是一个活跃的研究领域。
* 某些输入配置可能导致奇异加权矩阵,例如,当数据集中的两个以上点完全相同时,或者当数据被分割成不连续的组时。在这种情况下, `solver='arpack'` 将无法找到空空间。解决这一问题的最简单方法是使用 `solver='dense'` ,它将在一个奇异矩阵上进行,尽管它可能因为输入点的数量而非常缓慢。或者,人们可以尝试理解奇异的来源:如果它是由于不相交的集合,增加 `n_neighbors` 可能有所帮助;如果是由于数据集中的相同点,则删除这些点可能有所帮助。
See also
[完全随机树嵌入](ensemble.html#random-trees-embedding) 也可以用于得到特征空间的非线性表示,另外它不用降维。
\ No newline at end of file
>See also:[完全随机树嵌入](ensemble.html#random-trees-embedding) 也可以用于得到特征空间的非线性表示,另外它不用降维。
此差异已折叠。
......@@ -44,19 +44,15 @@ array([[ 1, 2],
一些模块也有 `row_labels_``column_labels_` 属性。 这些模块对行列进行分区, 例如对角线或者棋盘 bicluster 结构。
Note
Biclustering 在不同的领域有很多其他名称,包括 co-clustering, two-mode clustering, two-way clustering, block clustering, coupled two-way clustering 等.有一些算法的名称,比如 Spectral Co-Clustering algorithm, 反应了这些备用名称。
>**注意**
>Biclustering 在不同的领域有很多其他名称,包括 co-clustering, two-mode clustering, two-way clustering, block clustering, coupled two-way clustering 等.有一些算法的名称,比如 Spectral Co-Clustering algorithm, 反应了这些备用名称。
## 2.4.1\. Spectral Co-Clustering
> [`SpectralCoclustering`](https://scikit-learn.org/stable/modules/generated/sklearn.cluster.bicluster.SpectralCoclustering.html#sklearn.cluster.bicluster.SpectralCoclustering "sklearn.cluster.bicluster.SpectralCoclustering") 算法找到的 bicluster 的值比相应的其他行和列更高。
每一个行和列都只属于一个 bicluster, 所以重新分配行和列,使得分区连续显示对角线上的 high value:
Note
[`SpectralCoclustering`](https://scikit-learn.org/stable/modules/generated/sklearn.cluster.bicluster.SpectralCoclustering.html#sklearn.cluster.bicluster.SpectralCoclustering "sklearn.cluster.bicluster.SpectralCoclustering") 算法找到的 bicluster 的值比相应的其他行和列更高。每一个行和列都只属于一个 bicluster, 所以重新分配行和列,使得分区连续显示对角线上的 high value:
算法将输入的数据矩阵看做成二分图:该矩阵的行和列对应于两组顶点,每个条目对应于行和列之间的边,该算法近似的进行归一化,对图进行切割,找到更重的子图。
>**注意**
>算法将输入的数据矩阵看做成二分图:该矩阵的行和列对应于两组顶点,每个条目对应于行和列之间的边,该算法近似的进行归一化,对图进行切割,找到更重的子图。
### 2.4.1.1\. 数学公式
......@@ -83,18 +79,16 @@ Note
然后 ![Z](img/8f4e82e4dfa89ac81c42992c603a953e.jpg) 的 rows 通过使用 [k-means](clustering.html#k-means) 进行聚类. `n_rows` 标签提供行分区, 剩下的 `n_columns` 标签 提供 列分区。
例子:
>例子:
>* [A demo of the Spectral Co-Clustering algorithm](https://scikit-learn.org/stable/auto_examples/bicluster/plot_spectral_coclustering.html#sphx-glr-auto-examples-bicluster-plot-spectral-coclustering-py): 如何用 bicluster 数据矩阵并应用。
>* [Biclustering documents with the Spectral Co-clustering algorithm](https://scikit-learn.org/stable/auto_examples/bicluster/plot_bicluster_newsgroups.html#sphx-glr-auto-examples-bicluster-plot-bicluster-newsgroups-py):一个在 20 个新闻组数据集中发现 biclusters 的例子
* [A demo of the Spectral Co-Clustering algorithm](https://scikit-learn.org/stable/auto_examples/bicluster/plot_spectral_coclustering.html#sphx-glr-auto-examples-bicluster-plot-spectral-coclustering-py): 如何用 bicluster 数据矩阵并应用。
* [Biclustering documents with the Spectral Co-clustering algorithm](https://scikit-learn.org/stable/auto_examples/bicluster/plot_bicluster_newsgroups.html#sphx-glr-auto-examples-bicluster-plot-bicluster-newsgroups-py):一个在 20 个新闻组数据集中发现 biclusters 的例子
参考文献:
* Dhillon, Inderjit S, 2001\. [Co-clustering documents and words using bipartite spectral graph partitioning](http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.140.3011).
>参考文献:
>* Dhillon, Inderjit S, 2001\. [Co-clustering documents and words using bipartite spectral graph partitioning](http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.140.3011).
## 2.4.2\. Spectral Biclustering
> [`SpectralBiclustering`](https://scikit-learn.org/stable/modules/generated/sklearn.cluster.bicluster.SpectralBiclustering.html#sklearn.cluster.bicluster.SpectralBiclustering "sklearn.cluster.bicluster.SpectralBiclustering") 算法假设输入的数据矩阵具有隐藏的棋盘结构。 具有这种结构的矩阵的行列 可能被分区,使得在笛卡尔积中的 大部分 biclusters 的 row clusters 和 column cluster 是近似恒定的。
[`SpectralBiclustering`](https://scikit-learn.org/stable/modules/generated/sklearn.cluster.bicluster.SpectralBiclustering.html#sklearn.cluster.bicluster.SpectralBiclustering "sklearn.cluster.bicluster.SpectralBiclustering") 算法假设输入的数据矩阵具有隐藏的棋盘结构。 具有这种结构的矩阵的行列 可能被分区,使得在笛卡尔积中的 大部分 biclusters 的 row clusters 和 column cluster 是近似恒定的。
例如,如果有两个row 分区和三个列分区,每一行属于三个 bicluster ,每一列属于两个 bicluster。
......@@ -105,11 +99,9 @@ Note
输入矩阵 ![A](img/eeaf066f8cca5064b706ccfc4728323d.jpg) 先归一化,使得棋盘模式更明显。有三种方法:
1. _独立的行和列归一化_, as in Spectral Co-Clustering. 这个方法使得行和一个常数相加,列和变量相加。
2. **Bistochastization**: 重复行和列归一化直到收敛。该方法使得行和列都相加
   相同的常数。
2. **Bistochastization**: 重复行和列归一化直到收敛。该方法使得行和列都相加相同的常数。
1. **Log 归一化**: 计算数据矩阵的对数 ![L =
3. **Log 归一化**: 计算数据矩阵的对数 ![L =
\log A](img/515ee7781876d7344cc383bb43cb30ea.jpg). 列就是 ![\overline{L_{i \cdot}}](img/7ba11d33e68a1e32f2d8d9387bbc1eba.jpg), 行就是 ![\overline{L_{\cdot j}}](img/dc8f095e63b3defdb85fcf54d7d2d8c2.jpg), 总体上来看 ![\overline{L_{\cdot
\cdot}}](img/a0bb00db4979d538e9ca2f0a8b423286.jpg) of ![L](img/639e82f3829a0ad677110cc33a028c98.jpg) 被计算的. 最后矩阵通过下面的公式计算
......@@ -126,17 +118,14 @@ j}} + \overline{L_{\cdot \cdot}}](img/d670eea3215462f64d74d9366622a490.jpg)
例如,如果 ![p](img/e2f9b08680b30cfb80102f69264fdd5c.jpg) 奇异值向量被计算,最好按照描述找到 ![q](img/dc074c105944810a277030dfab298376.jpg) , 其中 ![q<p](img/cc9d324e8bc61a67cc1947f73bf5b618.jpg)。 ![U](img/11c00539ec3e5944afd76511830591db.jpg) 列为,the ![q](img/dc074c105944810a277030dfab298376.jpg) 最佳左奇异向量的矩阵, 并且 ![V](img/5303ecbc70bf5189b8785555c03c54ee.jpg) 对于右边是类似的. 要划分行, 将 ![A](img/eeaf066f8cca5064b706ccfc4728323d.jpg) 的 投影到 ![q](img/dc074c105944810a277030dfab298376.jpg) 维空间: ![A * V](img/99988260d9d836d14b2569c2fc921e81.jpg)。 ![m](img/94156b879a7455cb0d516efa9c9c0991.jpg) 行 ![m \times q](img/ccc8bedf9424617c5d6a61fbe9a1cc36.jpg) 矩阵的行作为采样和使用 k-means 的聚类处理产生行标签。 类似地,将列投影到 ![A^{\top} * U](img/c57acf47ae694e71f55f0005d1e52c55.jpg) ,并且对 ![n \times q](img/cd58ff0ab17f3ead1d5179426f2dae50.jpg) 矩阵进行聚类得到列标签。
示例:
>示例:
>* [A demo of the Spectral Biclustering algorithm](https://scikit-learn.org/stable/auto_examples/bicluster/plot_spectral_biclustering.html#sphx-glr-auto-examples-bicluster-plot-spectral-biclustering-py): 一个简单的例子 显示如何生成棋盘矩阵和 bicluster
* [A demo of the Spectral Biclustering algorithm](https://scikit-learn.org/stable/auto_examples/bicluster/plot_spectral_biclustering.html#sphx-glr-auto-examples-bicluster-plot-spectral-biclustering-py): 一个简单的例子 显示如何生成棋盘矩阵和 bicluster
.
>参考文献:
>* Kluger, Yuval, et. al., 2003\. [Spectral biclustering of microarray data: coclustering genes and conditions](http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.135.1608).
参考文献:
* Kluger, Yuval, et. al., 2003\. [Spectral biclustering of microarray data: coclustering genes and conditions](http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.135.1608).
## 2.4.3\. Biclustering 评测
## 2.4.3\. Biclustering 评价
有两种评估双组分结果的方法:内部和外部。 诸如群集稳定性等内部措施只依赖于数据和结果本身。 目前在scikit-learn中没有内部的二集群措施。外部措施是指外部信息来源,例如真正的解决方案。 当使用真实数据时,真正的解决方案通常是未知的,但是,由于真正的解决方案是已知的,因此人造数据的双重分析可能对于评估算法非常有用。
......@@ -146,13 +135,12 @@ j}} + \overline{L_{\cdot \cdot}}](img/d670eea3215462f64d74d9366622a490.jpg)
![J(A, B) = \frac{|A \cap B|}{|A| + |B| - |A \cap B|}](img/287e15c4b3d9b3f227fdc8e364609382.jpg)
```py
biclusters, 是交叉点的元素的数量
```
其中A和B是 biclusters, |A∩B| 是交叉点的元素的数量。
Jaccard 索引 达到最小值0,当 biclusters 不重叠的时候,并且当他们相同干的时候,最大值为1。
Jaccard 索引 达到最小值0,当biclusters完全不同时,Jaccard指数最小值为0;当biclusters完全相同时,Jaccard指数最大值为1。
些方法已经开发出来,用来比较两个 biclusters 的数据集。 从现在开始 之后 [`consensus_score`](https://scikit-learn.org/stable/modules/generated/sklearn.metrics.consensus_score.html#sklearn.metrics.consensus_score "sklearn.metrics.consensus_score") (Hochreiter et. al., 2010) 是可以用:
些方法已经开发出来,用来比较两个 biclusters 的数据集。 从现在开始 之后 [`consensus_score`](https://scikit-learn.org/stable/modules/generated/sklearn.metrics.consensus_score.html#sklearn.metrics.consensus_score "sklearn.metrics.consensus_score") (Hochreiter et. al., 2010) 是可以用:
1. 使用 Jaccard 索引或类似措施,计算 biclusters 的 bicluster 相似性。
2. 以一对一的方式将 bicluster 分从一组分配给另一组,以最大化其相似性的总和。该步骤使用匈牙利算法执行。
......@@ -160,6 +148,5 @@ Jaccard 索引 达到最小值0,当 biclusters 不重叠的时候,并且当
最小共识得分为0,发生在所有 biclusters 完全不相似时。当两组 biclusters 相同时,最大分数为1。
参考文献:
* Hochreiter, Bodenhofer, et. al., 2010\. [FABIA: factor analysis for bicluster acquisition](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2881408/).
\ No newline at end of file
>参考文献:
>* Hochreiter, Bodenhofer, et. al., 2010\. [FABIA: factor analysis for bicluster acquisition](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2881408/).
此差异已折叠。
......@@ -3,6 +3,7 @@
校验者:
        [@李昊伟](https://github.com/apachecn/scikit-learn-doc-zh)
        [@小瑶](https://github.com/apachecn/scikit-learn-doc-zh)
[@Loopy](https://github.com/loopyme)
翻译者:
        [@柠檬](https://github.com/apachecn/scikit-learn-doc-zh)
......@@ -16,9 +17,8 @@
样本的经验协方差矩阵可以使用 [`empirical_covariance`](https://scikit-learn.org/stable/modules/generated/sklearn.covariance.empirical_covariance.html#sklearn.covariance.empirical_covariance "sklearn.covariance.empirical_covariance") 包的函数计算 , 或者通过 [`EmpiricalCovariance`](https://scikit-learn.org/stable/modules/generated/sklearn.covariance.EmpiricalCovariance.html#sklearn.covariance.EmpiricalCovariance "sklearn.covariance.EmpiricalCovariance") 使用 [`EmpiricalCovariance.fit`](https://scikit-learn.org/stable/modules/generated/sklearn.covariance.EmpiricalCovariance.html#sklearn.covariance.EmpiricalCovariance.fit "sklearn.covariance.EmpiricalCovariance.fit") 方法将对象与数据样本拟合 。 要注意,取决于数据是否居中,结果会有所不同,所以可能需要准确使用参数 `assume_centered`。 如果使用 `assume_centered=False` ,则结果更准确。且测试集应该具有与训练集相同的均值向量。 如果不是这样,两者都应该使用中心值, `assume_centered=True` 应该使用。
例子:
* See [Shrinkage covariance estimation: LedoitWolf vs OAS and max-likelihood](https://scikit-learn.org/stable/auto_examples/covariance/plot_covariance_estimation.html#sphx-glr-auto-examples-covariance-plot-covariance-estimation-py) for an example on how to fit an [`EmpiricalCovariance`](https://scikit-learn.org/stable/modules/generated/sklearn.covariance.EmpiricalCovariance.html#sklearn.covariance.EmpiricalCovariance "sklearn.covariance.EmpiricalCovariance") object to data.
>例子:
>* See [Shrinkage covariance estimation: LedoitWolf vs OAS and max-likelihood](https://scikit-learn.org/stable/auto_examples/covariance/plot_covariance_estimation.html#sphx-glr-auto-examples-covariance-plot-covariance-estimation-py) for an example on how to fit an [`EmpiricalCovariance`](https://scikit-learn.org/stable/modules/generated/sklearn.covariance.EmpiricalCovariance.html#sklearn.covariance.EmpiricalCovariance "sklearn.covariance.EmpiricalCovariance") object to data.
# 2.6.2\. 收敛协方差
......@@ -34,9 +34,8 @@ Tr}\hat{\Sigma}}{p}\rm Id](img/8f62a01deaf67a7f9960d853abd9dcca.jpg).
选择收缩量, ![\alpha](img/d8b3d5242d513369a44f8bf0c6112744.jpg) 相当于设置偏差/方差权衡,下面将讨论。
示例:
* See [Shrinkage covariance estimation: LedoitWolf vs OAS and max-likelihood](https://scikit-learn.org/stable/auto_examples/covariance/plot_covariance_estimation.html#sphx-glr-auto-examples-covariance-plot-covariance-estimation-py) for an example on how to fit a [`ShrunkCovariance`](https://scikit-learn.org/stable/modules/generated/sklearn.covariance.ShrunkCovariance.html#sklearn.covariance.ShrunkCovariance "sklearn.covariance.ShrunkCovariance") object to data.
>示例:
>* See [Shrinkage covariance estimation: LedoitWolf vs OAS and max-likelihood](https://scikit-learn.org/stable/auto_examples/covariance/plot_covariance_estimation.html#sphx-glr-auto-examples-covariance-plot-covariance-estimation-py) for an example on how to fit a [`ShrunkCovariance`](https://scikit-learn.org/stable/modules/generated/sklearn.covariance.ShrunkCovariance.html#sklearn.covariance.ShrunkCovariance "sklearn.covariance.ShrunkCovariance") object to data.
## 2.6.2.2\. Ledoit-Wolf 收敛
......@@ -44,13 +43,17 @@ Tr}\hat{\Sigma}}{p}\rm Id](img/8f62a01deaf67a7f9960d853abd9dcca.jpg).
*sklearn.covariance* 包中,可以使用 [`ledoit_wolf`](https://scikit-learn.org/stable/modules/generated/sklearn.covariance.ledoit_wolf.html#sklearn.covariance.ledoit_wolf "sklearn.covariance.ledoit_wolf") 函数来计算样本的 基于 Ledoit-Wolf estimator 的协方差, 或者可以针对同样的样本 通过拟合 [`LedoitWolf`](https://scikit-learn.org/stable/modules/generated/sklearn.covariance.LedoitWolf.html#sklearn.covariance.LedoitWolf "sklearn.covariance.LedoitWolf") 对象来获得。
例子:
>**注意**:体协方差矩阵为各向同性(isotropic)的情形
>
>值得注意的是,当样本数量远远大于特征数量时,人们会认为不需要收缩。这背后的直觉是,如果总体协方差是满秩的, 当样本数量增加时,样本协方差也会变为正定。因此,没有收缩的必要,该方法应该自动做到这一点。
>
>然而,当总体协方差恰好是恒等矩阵(identity matrix)的倍数时,在Ledoit-Wolf过程中就不是这样了。 在这种情况下,Ledoit-Wolf收缩估计值随着样本数的增加而接近1。 这表明,Ledoit-Wolf意义下协方差矩阵的最优估计是恒等式的倍数(multiple of the identity)。 由于总体协方差已经是恒等矩阵的倍数,Ledoit-Wolf解确实是一个合理的估计。
* See [Shrinkage covariance estimation: LedoitWolf vs OAS and max-likelihood](https://scikit-learn.org/stable/auto_examples/covariance/plot_covariance_estimation.html#sphx-glr-auto-examples-covariance-plot-covariance-estimation-py) 关于如何将 [`LedoitWolf`](https://scikit-learn.org/stable/modules/generated/sklearn.covariance.LedoitWolf.html#sklearn.covariance.LedoitWolf "sklearn.covariance.LedoitWolf") 对象与数据拟合, 并将 Ledoit-Wolf 估计器的性能进行可视化的示例。
>例子:
>* See [Shrinkage covariance estimation: LedoitWolf vs OAS and max-likelihood](https://scikit-learn.org/stable/auto_examples/covariance/plot_covariance_estimation.html#sphx-glr-auto-examples-covariance-plot-covariance-estimation-py) 关于如何将 [`LedoitWolf`](https://scikit-learn.org/stable/modules/generated/sklearn.covariance.LedoitWolf.html#sklearn.covariance.LedoitWolf "sklearn.covariance.LedoitWolf") 对象与数据拟合, 并将 Ledoit-Wolf 估计器的性能进行可视化的示例。
参考文献:
| [[1]](#id5) | O. Ledoit and M. Wolf, “A Well-Conditioned Estimator for Large-Dimensional Covariance Matrices”, Journal of Multivariate Analysis, Volume 88, Issue 2, February 2004, pages 365-411. |
>参考文献:
>* [1] O. Ledoit and M. Wolf, “A Well-Conditioned Estimator for Large-Dimensional Covariance Matrices”, Journal of Multivariate Analysis, Volume 88, Issue 2, February 2004, pages 365-411.
## 2.6.2.3\. Oracle 近似收缩
......@@ -62,14 +65,12 @@ Tr}\hat{\Sigma}}{p}\rm Id](img/8f62a01deaf67a7f9960d853abd9dcca.jpg).
设定收缩时的偏差方差权衡:比较 Ledoit-Wolf 和 OAS 估计量的选择
参考文献:
| [[2]](#id7) | Chen et al., “Shrinkage Algorithms for MMSE Covariance Estimation”, IEEE Trans. on Sign. Proc., Volume 58, Issue 10, October 2010. |
>参考文献:
>* [2]Chen et al., “Shrinkage Algorithms for MMSE Covariance Estimation”, IEEE Trans. on Sign. Proc., Volume 58, Issue 10, October 2010.
示例:
* See [Shrinkage covariance estimation: LedoitWolf vs OAS and max-likelihood](https://scikit-learn.org/stable/auto_examples/covariance/plot_covariance_estimation.html#sphx-glr-auto-examples-covariance-plot-covariance-estimation-py) for an example on how to fit an [`OAS`](https://scikit-learn.org/stable/modules/generated/sklearn.covariance.OAS.html#sklearn.covariance.OAS "sklearn.covariance.OAS") object to data.
* See [Ledoit-Wolf vs OAS estimation](https://scikit-learn.org/stable/auto_examples/covariance/plot_lw_vs_oas.html#sphx-glr-auto-examples-covariance-plot-lw-vs-oas-py) to visualize the Mean Squared Error difference between a [`LedoitWolf`](https://scikit-learn.org/stable/modules/generated/sklearn.covariance.LedoitWolf.html#sklearn.covariance.LedoitWolf "sklearn.covariance.LedoitWolf") and an [`OAS`](https://scikit-learn.org/stable/modules/generated/sklearn.covariance.OAS.html#sklearn.covariance.OAS "sklearn.covariance.OAS") estimator of the covariance.
>示例:
>* See [Shrinkage covariance estimation: LedoitWolf vs OAS and max-likelihood](https://scikit-learn.org/stable/auto_examples/covariance/plot_covariance_estimation.html#sphx-glr-auto-examples-covariance-plot-covariance-estimation-py) for an example on how to fit an [`OAS`](https://scikit-learn.org/stable/modules/generated/sklearn.covariance.OAS.html#sklearn.covariance.OAS "sklearn.covariance.OAS") object to data.
>* See [Ledoit-Wolf vs OAS estimation](https://scikit-learn.org/stable/auto_examples/covariance/plot_lw_vs_oas.html#sphx-glr-auto-examples-covariance-plot-lw-vs-oas-py) to visualize the Mean Squared Error difference between a [`LedoitWolf`](https://scikit-learn.org/stable/modules/generated/sklearn.covariance.LedoitWolf.html#sklearn.covariance.LedoitWolf "sklearn.covariance.LedoitWolf") and an [`OAS`](https://scikit-learn.org/stable/modules/generated/sklearn.covariance.OAS.html#sklearn.covariance.OAS "sklearn.covariance.OAS") estimator of the covariance.
[![http://sklearn.apachecn.org/cn/0.19.0/_images/sphx_glr_plot_lw_vs_oas_0011.png](img/bc35316fd422689a9bc65845d63c1433.jpg)](https://scikit-learn.org/stable/auto_examples/covariance/plot_lw_vs_oas.html)
......@@ -83,42 +84,33 @@ Tr}\hat{\Sigma}}{p}\rm Id](img/8f62a01deaf67a7f9960d853abd9dcca.jpg).
[![http://sklearn.apachecn.org/cn/0.19.0/_images/sphx_glr_plot_sparse_cov_0011.png](img/7c9ce57d4e2ba5270352f4e118af7fac.jpg)](https://scikit-learn.org/stable/auto_examples/covariance/plot_sparse_cov.html)
Note
**结构恢复**
从数据中的相关性恢复图形结构是一个具有挑战性的事情。如果您对这种恢复感兴趣,请记住:
* 相关矩阵的恢复比协方差矩阵更容易:在运行 [`GraphLasso`](https://scikit-learn.org/stable/modules/generated/sklearn.covariance.GraphLasso.html#sklearn.covariance.GraphLasso "sklearn.covariance.GraphLasso") 前先标准化观察值
* 如果底层图具有比平均节点更多的连接节点,则算法将错过其中一些连接。
* 如果您的观察次数与底层图形中的边数相比不大,则不会恢复。
* 即使您具有良好的恢复条件,通过交叉验证(例如使用GraphLassoCV对象)选择的 Alpha 参数将导致选择太多边。 然而,相关边缘将具有比不相关边缘更重的权重。
> **注意**:**结构恢复**
>
>从数据中的相关性恢复图形结构是一个具有挑战性的事情。如果您对这种恢复感兴趣,请记住:
>* 相关矩阵的恢复比协方差矩阵更容易:在运行 [`GraphLasso`](https://scikit-learn.org/stable/modules/generated/sklearn.covariance.GraphLasso.html#sklearn.covariance.GraphLasso "sklearn.covariance.GraphLasso") 前先标准化观察值
>* 如果底层图具有比平均节点更多的连接节点,则算法将错过其中一些连接。
>* 如果您的观察次数与底层图形中的边数相比不大,则不会恢复。
>* 即使您具有良好的恢复条件,通过交叉验证(例如使用GraphLassoCV对象)选择的 Alpha 参数将导致选择太多边。 然而,相关的边会比不相关的边有更重的权重。
数学公式如下:
![\hat{K} = \mathrm{argmin}_K \big(\mathrm{tr} S K - \mathrm{log} \mathrm{det} K+ \alpha \|K\|_1\big)](img/43996aff9311511e6e2f81912a249c7e.jpg)
其中:![K](img/e279b8169ddd6581c5606c868ba52fae.jpg) 是要估计的精度矩阵(precision matrix), ![S](img/12ecd862769bee1e71c75c134b6423bb.jpg) 是样本的协方差矩阵。 ![\|K\|_1](img/6122e23454910f4f076c71a84c068291.jpg) 是非对角系数 ![K](img/e279b8169ddd6581c5606c868ba52fae.jpg) (off-diagonal coefficients)的绝对值之和。 用于解决这个问题的算法是来自 Friedman 2008 Biostatistics 论文的 GLasso 算法。 它与 R 语言 `glasso` 包中的算法相同。
例子:
* [Sparse inverse covariance estimation](https://scikit-learn.org/stable/auto_examples/covariance/plot_sparse_cov.html#sphx-glr-auto-examples-covariance-plot-sparse-cov-py):
合成数据示例,显示结构的一些恢复,并与其他协方差估计器进行比较。
* [Visualizing the stock market structure](https://scikit-learn.org/stable/auto_examples/applications/plot_stock_market.html#sphx-glr-auto-examples-applications-plot-stock-market-py): 真实股票市场数据示例,查找哪些信号最相关。
>例子:
>* [Sparse inverse covariance estimation](https://scikit-learn.org/stable/auto_examples/covariance/plot_sparse_cov.html#sphx-glr-auto-examples-covariance-plot-sparse-cov-py):合成数据示例,显示结构的一些恢复,并与其他协方差估计器进行比较。
>* [Visualizing the stock market structure](https://scikit-learn.org/stable/auto_examples/applications/plot_stock_market.html#sphx-glr-auto-examples-applications-plot-stock-market-py): 真实股票市场数据示例,查找哪些信号最相关。
参考文献:
* Friedman et al, [“Sparse inverse covariance estimation with the graphical lasso”](http://biostatistics.oxfordjournals.org/content/9/3/432.short), Biostatistics 9, pp 432, 2008
>参考文献:
>* Friedman et al, [“Sparse inverse covariance estimation with the graphical lasso”](http://biostatistics.oxfordjournals.org/content/9/3/432.short), Biostatistics 9, pp 432, 2008
# 2.6.4\. Robust 协方差估计
实际数据集通常是会有测量或记录错误。合格但不常见的观察也可能出于各种原因。 每个不常见的观察称为异常值。 上面提出的经验协方差估计器和收缩协方差估计器对数据中异常观察值非常敏感。 因此,应该使用更好的协方差估计(robust covariance estimators)来估算其真实数据集的协方差。 或者,可以使用更好的协方差估计器(robust covariance estimators)来执行异常值检测, 并根据数据的进一步处理,丢弃/降低某些观察值。
`sklearn.covariance` 包实现了 robust estimator of covariance, 即 Minimum Covariance Determinant [[3]](#id14)
`sklearn.covariance` 包实现了 robust estimator of covariance, 即 Minimum Covariance Determinant [3]
## 2.6.4.1\. 最小协方差决定
......@@ -128,17 +120,14 @@ Rousseeuw 和 Van Driessen [[4]](#id15) 开发了 FastMCD 算法,以计算最
Raw估计可通过 [`MinCovDet`](https://scikit-learn.org/stable/modules/generated/sklearn.covariance.MinCovDet.html#sklearn.covariance.MinCovDet "sklearn.covariance.MinCovDet") 对象的 `raw_location_``raw_covariance_` 属性获得。
参考文献:
| [3] | _([1](#id10), [2](#id12))_ P. J. Rousseeuw. Least median of squares regression. J. Am Stat Ass, 79:871, 1984. |
| [[4]](#id13) | A Fast Algorithm for the Minimum Covariance Determinant Estimator, 1999, American Statistical Association and the American Society for Quality, TECHNOMETRICS. |
例子:
>参考文献:
>* [3] P. J. Rousseeuw. Least median of squares regression. J. Am Stat Ass, 79:871, 1984.
>* [4] A Fast Algorithm for the Minimum Covariance Determinant Estimator, 1999, American Statistical Association and the American Society for Quality, TECHNOMETRICS.
* See [Robust vs Empirical covariance estimate](https://scikit-learn.org/stable/auto_examples/covariance/plot_robust_vs_empirical_covariance.html#sphx-glr-auto-examples-covariance-plot-robust-vs-empirical-covariance-py) 关于如何将对象 [`MinCovDet`](https://scikit-learn.org/stable/modules/generated/sklearn.covariance.MinCovDet.html#sklearn.covariance.MinCovDet "sklearn.covariance.MinCovDet") 与数据拟合的示例, 尽管存在异常值,但估计结果仍然比较准确。
* See [Robust covariance estimation and Mahalanobis distances relevance](https://scikit-learn.org/stable/auto_examples/covariance/plot_mahalanobis_distances.html#sphx-glr-auto-examples-covariance-plot-mahalanobis-distances-py) 马氏距离(Mahalanobis distance),针对协方差估计器 [`EmpiricalCovariance`](https://scikit-learn.org/stable/modules/generated/sklearn.covariance.EmpiricalCovariance.html#sklearn.covariance.EmpiricalCovariance "sklearn.covariance.EmpiricalCovariance")[`MinCovDet`](https://scikit-learn.org/stable/modules/generated/sklearn.covariance.MinCovDet.html#sklearn.covariance.MinCovDet "sklearn.covariance.MinCovDet") 之间的差异进行可视化。(所以我们得到了精度矩阵的更好估计)
>例子:
>* See [Robust vs Empirical covariance estimate](https://scikit-learn.org/stable/auto_examples/covariance/plot_robust_vs_empirical_covariance.html#sphx-glr-auto-examples-covariance-plot-robust-vs-empirical-covariance-py) 关于如何将对象 [`MinCovDet`](https://scikit-learn.org/stable/modules/generated/sklearn.covariance.MinCovDet.html#sklearn.covariance.MinCovDet "sklearn.covariance.MinCovDet") 与数据拟合的示例, 尽管存在异常值,但估计结果仍然比较准确。
>* See [Robust covariance estimation and Mahalanobis distances relevance](https://scikit-learn.org/stable/auto_examples/covariance/plot_mahalanobis_distances.html#sphx-glr-auto-examples-covariance-plot-mahalanobis-distances-py) 马氏距离(Mahalanobis distance),针对协方差估计器 [`EmpiricalCovariance`](https://scikit-learn.org/stable/modules/generated/sklearn.covariance.EmpiricalCovariance.html#sklearn.covariance.EmpiricalCovariance "sklearn.covariance.EmpiricalCovariance") 和 [`MinCovDet`](https://scikit-learn.org/stable/modules/generated/sklearn.covariance.MinCovDet.html#sklearn.covariance.MinCovDet "sklearn.covariance.MinCovDet") 之间的差异进行可视化。(所以我们得到了精度矩阵的更好估计)
| Influence of outliers on location and covariance estimates | Separating inliers from outliers using a Mahalanobis distance |
| 异常值对位置和协方差估计的影响 | 使用Mahalanobis距离从异常值中分离异常值 |
| --- | --- |
| [![robust_vs_emp](img/e1b4d08b93d1d222e96d99475a766281.jpg)](https://scikit-learn.org/stable/auto_examples/covariance/plot_robust_vs_empirical_covariance.html) | [![mahalanobis](img/89807b9fa9f5924b027486f280324b1a.jpg)](https://scikit-learn.org/stable/auto_examples/covariance/plot_mahalanobis_distances.html) |
此差异已折叠。
# 2.12\. 密度估计
# 2.8\. 密度估计
校验者:
        [@不将就](https://github.com/apachecn/scikit-learn-doc-zh)
......@@ -9,7 +9,7 @@
密度估计是一个非常简单的概念,大多数人已经熟悉了其中一种常用的密度估计技术:直方图。
## 2.12.1\. 密度估计: 直方图
## 2.8.1\. 密度估计: 直方图
直方图是一种简单的数据可视化方法,其中定义了组( bins ),并且统计了每个组( bin )中的数据点的数量。在下图的左上角中可以看到一个直方图的例子:
......@@ -21,7 +21,7 @@
这个可视化是核密度估计的一个例子,该例中用的是一种”顶帽”核(即每个点上的方块)。我们可以通过使用一种更平滑的核来得到一个更平滑的分布。上图右下角展示了一个高斯核密度估计,其中每个点都给总的分布贡献一条高斯曲线。结果是从数据中得到了一个平滑的密度估计,并且可作为一个强大的非参数模型用来估计这些点的分布。
## 2.12.2\. 核密度估计
## 2.8.2\. 核密度估计
[`sklearn.neighbors.KernelDensity`](https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.KernelDensity.html#sklearn.neighbors.KernelDensity "sklearn.neighbors.KernelDensity") 实现了 scikit-learn 中的核密度估计,它使用 Ball Tree 或 KD Tree 来进行高效查询(有关这些讨论请参见 [最近邻](neighbors.html#neighbors) )。尽管为了简单起见上述示例采用的是一维数据集,但实际上核密度估计能够用在任意维度上, 不过在实际应用中,维数灾难会导致其在高维上的性能降低。
......@@ -80,7 +80,7 @@ array([-0.41075698, -0.41075698, -0.41076071, -0.41075698, -0.41075698,
核密度估计可以与任何有效的距离度量一起使用(可用度量列表请参见 [`sklearn.neighbors.DistanceMetric`](https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.DistanceMetric.html#sklearn.neighbors.DistanceMetric "sklearn.neighbors.DistanceMetric") ), 但其结果被适当地归一化处理,仅适用于欧几里德度量标准。 一个特别有用的度量是测量球体上的点与点之间角距离 的 [Haversine distance](https://en.wikipedia.org/wiki/Haversine_formula) 。 下面是使用核密度估计来对地理空间数据进行可视化的示例,本例中南美大陆两种不同物种的观测分布如图:
**[![species_kde](../Images/97b3ab2cc18a43b00c07a1cf6e118798.jpg)](https://scikit-learn.org/stable/auto_examples/neighbors/plot_species_kde.html)**
[![species_kde](img/97b3ab2cc18a43b00c07a1cf6e118798.jpg)](https://scikit-learn.org/stable/auto_examples/neighbors/plot_species_kde.html)
核密度估计的另一个有用的应用是从数据集中学习出一个非参数生成模型,以便有效地从该生成模型中绘制新的样本。 以下是使用此过程创建一组新的手写数字的示例,使用的是高斯核对数据的 PCA 投影进行学习:
......@@ -88,8 +88,7 @@ array([-0.41075698, -0.41075698, -0.41076071, -0.41075698, -0.41075698,
“新”数据由输入数据线性组合而成,其权重根据 KDE 模型按概率给出。
示例:
* [Simple 1D Kernel Density Estimation](https://scikit-learn.org/stable/auto_examples/neighbors/plot_kde_1d.html#sphx-glr-auto-examples-neighbors-plot-kde-1d-py): 一维简单核密度估计的计算。
* [Kernel Density Estimation](https://scikit-learn.org/stable/auto_examples/neighbors/plot_digits_kde_sampling.html#sphx-glr-auto-examples-neighbors-plot-digits-kde-sampling-py): 使用核密度估计来学习手写数字数据生成模型,以及使用该模型绘制新样本的示例
* [Kernel Density Estimate of Species Distributions](https://scikit-learn.org/stable/auto_examples/neighbors/plot_species_kde.html#sphx-glr-auto-examples-neighbors-plot-species-kde-py): 使用Haversine距离度量来显示地理空间数据的核密度估计示例.
\ No newline at end of file
>示例:
>* [Simple 1D Kernel Density Estimation](https://scikit-learn.org/stable/auto_examples/neighbors/plot_kde_1d.html#sphx-glr-auto-examples-neighbors-plot-kde-1d-py): 一维简单核密度估计的计算。
>* [Kernel Density Estimation](https://scikit-learn.org/stable/auto_examples/neighbors/plot_digits_kde_sampling.html#sphx-glr-auto-examples-neighbors-plot-digits-kde-sampling-py): 使用核密度估计来学习手写数字数据生成模型,以及使用该模型绘制新样本的示例
>* [Kernel Density Estimate of Species Distributions](https://scikit-learn.org/stable/auto_examples/neighbors/plot_species_kde.html#sphx-glr-auto-examples-neighbors-plot-species-kde-py): 使用Haversine距离度量来显示地理空间数据的核密度估计示例.
# 2.13\. 神经网络模型(无监督)
# 2.9\. 神经网络模型(无监督)
校验者:
        [@不将就](https://github.com/apachecn/scikit-learn-doc-zh)
[@Loopy](https://github.com/loopyme)
翻译者:
        [@夜神月](https://github.com/apachecn/scikit-learn-doc-zh)
## 2.13.1\. 限制波尔兹曼机
## 2.9.1\. 限制波尔兹曼机
Restricted Boltzmann machines (RBM)(限制玻尔兹曼机)是基于概率模型的无监督非线性特征学习器。当用 RBM 或 RBMs 中的层次结构提取的特征在馈入线性分类器(如线性支持向量机或感知机)时通常会获得良好的结果。
......@@ -17,11 +18,10 @@ RBM 尝试使用特定图形模型最大化数据的可能性。所使用的参
[![http://sklearn.apachecn.org/cn/0.19.0/_images/sphx_glr_plot_rbm_logistic_classification_0011.png](img/3af1cb0026efe5789c3acf3669ff5bc6.jpg)](https://scikit-learn.org/stable/auto_examples/neural_networks/plot_rbm_logistic_classification.html)
示例:
>示例:
>* [Restricted Boltzmann Machine features for digit classification](https://scikit-learn.org/stable/auto_examples/neural_networks/plot_rbm_logistic_classification.html#sphx-glr-auto-examples-neural-networks-plot-rbm-logistic-classification-py)
* [Restricted Boltzmann Machine features for digit classification](https://scikit-learn.org/stable/auto_examples/neural_networks/plot_rbm_logistic_classification.html#sphx-glr-auto-examples-neural-networks-plot-rbm-logistic-classification-py)
### 2.13.1.1\. 图形模型和参数化
### 2.9.1.1\. 图形模型和参数化
RBM 的图形模型是一个全连接的二分图(fully-connected bipartite graph)。
......@@ -30,8 +30,7 @@ RBM 的图形模型是一个全连接的二分图(fully-connected bipartite gr
节点是随机变量,其状态取决于它连接到的其他节点的状态。 因此,为了简单起见,模型被参数化为连接的权重以及每个可见和隐藏单元的一个偏置项。 我们用能量函数衡量联合概率分布的质量:
![E(\mathbf{v}, \mathbf{h}) = \sum_i \sum_j w_{ij}v_ih_j + \sum_i b_iv_i
+ \sum_j c_jh_j](img/5959a6fe3c27570b7d474f26126eb628.jpg)
![E(\mathbf{v}, \mathbf{h}) = \sum_i \sum_j w_{ij}v_ih_j + \sum_i b_iv_i + \sum_j c_jh_j](img/5959a6fe3c27570b7d474f26126eb628.jpg)
在上面的公式中, ![\mathbf{b}](img/4dee38783cbd4faef5d5639ce23a5c59.jpg) 和 ![\mathbf{c}](img/a4dd5119f3eeb13b99180aab64917975.jpg) 分别是可见层和隐藏层的偏置向量。 模型的联合概率是根据能量来定义的:
......@@ -41,28 +40,26 @@ RBM 的图形模型是一个全连接的二分图(fully-connected bipartite gr
“限制”是指模型的二分图结构,它禁止隐藏单元之间或可见单元之间的直接交互。 这代表以下条件独立性成立:
![h_i \bot h_j | \mathbf{v} \\
v_i \bot v_j | \mathbf{h}](img/9521899a181a367c5873e61b9f7785ce.jpg)
![h_i \bot h_j | \mathbf{v} \\v_i \bot v_j | \mathbf{h}](img/9521899a181a367c5873e61b9f7785ce.jpg)
二分图结构允许使用高效的块吉比斯采样(block Gibbs sampling)进行推断。
### 2.13.1.2\. 伯努利限制玻尔兹曼机
### 2.9.1.2\. 伯努利限制玻尔兹曼机
[`BernoulliRBM`](https://scikit-learn.org/stable/modules/generated/sklearn.neural_network.BernoulliRBM.html#sklearn.neural_network.BernoulliRBM "sklearn.neural_network.BernoulliRBM") 中,所有单位都是二进制随机单元。 这意味着输入数据应该是二进制的,或者在 0 和 1 之间的实数值表示可见单元活跃或不活跃的概率。 这是一个很好的字符识别模型,其中的关注点是哪些像素是活跃的,哪些不是。 对于自然场景的图像,它不再适合,因为背景,深度和相邻像素的趋势取相同的值。
每个单位的条件概率分布由其接收的输入的sigmoid函数给出:
![P(v_i=1|\mathbf{h}) = \sigma(\sum_j w_{ij}h_j + b_i) \\
P(h_i=1|\mathbf{v}) = \sigma(\sum_i w_{ij}v_i + c_j)](img/e6811d3f6333e9490d602db8dc1e3d96.jpg)
![P(v_i=1|\mathbf{h}) = \sigma(\sum_j w_{ij}h_j + b_i) \\P(h_i=1|\mathbf{v}) = \sigma(\sum_i w_{ij}v_i + c_j)](img/e6811d3f6333e9490d602db8dc1e3d96.jpg)
其中 ![\sigma](img/8c4a5c99b21079b9fb1be49910ff96e3.jpg) 是Sigmoid函数:
![\sigma(x) = \frac{1}{1 + e^{-x}}](img/f1c8c9b812ae1b6ec189eda900e47269.jpg)
### 2.13.1.3\. 随机最大似然学习
### 2.9.1.3\. 随机最大似然学习
[`BernoulliRBM`](https://scikit-learn.org/stable/modules/generated/sklearn.neural_network.BernoulliRBM.html#sklearn.neural_network.BernoulliRBM "sklearn.neural_network.BernoulliRBM") 函数中实现的学习算法被称为随机最大似然(Stochastic Maximum Likelihood (SML))或持续对比发散(Persistent Contrastive Divergence (PCD))。由于数据的似然函数的形式,直接优化最大似然是不可行的:
......@@ -76,7 +73,6 @@ P(h_i=1|\mathbf{v}) = \sigma(\sum_i w_{ij}v_i + c_j)](img/e6811d3f6333e9490d602d
持续的对比分歧解决这个问题。而不是每次需要梯度启动一个新的链,并且只执行一个 Gibbs 采样步骤,在 PCD 中,我们保留了在每个权重更新之后更新的 ![k](img/f93871977da52a6d11045d57c3e18728.jpg) Gibbs 步长的多个链(幻想粒子)。这使得颗粒更彻底地探索空间.
参考文献:
* [“A fast learning algorithm for deep belief nets”](http://www.cs.toronto.edu/~hinton/absps/fastnc.pdf) G. Hinton, S. Osindero, Y.-W. Teh, 2006
* [“Training Restricted Boltzmann Machines using Approximations to the Likelihood Gradient”](http://www.cs.toronto.edu/~tijmen/pcd/pcd.pdf) T. Tieleman, 2008
\ No newline at end of file
>参考文献:
>* [“A fast learning algorithm for deep belief nets”](http://www.cs.toronto.edu/~hinton/absps/fastnc.pdf) G. Hinton, S. Osindero, Y.-W. Teh, 2006
>* [“Training Restricted Boltzmann Machines using Approximations to the Likelihood Gradient”](http://www.cs.toronto.edu/~tijmen/pcd/pcd.pdf) T. Tieleman, 2008
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册