Develop a program to implement Principal Component Analysis (PCA) for reducing the
dimensionality of the Iris dataset from 4 features to 2.
import numpy as np
import pandas as pd
from [Link] import PCA
import [Link] as plt
# Load the Iris dataset from local system
iris_df = pd.read_csv("absolute_path_of_iris.csv")
data = iris_df.iloc[:, :-1].values
labels = iris_df.iloc[:, -1].values
label_names = [Link](labels)
# Perform PCA to reduce dimensionality to 2
pca = PCA(n_components=2)
data_reduced = pca.fit_transform(data)
# Create a DataFrame for the reduced data
reduced_df = [Link](data_reduced, columns=['Principal Component 1', 'Principal
Component 2'])
reduced_df['Label'] = labels
# Plot the reduced data
[Link](figsize=(8, 6))
colors = ['r', 'g', 'b']
for i, label in enumerate(label_names):
[Link](
reduced_df[reduced_df['Label'] == label]['Principal Component 1'],
reduced_df[reduced_df['Label'] == label]['Principal Component 2'],
label=label,
color=colors[i]
[Link]('PCA on Iris Dataset')
[Link]('Principal Component 1')
[Link]('Principal Component 2')
[Link]()
[Link]()
[Link]()