Data Preprocessing
PART A: Installing Anaconda (Python Environment)
Step 1: What is Anaconda?
Anaconda is free software that includes:
Python
Important ML libraries (NumPy, Pandas, Matplotlib, Scikit-learn)
Jupyter Notebook (very beginner-friendly)
� You do not need to install Python separately
Step 2: Download Anaconda
1. Open your browser
2. Go to:
� [Link]
3. Click Download
4. Choose:
o Windows (if your PC is Windows)
o 64-bit Graphical Installer
5. Wait for download to finish
Step 3: Install Anaconda
1. Double-click the downloaded file
2. Click Next
3. Click I Agree
4. Select Just Me → Next
5. Choose install location (default is fine)
6. ✔ Check Add Anaconda to PATH (if shown)
7. Click Install
8. Wait until installation finishes
9. Click Finish
� Anaconda is now installed
PART B: Open Python Using Anaconda
Step 4: Open Anaconda Navigator
1. Press Windows key
2. Type Anaconda Navigator
3. Open it
You will see tools like:
Jupyter Notebook
Spyder
VS Code
For beginners: Jupyter Notebook is best
Step 5: Launch Jupyter Notebook
1. In Anaconda Navigator, click Launch under Jupyter Notebook
2. Your browser will open automatically
3. You will see folders on your computer
Step 6: Create a New Python Notebook
1. Click New (top-right)
2. Select Python 3
3. A new notebook opens
PART C: Data Preprocessing
Now we start actual data preprocessing.
Step 7: Import Required Libraries
In the first cell, type:
import numpy as np
import pandas as pd
import [Link] as plt
Run the cell: Shift + Enter
Step 8: Load Your Dataset
(a) Place your dataset
Put your dataset (e.g., [Link]) in the same folder as the notebook
(b) Load it
data = pd.read_csv("[Link]")
Check data:
[Link]()
Step 9: Understand the Dataset
[Link]()
[Link]()
Check missing values:
[Link]().sum()
Step 10: Handle Missing Values
Numerical columns (mean)
data['Age'].fillna(data['Age'].mean(), inplace=True)
Categorical columns (mode)
data['Gender'].fillna(data['Gender'].mode()[0], inplace=True)
Step 11: Encode Categorical Variables
Label Encoding (Male/Female)
from [Link] import LabelEncoder
le = LabelEncoder()
data['Gender'] = le.fit_transform(data['Gender'])
One-Hot Encoding (Multiple Categories)
data = pd.get_dummies(data, columns=['Country'])
Step 12: Feature Scaling
Important for ML algorithms.
from [Link] import StandardScaler
scaler = StandardScaler()
data[['Age', 'Salary']] = scaler.fit_transform(data[['Age', 'Salary']])
Step 13: Remove Outliers (Optional but Good)
Q1 = data['Salary'].quantile(0.25)
Q3 = data['Salary'].quantile(0.75)
IQR = Q3 - Q1
data = data[(data['Salary'] >= Q1 - 1.5*IQR) &
(data['Salary'] <= Q3 + 1.5*IQR)]
Step 14: Split Dataset (Very Important for ML)
from sklearn.model_selection import train_test_split
X = [Link]('Target', axis=1)
y = data['Target']
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.2, random_state=42)
PART D: Save Preprocessed Data
data.to_csv("processed_data.csv", index=False)
� You can submit this file or use it for model training.