YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
This project analyzes historical airplane accident data to predict the severity of crashes.
dataset shape: +28,000 rows of flight records, covering a long period of history from 1908 to 2009.
STEP 1 The Main Question I wanted to focus is: "Can we predict the total fatalities of an airplane crash based on the flight characteristics?"
- I focused on key input variables such as:
- Pax on board (Number of passengers)
- Crew on board
- Age` of the aircraft
- Flight Type (Military vs. Commercial vs. Private)
I used two different approaches with specific target variables:
- For Regression: My target was
Total fatalities(I wanted to predict the exact number of deaths). - For Classification: My target was
Severity(I wanted to predict if the crash was "High Risk" or "Low Risk").
STEP 2 - EDA & Data cleaning
Raw data contained missing values and some columns were not useful for prediction.
I decided to remove the following columns: 'Schedule', 'Registration', 'Time', 'Flight no.', 'MSN', and 'Other fatalities'. I removed them because these columns were not useful for answering my main question about predicting the severity of the crash.
- For categorical variables (like
OperatororSummary), I replaced missing values with "Unknown". - For numerical variables (like
Pax on boardorCrew on board), I filled the missing values with the Median (if many outliers) or the Mean (if not too much outliers) to preserve the data distribution.
I removed rows where the Total fatalities count was higher than the number of people on board, which is impossible.
To find extreme values, I used the Z-score method.
- My Decision: I chose to keep the outliers. Reasoning: In the context of airplane crashes, extreme values (like a crash with 500 fatalities) are statistically rare but they are real events. I simply verified that the data was not impossible (e.g., no negative numbers), but I kept the high values because the model needs to learn from these major catastrophes.
Then I analyzed the dataset with under questions
The correlation matrix reveals a very strong linear relationship between Pax on board and Total fatalities. However, the correlation between Age and Total fatalities is extremely low (close to 0). This mathematically proves that aircraft age is not a predictor of crash severity: older planes do not result in more fatalities than newer ones.
This plot shows a relationship between Pax on board and Total fatalities. When there are more passengers, the number of deaths is usually higher. The red line shows this trend: more people → more possible deaths. We also see a clear diagonal line of points: this means some crashes killed everyone on board. The number of passengers is important. When an airplane carries many people, the crash can cause more deaths. So “Passengers on board” is a useful variable to help predict fatalities.
Based on the EDA analysis, the model concluded'Pax on board' and 'Flight type' will be crucial features.
step 3- Define and Train a baseline model
I used Supervised Learning to build the first model. I chose Linear Regression. I gave the model the "features" and the "labels" (Total Fatalities).
The model achieved an R² score of about 0.441, MAE of 5.27 , and RMSE of 13.22 This means the model can explain only about 40% to 45% of the crash severity.
step 4- Feature Engineering
This code helps to decide how many groups (clusters) I should create for our data.
I chose k=3 because it is the 'Elbow Point' on the graph.
Looking at the curve, the error drops significantly from 1 to 3 clusters. After k=3, the line starts to flatten out.
I used the K-Means tool (unsupervised learning) to put all the aircraft into three clear groups based on size and age. This was done to find hidden risk profiles that the simple Linear Regression model could not see."
- Group 0 (Small & New): These planes are typically new (around 7 years old) but small, with low passenger and crew numbers.
- Group 1 (The Giants): This group is defined by its large size, with a high average of 113 passengers and 8 crew members. These are the big, commercial airplanes.
- Group 2 (Small & Old): This group is the oldest (almost 30 years old) but small in size. These are likely older private or cargo planes. Separating the data into these three profiles, I have created a high-value Cluster Feature that should significantly improve the prediction accuracy of my final model."
Step 5- Train and Evaluate Three Improved Models
I group the numerous flight types into three main categories (Military, Commercial, Private) and define the final dataset variables by transforming text into numerical data. I use the Cluster ID to ensure the training sets are ready for the advanced models
I train 3 models: Linear Regression , Decision Tree and Random Forest. The linear regression has the highest score among the others models The Reason: The relationship between Passengers and Fatalities is very direct and linear. As seen in the scatter plot, more passengers simply means more potential victims. The complex models tried to find complicated patterns that do not exist, so they overthought the problem and made more mistakes.
step 6- Regression-to-Classification
I convert the target variable (Total fatalities) to a binary classification problem. I use the Median Split strategy, I calculate the median number of fatalities from the training set (which is 2.0). Any accident with fatalities > 2.0 is labeled as Class 1 .Any accident with fatalities < 2.0 is labeled as Class 0.
Before training, I check the balance between my two new classes to avoid bias. The analysis shows a distribution of 54.2% for Class 1 and 45.8% for Class 0. This confirms that my dataset is well-balanced (close to a 50/50 split), making it suitable for training standard classification models like Logistic Regression or Random Forest.
I chose Recall because of safety. In a plane crash scenario, the worst mistake is to miss a serious accident. If the model predicts 'No Danger' but people are actually dying, emergency services will not be sent, and lives will be lost. It is better to have a False Positive (sending help for a minor accident) than to miss a real disaster.
False Negative is the most critical error to avoid. False Negative: The model predicts the crash is "Low Severity", but the answer is actually "High Severity". Consequence: Emergency services might not be alerted or might send insufficient help. This could result in loss of life because the response was too weak for the real danger.
step 7- Train & Eval Classification Models
I trained 3 classification models: Logistic Regression Random Forest and Gradient Boosting to predict the severity of airplane accidents. The results show that Random Forest and Gradient Boosting have a little bit better global accuracy of sixty-three percent compared to 59% for Logistic Regression. The most important metric for the safety objective is the Recall for Class 1 because I want to avoid False Negatives and detect every serious crash. The Logistic Regression model achieved the highest Recall score of 82% percent and it made the fewest critical errors with only four 482 missed serious crashes compared to almost seven hundred for the other models. I identify Logistic Regression as the winning model because even if it is less precise overall it is the safest model to ensure that emergency services are always alerted in case of a major accident.


