0Pricing
Data Science Academy · レッスン

スクリープロットで成分を選ぶ

説明分散を十分に保つ

「スクリープロットで成分を選ぶ」はCoddyKit上の無料Data Science Academyレッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはData Science Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Data Science Academyコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

How Many to Keep?

PCA can hand you dozens of components, but you only want the useful few. The real skill is choosing how many to keep.

Meet the Scree Plot

A scree plot charts each component against the variance it explains, so you can see importance drop off at a glance.

Look for the Elbow

Variance falls fast then levels into a flat tail. The bend, called the elbow, marks where extra components stop paying off.

Plot the Ratios

Fit PCA with all components, then plot explained_variance_ratio_ to draw the curve and spot that elbow.

import matplotlib.pyplot as plt
plt.plot(pca.explained_variance_ratio_)

Cumulative Variance

Add the ratios up as you go to get cumulative variance, showing the total information kept by the first k components.

import numpy as np
cum = np.cumsum(pca.explained_variance_ratio_)

Pick a Threshold

A common rule is to keep enough components to reach a target, like 95 percent of total variance retained.

Let scikit-learn Choose

Pass a fraction as n_components and scikit-learn keeps just enough components to hit that explained-variance target.

from sklearn.decomposition import PCA
pca = PCA(n_components=0.95).fit(X)

The Kaiser Rule

Another guide, the Kaiser rule, keeps components whose eigenvalue exceeds one, meaning they explain more than a single feature would.

Balance the Trade-Off

Fewer components mean simpler, faster models but more lost detail. Choosing k is always a trade-off between size and fidelity.

Validate Downstream

The best k is the one that helps your real task. Try a few values and compare model scores with cross-validation.

Beware Tiny Components

Components past the elbow often capture mostly noise. Keeping them rarely helps and can quietly hurt your model.

Quick Check

The scree plot points you to one telltale spot.

Recap

Use a scree plot, elbow, or a cumulative-variance threshold to keep just enough components, then validate k downstream. 🎯

よくある質問

「スクリープロットで成分を選ぶ」レッスンは無料ですか?

はい。「スクリープロットで成分を選ぶ」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Data Science Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Data Science Academyコースには全4レッスンが含まれています。

「スクリープロットで成分を選ぶ」で何を学びますか?

説明分散を十分に保つ ブラウザで直接実行するハンズオンコードでData Science Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

Data Science Academyを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのData Science Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン4/4です。

「スクリープロットで成分を選ぶ」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このData Science Academyレッスンでコードを書いて実行できますか?

はい。すべてのData Science Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. 特徴量が多すぎる問題
  2. PCAが成分を見つける仕組み
  3. まずスケーリングしてからPCAを適用する
  4. スクリープロットで成分を選ぶ
← Data Science Academyに戻る