This project implements Principal Component Analysis (PCA) using NumPy to analyze African CO2 emissions data. The implementation includes standardization, eigendecomposition, and dimension reduction.
## Project Overview
This project implements **Principal Component Analysis (PCA)** using NumPy to analyze African CO2 emissions data. The implementation includes standardization, eigendecomposition, and dimension reduction.
- Open the Notebook in Google Colab
## Project Structure
```
pca-ml/
├── README.md
├── africa-co2-emissions.csv
├── PCA_Formative_2[Peer_Pair_Number].ipynb
```
## Dataset Information
**Dataset:** `africa-co2-emissions.csv`
### Dataset Characteristics:
- **Rows:** 1,134
- **Columns:** 20 total (3 non-numeric, 17 numeric)
- **Missing Values:** 1,013 (handled via mean imputation)
- **Source:** African countries CO2 emissions data
## Installation & Setup
### Step 1: Clone or Download the Repository
```bash
git clone
github.com
cd pca-ml
```
### Step 2: Install Required Libraries
```bash
# Install Jupyter Notebook (if not already installed)
pip install jupyter
# Install required Python libraries
pip install numpy pandas matplotlib
```
## How to Use the Notebook
### Method 1: Using Jupyter Notebook (Local)
```bash
# Navigate to project directory
cd pca-ml
# Launch Jupyter Notebook
jupyter notebook
# Open the file: PCA_Formative_2.ipynb
```
### Method 2: Using Google Colab
1. Click the "Open in Colab" badge at the top of the notebook
2. Upload `africa-co2-emissions.csv` to your files
3. Run all cells
### Method 3: Using VS Code
1. Open VS Code
2. Install the Jupyter extension (if not already installed)
3. Open the folder `pca-ml`
4. Click on `PCA_Formative_2.ipynb`
5. Select Run all
6. Select Python kernel when prompted
## PCA Implementation Steps
The notebook implements PCA in 7 steps:
### **Step 1: Load and Standardize Data**
- Loads the African CO2 emissions dataset
- Handles missing values via mean imputation
- Manual standardization using Z-score formula: `Z = (X - μ) / σ`
- **No sklearn used** - Pure NumPy implementation
### **Step 2: Calculate Covariance Matrix**
- Computes 17×17 covariance matrix
- …