Skip to content

Commit

Permalink
校验: 5. 数据集转换 + 5.1 Pipeline(管道)和 FeatureUnion(特征联合): 合并的评估器 (#369)
Browse files Browse the repository at this point in the history
* 修改部分错误链接

* 修改错误索引

* 修改目录格式
  • Loading branch information
VPrincekin authored and loopyme committed Aug 21, 2019
1 parent 7fab4a3 commit 8b36189
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion docs/0.21.3/37.md
Expand Up @@ -2,7 +2,7 @@

scikit-learn 提供了一个用于转换数据集的库, 它也许会 clean(清理)(请参阅 [预处理数据](40.md#53-预处理数据)), reduce(减少)(请参阅 [无监督降维](42.md#55-无监督降维)), expand(扩展)(请参阅 [内核近似](44.md#57-内核近似))或 generate(生成)(请参阅 [特征提取](39.md#52-特征提取)) feature representations(特征表示).

像其它预估计一样, 它们由具有 `fit` 方法的类来表示, 该方法从训练集学习模型参数(例如, 归一化的平均值和标准偏差)以及将该转换模型应用于 `transform` 方法到不可见数据. 同时 `fit_transform` 可以更方便和有效地建模与转换训练数据.
像其它预估计一样, 它们由具有 `fit` 方法的类来表示, 该方法从训练集学习模型参数(例如, 归一化的平均值和标准偏差)以及`transform` 方法将该转换模型应用于不可见数据. 同时 `fit_transform` 可以更方便和有效地建模与转换训练数据.

[Pipeline(管道)和 FeatureUnion(特征联合): 合并的评估器](38.md#51-pipeline(管道)和-featureunion(特征联合)--合并的评估器) 中 transformers(转换)使用并行的或者串联的方式合并到一起. [成对的矩阵, 类别和核函数](45.md#58-成对的矩阵,-类别和核函数) 涵盖将特征空间转换为 affinity matrices(亲和矩阵), 而 [预测目标 (y) 的转换](46.md#59-预测目标--的转换) 考虑在 scikit-learn 中使用目标空间的转换(例如. 标签分类).

Expand All @@ -21,6 +21,7 @@ scikit-learn 提供了一个用于转换数据集的库, 它也许会 clean(
* [5.3.2 非线性转换](40.md#532-非线性转换)
* [5.3.3 归一化](40.md#533-归一化)
* [5.3.4 类别特征编码](40.md#534-类别特征编码)
* [5.3.5 离散化](40.md#535-离散化)
* [5.3.6 缺失值补全](40.md#536-缺失值补全)
* [5.3.7 生成多项式特征](40.md#537-生成多项式特征)
* [5.3.8 自定义转换器](40.md#538-自定义转换器)
Expand Down
14 changes: 7 additions & 7 deletions docs/0.21.3/38.md
Expand Up @@ -157,28 +157,28 @@ Pipeline(...,
>**警告**:缓存转换器的副作用
>
>使用 [`Pipeline`](https://scikit-learn.org/stable/modules/generated/sklearn.pipeline.Pipeline.html#sklearn.pipeline.Pipeline "sklearn.pipeline.Pipeline") 而不开启缓存功能,还是可以通过查看原始实例的,例如:
>```py
>
```py
>>> from sklearn.datasets import load_digits
>>> digits = load_digits()
>>> pca1 = PCA()
>>> svm1 = SVC(gamma='scale')
>>> pipe = Pipeline([('reduce_dim', pca1), ('clf', svm1)])
>>> pipe.fit(digits.data, digits.target)
...
Pipeline(memory=None,
steps=[('reduce_dim', PCA(...)), ('clf', SVC(...))],
verbose=False)
>>> # The pca instance can be inspected directly
>>> print(pca1.components_)
[[-1.77484909e-19 ... 4.07058917e-18]]
```
```
>开启缓存会在适配前触发转换器的克隆。因此,管道的转换器实例不能被直接查看。 在下面例子中, 访问 `PCA` 实例 `pca2` 将会引发 `AttributeError` 因为 `pca2` 是一个未适配的转换器。 这时应该使用属性 `named_steps` 来检查管道的评估器:
>```py
>
```py
>>> cachedir = mkdtemp()
>>> pca2 = PCA()
>>> svm2 = SVC(gamma='scale')
>>> cached_pipe = Pipeline([('reduce_dim', pca2), ('clf', svm2)],
... memory=cachedir)
>>> cached_pipe = Pipeline([('reduce_dim', pca2), ('clf', svm2)],memory=cachedir)
>>> cached_pipe.fit(digits.data, digits.target)
...
Pipeline(memory=...,
Expand All @@ -189,7 +189,7 @@ Pipeline(...,
[[-1.77484909e-19 ... 4.07058917e-18]]
>>> # Remove the cache directory
>>> rmtree(cachedir)
```
```

> **示例** :
>* [Selecting dimensionality reduction with Pipeline and GridSearchCV](https://scikit-learn.org/stable/auto_examples/plot_compare_reduction.html#sphx-glr-auto-examples-plot-compare-reduction-py)
Expand Down

0 comments on commit 8b36189

Please sign in to comment.