Road Accident Data Analysis in India π
π Project Overview
This project explores road accident data in India using Python. It focuses on understanding the dataset, checking data quality, handling missing values, and visualizing relationships between selected accident-related variables.
π― Objectives
- Load and inspect the road accident dataset.
- Perform basic exploratory data analysis (EDA).
- Identify and handle missing or unknown values.
- Visualize the relationship between speed limits and number of fatalities.
- Plot month and year data for an initial overview.
π οΈ Tools & Libraries
- Python
- Pandas β data loading and manipulation
- NumPy β numerical operations
- Matplotlib β charts and plots
- Seaborn β visualization library imported in the notebook
π Project Structure
Road-Accident-Data-Analysis/
βββ task_1.ipynb
βββ accident_prediction_india.csv
βββ speed limit vs no. of fatalities.png
βββ months vs years.png
π Workflow
- Import libraries β import Pandas, NumPy, Matplotlib, and Seaborn.
- Load the dataset β read accident_prediction_india.csv into a Pandas DataFrame.
- Inspect the data β use info(), describe(), head(), tail(), and shape to understand the dataset.
- Handle missing values β replace "Unknown" in City Name with a missing value, then fill missing values in Traffic Control Presence, Driver License Status, and City Name using each column's mode.
- Visualize the data β create a scatter plot of Speed Limit (km/h) against Number of Fatalities, and a bar chart using Month and Year.
π Visualizations
Speed Limit vs Number of Fatalities A scatter plot is used to explore the relationship between speed limits and the number of fatalities. The plot alone does not establish causation.
Month vs Year A bar chart is created using the Month and Year columns as coded in the notebook. For a more meaningful time-based analysis, consider plotting accident counts by month or year if the dataset contains an accident count or suitable record-level rows.
π‘ Key Learning Outcomes
- Reading CSV files with Pandas.
- Inspecting datasets with common DataFrame methods.
- Detecting and handling missing values.
- Using mode imputation for selected categorical columns.
- Creating scatter plots and bar charts with Matplotlib.
House Price Prediction π
π Project Overview
This project uses a Linear Regression model to predict house prices from a dataset loaded from data.csv. The notebook explores the data, converts selected categorical columns into numeric features, trains and evaluates the model, and visualizes prediction results.
π― Objectives
- Explore and inspect the house-price dataset.
- Check data types, dataset dimensions, summary statistics, and missing values.
- Separate price as the target variable.
- Convert categorical features into numeric dummy variables.
- Train a Linear Regression model.
- Evaluate predictions using MAE, MSE, and RΒ².
- Visualize the price distribution and actual-versus-predicted prices.
π οΈ Technologies & Libraries
- Python
- Pandas
- NumPy
- Matplotlib
- Seaborn
- Scikit-learn
π Project Structure
House-Price-Prediction/
βββ house_prediction.ipynb
βββ data.csv
βββ outliers.png
βββ actual_vs_predicted.png
π Project Workflow
- Import Libraries The notebook imports Pandas and NumPy for data handling, Matplotlib and Seaborn for visualization, and Scikit-learn for model training and evaluation.
- Load and Explore Data The dataset is loaded using: df = pd.read_csv("data.csv") The notebook inspects data types, the last few rows, dataset information, descriptive statistics, dataset shape, and missing-value counts.
- Prepare Features and Target The target variable is price, while the remaining columns are used as input features: y = df["price"] x = df.drop(["price"], axis=1)
- Encode Categorical Features The notebook uses pd.get_dummies() with drop_first=True on these columns:
- date
- street
- city
- statezip
- country This converts the selected categorical columns into numeric indicator columns that the model can use.
- Split the Dataset The data is split into training and testing sets with an 80/20 split and random_state=42.
- Train the Model A LinearRegression model is fitted using the training features and target values.
- Evaluate the Model Predictions are generated for the test set and evaluated with:
- MAE (Mean Absolute Error): average absolute difference between actual and predicted prices.
- MSE (Mean Squared Error): average squared prediction error.
- RΒ² (R-squared): indicates how well the model explains variation in the target on the evaluated data. The actual metric values depend on the dataset and the results produced when the notebook is run.
- Visualize Results
- Price box plot: visual inspection of the price distribution and potential outliers.
- Actual vs. Predicted scatter plot: compares actual test prices with model predictions.
Email Spam Detection using Deep Learning π§
This project builds a binary email classification model to identify spam and non-spam emails. The notebook loads spam_email_dataset.csv, prepares the features, trains a neural network using TensorFlow/Keras, and evaluates its predictions with common classification metrics.
- Load and inspect an email dataset.
- Separate the target label from the input features.
- Convert selected categorical/text columns into numeric dummy features.
- Split the data into training and testing sets.
- Scale the features.
- Train a feed-forward neural network for binary classification.
- Evaluate the model using accuracy, precision, recall, and F1-score.
- Python
- Pandas and NumPy β data handling
- Scikit-learn β preprocessing, train-test split, and evaluation metrics
- TensorFlow / Keras β neural network model
- Matplotlib and Seaborn β visualization libraries imported in the notebook
Email-Spam-Detection/
βββ Email_detection.ipynb
βββ spam_email_dataset.csv
Keep spam_email_dataset.csv in the same directory as the notebook, or change the file path in the code.
The notebook loads the CSV file:
df = pd.read_csv("spam_email_dataset.csv")It then checks the dataset's information, summary statistics, column names, shape, missing values, data types, and first rows.
The notebook uses label as the target:
y = df["label"]
x = df.drop(["label"], axis=1)The notebook applies pd.get_dummies() to subject, email_text, sender_email, and sender_domain, with drop_first=True, to convert these columns into numeric indicator features.
The data is split into training and testing sets using an 80/20 split, random_state=42, and stratification by label.
StandardScaler is fitted on the training features and then applied to the test features.
The model is a feed-forward neural network with:
- Input layer followed by a Dense layer with 128 units and ReLU activation
- Dense hidden layer with 64 units and ReLU activation
- Output layer with 1 unit and sigmoid activation
The model is compiled with the Adam optimizer, binary cross-entropy loss, and accuracy as a training metric. It is trained for 50 epochs with a batch size of 32 and uses 20% of the training data for validation.
The notebook predicts labels for the test set using a threshold of 0.5 and calculates:
- Accuracy: overall proportion of correct predictions.
- Precision: proportion of predicted spam-positive cases that are correct.
- Recall: proportion of actual positive cases identified.
- F1-score: harmonic mean of precision and recall.
The notebook calculates these metrics when run. No specific performance score is stated here because results depend on the dataset and execution.
- Download or clone this repository.
- Install Python.
- Install dependencies:
pip install pandas numpy matplotlib seaborn scikit-learn tensorflow jupyter
- Put
spam_email_dataset.csvin the project folder. - Start Jupyter:
jupyter notebook
- Open
Email_detection.ipynband run cells from top to bot
- The notebook uses
pd.get_dummies()onemail_textand other high-cardinality fields. This can create a very large feature matrix and does not capture text similarity in the same way as a TF-IDF representation.TfidfVectorizeris imported but is not used in the current notebook. StandardScalermay be inefficient for a very wide sparse feature matrix; a sparse-friendly text preprocessing pipeline may be more suitable.- Confirm how the dataset encodes
label(for example, 0 and 1) before interpreting precision and recall as spam-specific. - The notebook evaluates the model but does not save the trained model for later use.
Add your name and GitHub profile here.
Add a license if you want others to reuse this project. """ path="/mnt/data/README_email_spam_detection.md" with open(path,"w",encoding="utf-8") as f.write(rea print(path, os.pat
Customer Churn Prediction π
This project uses machine learning to predict customer churn from a customer dataset. The notebook explores the data, prepares categorical features, trains a Random Forest Classifier, evaluates predictions, and creates visualizations to explore how selected customer attributes relate to the Exited target.
- Inspect and understand the customer dataset.
- Check data types, summary statistics, missing values, and duplicate rows.
- Separate the target variable (
Exited) from input features. - Encode selected categorical columns.
- Train a Random Forest classification model.
- Evaluate the model using Accuracy, Recall, and ROC AUC.
- Visualize Credit Score, Balance, and Active Member status by churn label.
- Python
- Pandas and NumPy β data handling
- Matplotlib and Seaborn β data visualization
- Scikit-learn β model training, splitting, and evaluation
Customer-Churn-Prediction/
βββ churn.ipynb
βββ Churn_dataset.csv
βββ creditscore.png
βββ balance.png
βββ Isactivemember.png
βββ EstimatedSalary vs Tenure.png
The CSV file is required to run the notebook. The PNG files are generated by the visualization cells when those cells run; add them to the repository only if you want to display the charts directly on GitHub.
The notebook imports Pandas, NumPy, Matplotlib, Seaborn, RandomForestClassifier, train_test_split, and classification evaluation metrics.
The notebook loads Churn_dataset.csv and inspects:
- First and last rows
- Dataset information and descriptive statistics
- Dataset shape and data types
- Missing-value counts
- Duplicate-row count
The target is Exited; the remaining columns are used as input features:
y = df["Exited"]
x = df.drop(["Exited"], axis=1)The notebook uses pd.get_dummies() with drop_first=True on:
SurnameGeographyGender
This converts those categorical columns into numeric indicator features.
The data is split into training and test sets with an 80/20 split and random_state=42.
A RandomForestClassifier is trained on the training data using Scikit-learn's default model settings.
The notebook calculates:
- Accuracy: fraction of test examples classified correctly.
- Recall: fraction of actual positive (
Exited = 1) examples identified by the model. - ROC AUC: in the current notebook, this is calculated using predicted class labels (
y_pred), rather than predicted probabilities or decision scores.
The actual metric values depend on the dataset and the results produced when the notebook is run.
The notebook creates:
-
Box plot of
CreditScorebyExited -
Box plot of
BalancebyExited -
Box plot of
IsActiveMemberbyExited -
Scatter plot of
EstimatedSalaryagainstTenure
- Download or clone this repository.
- Install Python.
- Install the required packages:
pip install pandas numpy matplotlib seaborn scikit-learn jupyter
- Place
Churn_dataset.csvin the same directory aschurn.ipynb. - Start Jupyter Noteb
jupyter notebook
- Open
churn.ipynband run the cells from top to bottom.
- The notebook checks for missing values and duplicate rows but does not remove or impute them.
Surnameis included as a model feature after one-hot encoding. Depending on the dataset, it may add many features and may not generalize well.- The notebook uses the default Random Forest settings and does not include hyperparameter tuning or cross-validation.
- ROC AUC is more informative when calculated from predicted probabilities, for example
model.predict_proba(x_test)[:, 1], rather than hard class labels. - The notebook does not currently save the trained model for reuse.
Add your name and GitHub profile here.
Add a license if y