This GitHub repository contains a Python script that implements the Principal Component Analysis (PCA) algorithm to reduce the dimensionality of a dataset and provides a graphical user interface (GUI) for users to interact with the algorithm. PCA is a dimensionality reduction technique that is widely used in machine learning and data analysis.
Before using this code, you should have the following installed:
- Python (>=3.7)
The main script is named algorithm.py and contains the PCA algorithm implementation. It includes the following key components:
- Importing necessary libraries such as scikit-learn, tkinter, numpy, pandas, matplotlib, and more.
- Functions for performing PCA with different numbers of components (1, 2, and 3).
- A GUI created with tkinter, which allows the user to select the number of components for PCA and visualize the results.
The GUI includes a background image (named asset.jpg) to enhance the visual appearance of the interface.
The script uses the Iris dataset, which is loaded from an external URL (UCI Machine Learning Repository).
You can access the dataset here
To use this PCA implementation with the GUI, follow these steps:
- Clone or download the repository to your local machine.
git clone https://github.com/your_username/PCA-Algorithm.git
- Ensure you have the required Python libraries installed. You can typically install them using pip:
pip install scikit-learn pandas matplotlib pillow plotly
- Run the script algorithm.py using a Python interpreter. This will launch the GUI.
- In the GUI, you can choose to perform PCA with 1, 2, or 3 components.
- The script will load the Iris dataset, apply PCA, and display a confusion matrix and accuracy score for the selected number of components. It will also display a scatter plot or 3D scatter plot to visualize the data's reduced dimensionality.