開始使用免費開始

用 PCA 做特徵探索

你將使用上一題建立的 PCA pipeline,視覺化探索部分類別型特徵與 poke_df 變異之間的關係。 這些類別型特徵(TypeLegendary)位在另一個 DataFrame:poke_cat_df

所有相關套件與類別都已為你預先載入(Pipeline()StandardScaler()PCA())。

本練習屬於課程

Python 的降維

檢視課程

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Build the pipeline
pipe = Pipeline([('scaler', StandardScaler()),
                 ('reducer', PCA(n_components=2))])

# Fit the pipeline to poke_df and transform the data
pc = ____

print(pc)
編輯並執行程式碼