课程进度 83% · 第9/10章第9/10章 · 标签 1/4
— 1 —
数据挖掘实战
完整的分类项目
从数据加载、探索性分析、特征工程到模型训练和评估的完整流程。
— 2 —
Pipeline示例
python
1
from sklearn.pipeline import Pipeline
2
from sklearn.preprocessing import StandardScaler
3
from sklearn.decomposition import PCA
4
from sklearn.ensemble import RandomForestClassifier
5
6
pipe = Pipeline([
7
('scaler', StandardScaler()),
8
('pca', PCA(n_components=0.95)),
9
('clf', RandomForestClassifier())
10
])
11
pipe.fit(X_train, y_train)
12
print(f"Score: {pipe.score(X_test, y_test):.4f}")