0% found this document useful (0 votes)
2 views4 pages

Data Preprocessing1

The document provides a step-by-step guide for installing Anaconda, opening Python using Anaconda, and performing data preprocessing. It covers downloading and installing Anaconda, launching Jupyter Notebook, importing libraries, loading datasets, handling missing values, encoding categorical variables, feature scaling, removing outliers, and splitting the dataset for machine learning. Finally, it instructs users to save the preprocessed data for further use.

Uploaded by

zenaaleme21
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)
2 views4 pages

Data Preprocessing1

The document provides a step-by-step guide for installing Anaconda, opening Python using Anaconda, and performing data preprocessing. It covers downloading and installing Anaconda, launching Jupyter Notebook, importing libraries, loading datasets, handling missing values, encoding categorical variables, feature scaling, removing outliers, and splitting the dataset for machine learning. Finally, it instructs users to save the preprocessed data for further use.

Uploaded by

zenaaleme21
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

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.

You might also like