Exercise 5.3: PCA 1) Apply PCA to the data - output of Exercise 5.2 (with no outliers) in order to reduce the dimension

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Exercise 5.3: PCA 1) Apply PCA to the data - output of Exercise 5.2 (with no outliers) in order to reduce the dimension

Post by answerhappygod »

Exercise 5.3: PCA 1) Apply PCA to the data - output of
Exercise 5.2 (with no outliers) in order to reduce the dimension
from 3 to 2 (use "PCA(n_components = 2)". 2) Transform your
data (3 dimensional) to a new data (2 dimensional) by applying
"pca.transform", then print the shapes and the first 5 rows of your
data and new/transformed data.
this is the cod for Exercise 5.2
df = pd.DataFrame(columns= ["Normal","Exp1","Exp2"])
df["Normal"] = np.random.normal(0,1,200)
df["Exp1"] = np.random.exponential(2,200)
df["Exp2"] = np.random.exponential(3,200)
sns.distplot(df["Normal"])
sns.distplot(df["Exp1"])
sns.distplot(df["Exp2"])
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply