0% found this document useful (0 votes)
47 views

Factor Analysis

The document outlines 12 steps for performing a hands-on exercise in factor analysis using Python. It involves loading the iris dataset, splitting the data into training and test sets, scaling the data, performing factor analysis to transform the features, training a random forest classifier on the original and transformed data, and comparing the accuracy scores. The goal is to see if factor analysis improves the random forest performance.

Uploaded by

Nishant Randev
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views

Factor Analysis

The document outlines 12 steps for performing a hands-on exercise in factor analysis using Python. It involves loading the iris dataset, splitting the data into training and test sets, scaling the data, performing factor analysis to transform the features, training a random forest classifier on the original and transformed data, and comparing the accuracy scores. The goal is to see if factor analysis improves the random forest performance.

Uploaded by

Nishant Randev
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Data Science with Python Module 10

Hands On - 2

[email protected]
+91-7022374614
US: 1-800-216-8930(Toll Free)
Data Science with Python Certification Course

Data Science with Python Module 10: Hands-on: 2


Factor Analysis

Step 1: Open Anaconda Navigator

Step 2: Click on Launch button under jupyter notebooks.

[email protected] - +91-7022374614 - US: 1-800-216-8930(Toll Free)


Data Science with Python Certification Course

Step 3: After the notebook opens click on new and Python 3.

Step 4: Import all the required modules by typing the following code in the notebook and run it
by pressing shift + enter

Step 5: Load the iris dataset.

[email protected] - +91-7022374614 - US: 1-800-216-8930(Toll Free)


Data Science with Python Certification Course

Step 6: Extract X and Y variables out of the dataset.

Step 7: Split the data into 70 percent for training and 30 percent testing.

Step 8: Scale the data.

Step 9: Create a RandomForestCLassifier train it on scaled data and print its accuracy score and
confusion matrix.

[email protected] - +91-7022374614 - US: 1-800-216-8930(Toll Free)


Data Science with Python Certification Course

Step 9: Create FactorAnalysis or FA instance and transform x_train and x_test.

Step 10: Create a RandomForestCLassifier train it on scaled and transformed data and print its
accuracy score and confusion matrix.

[email protected] - +91-7022374614 - US: 1-800-216-8930(Toll Free)


Data Science with Python Certification Course

Step 12: Call the perform_pca method with n_components set to a number from 1 to 4 and
print their confusion matrix and accuracy scores.

[email protected] - +91-7022374614 - US: 1-800-216-8930(Toll Free)

You might also like