Principal Component चयन

Python में Dimensionality Reduction

Jeroen Boeye

Head of Machine Learning, Faktion

Explained variance थ्रेशहोल्ड सेट करना

pipe = Pipeline([
        ('scaler', StandardScaler()),
        ('reducer', PCA(n_components=0.9))])

# Fit the pipe to the data pipe.fit(poke_df) print(len(pipe['reducer'].components_))
5
Python में Dimensionality Reduction

घटकों की एक उपयुक्त संख्या

pipe.fit(poke_df)

var = pipe['reducer'].explained_variance_ratio_

plt.plot(var)

plt.xlabel('Principal component index')
plt.ylabel('Explained variance ratio')
plt.show()

explained variance ratio

Python में Dimensionality Reduction

घटकों की एक उपयुक्त संख्या

pipe.fit(poke_df)

var = pipe['reducer'].explained_variance_ratio_

plt.plot(var)

plt.xlabel('Principal component index')
plt.ylabel('Explained variance ratio')
plt.show()

explained variance ratio elbow

Python में Dimensionality Reduction

PCA operations

PCA fit transform schema 1

Python में Dimensionality Reduction

PCA operations

PCA fit transform schema 2

Python में Dimensionality Reduction

PCA operations

PCA fit transform schema 3

Python में Dimensionality Reduction

इमेज कॉम्प्रेस करना

चेहरे मूल

Python में Dimensionality Reduction

इमेज कॉम्प्रेस करना

print(X_test.shape)
(15, 2914)

62 x 47 पिक्सेल = 2914 ग्रेस्केल वैल्यूज़

print(X_train.shape)
(1333, 2914)
Python में Dimensionality Reduction

इमेज कॉम्प्रेस करना

pipe = Pipeline([
        ('scaler', StandardScaler()),
        ('reducer', PCA(n_components=290))])

pipe.fit(X_train)
pc = pipe.fit_transform(X_test) print(pc.shape)
(15, 290)
Python में Dimensionality Reduction

इमेज दोबारा बनाना

pc = pipe.transform(X_test)

print(pc.shape)
(15, 290)
X_rebuilt = pipe.inverse_transform(pc)

print(X_rebuilt.shape)
(15, 2914)
img_plotter(X_rebuilt)

चेहरे कॉम्प्रेस्ड

Python में Dimensionality Reduction

इमेज दोबारा बनाना

चेहरे मूल

चेहरे कॉम्प्रेस्ड

Python में Dimensionality Reduction

अभ्यास करते हैं!

Python में Dimensionality Reduction

Preparing Video For Download...