Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

🎓 Students Performance Analysis & Insights

A basic Data Analytics project in Python that focus on cleans, explores, and visualizes a Kaggle dataset of 30,000+ student records to analyze how demographic factors, parental background, and student habits influence academic performance.


📌 Project Overview

Understanding the key drivers of student performance helps educators and families create better learning environments. This project delivers a comprehensive exploratory data analysis (EDA) pipeline in Python to identify significant relationships between lifestyle habits, family background, and exam outcomes.

Core Objectives:

  • 🧹 Data Preprocessing & Cleaning: Handle missing values, verify duplicates, convert data types, and prepare the dataset for exploratory analysis.
  • 📊 Exploratory Data Analysis (EDA): Analyze distributions and relationships across all 14 feature variables.
  • 📈 Visual Analytics: Generate clear, scannable diagrams (boxplots, heatmaps, bar charts) to highlight critical trends.
  • 💡 Actionable Insights: Extract data-backed findings on how study hours, sports, parental background, and prep courses affect math, reading, and writing scores.

📊 Dataset Overview

  • Title: Students Exam Scores Dataset
  • Source: Kaggle
  • Size: 30,641 Rows | 14 Columns
  • Objective: Analyze how different factors affect student exam performance.

Features & Categories

Category Feature Name Description / Type
Demographics Gender Male / Female
Ethnic Group Student ethnic background
First Child Whether the student is the firstborn child (Yes/No)
Number of Siblings Count of siblings
Parental Background Parent Education Highest education level achieved by parents
Parent Marital Status Marital status of parents
Student Behavior Lunch Type Standard or free/reduced lunch
Test Prep Completion status of test preparation course
Practice Sport Frequency of sports participation
Weekly Study Hours Range of hours spent studying per week
Transport Means Mode of transportation to school
Performance Math Score Numerical exam score
Reading Score Numerical exam score
Writing Score Numerical exam score

🛠️ Data Preparation Methodology

To prepare the dataset for exploratory data analysis and predictive modeling, a two-phase data preparation pipeline was implemented:


1. 🧹 Data Cleaning

  • Removed Unnecessary Index Columns: Dropped redundant identifier columns (e.g., Unnamed: 0).
  • Standardized Column Names: Converted headers to lowercase and replaced spaces with underscores (_).
  • Extracted Numeric Values from Study Hours: Converted string range values (e.g., "< 5", "5 - 10", "> 10") into numeric averages.
  • Imputed Missing Values: Filled missing values using statistical median for numeric features and mode for categorical features.
  • Dropped Duplicates: Checked and removed duplicate records to prevent data duplication.
  • Dropped Outliers: Filtered extreme score outliers using the Interquartile Range (IQR) method.
import pandas as pd
import numpy as np

# 1. Drop index column & standardize headers
if 'Unnamed: 0' in df.columns:
    df = df.drop(columns=['Unnamed: 0'])
df.columns = df.columns.str.strip().str.lower().str.replace(' ', '_')

# 2. Extract numeric values from study hours
def parse_study_hours(val):
    if pd.isna(val):
        return val
    if '<' in str(val):
        return 2.5
    elif '>' in str(val):
        return 10.0
    elif '-' in str(val):
        parts = str(val).split('-')
        return (float(parts[0]) + float(parts[1])) / 2
    return val

df['weekly_study_hours'] = df['weekly_study_hours'].apply(parse_study_hours)

# 3. Impute missing values (median for numeric, mode for categorical)
num_cols = df.select_dtypes(include=[np.number]).columns
cat_cols = df.select_dtypes(include=['object']).columns

for col in num_cols:
    df[col] = df[col].fillna(df[col].median())

for col in cat_cols:
    df[col] = df[col].fillna(df[col].mode()[0])

# 4. Drop duplicates & outliers
df = df.drop_duplicates()

Q1 = df['math_score'].quantile(0.25)
Q3 = df['math_score'].quantile(0.75)
IQR = Q3 - Q1
df = df[(df['math_score'] >= Q1 - 1.5 * IQR) & (df['math_score'] <= Q3 + 1.5 * IQR)]

2. ⚙️ Feature Engineering

  • **One-Hot Encoding: Encoded multi-class categorical variables (e.g., ethnic_group, transport_means, parent_education) into binary dummy variables ($0$ or $1$).
  • **Label Encoding: Applied binary encoding ($0$ or $1$) to binary categorical features (e.g., gender, first_child, test_prep, lunch_type).
  • **Calculated 'Total Score': Engineered a composite feature total_score by aggregating individual subject scores (math_score + reading_score + writing_score).
from sklearn.preprocessing import LabelEncoder

# 1. Label Encoding for binary features
binary_cols = ['gender', 'first_child', 'test_prep', 'lunch_type']
le = LabelEncoder()
for col in binary_cols:
    if col in df.columns:
        df[col] = le.fit_transform(df[col])

# 2. One-Hot Encoding for multi-class categorical features
multi_cat_cols = ['ethnic_group', 'parent_education', 'parent_marital_status', 'transport_means']
df = pd.get_dummies(df, columns=[c for c in multi_cat_cols if c in df.columns], drop_first=True, dtype=int)

# 3. Calculate 'Total Score' feature
df['total_score'] = df['math_score'] + df['reading_score'] + df['writing_score']

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages