diff --git "a/docs/8.\351\231\215\347\273\264.md" "b/docs/8.\351\231\215\347\273\264.md" index 889259cdf90353c092db40db467154dad7e44044..9a3b61810f67438c86ec6d1d12891bd45e9c4260 100644 --- "a/docs/8.\351\231\215\347\273\264.md" +++ "b/docs/8.\351\231\215\347\273\264.md" @@ -273,7 +273,10 @@ X_reduced=rbf_pca.fit_transform(X) 由于 kPCA 是无监督学习算法,因此没有明显的性能指标可以帮助您选择最佳的核方法和超参数值。但是,降维通常是监督学习任务(例如分类)的准备步骤,因此您可以简单地使用网格搜索来选择可以让该任务达到最佳表现的核方法和超参数。例如,下面的代码创建了一个两步的流水线,首先使用 kPCA 将维度降至两维,然后应用 Logistic 回归进行分类。然后它使用`Grid SearchCV`为 kPCA 找到最佳的核和`gamma`值,以便在最后获得最佳的分类准确性: ```Python -from sklearn.model_selection import GridSearchCV from sklearn.linear_model import LogisticRegression from sklearn.pipeline import Pipeline +from sklearn.model_selection import GridSearchCV +from sklearn.linear_model import LogisticRegression +from sklearn.pipeline import Pipeline + clf = Pipeline([ ("kpca", KernelPCA(n_components=2)), ("log_reg", LogisticRegression())