1. Data Preparation

Data integrity was a top priority. My goal was to prepare this longitudinal dataset for a full scale analysis:

2. Machine Learning Pipeline

Building an accurate model required more than selecting an algorithm. This project followed a structured machine learning workflow, beginning with feature engineering and progressing through model comparison, validation, and interpretation. Rather than optimizing solely for training performance, each stage emphasized generalization to unseen data.

WORKFLOW // MACHINE_LEARNING_PIPELINE TYPE: VECTOR_SVG
DATA Cleaning FEATURES Engineering VALIDATION Train/Test MODELS Comparison FINAL MODEL Random Forest
Fig 1. End-to-end machine learning workflow used to evaluate multiple supervised learning models before selecting the final Random Forest classifier.

3. Model Selection

Several supervised learning approaches were evaluated, including Random Forest, XGBoost, feature reduction techniques, and oversampling methods to address class imbalance. Although the more sophisticated approaches improved training performance, they consistently reduced accuracy on unseen test data, indicating overfitting. Random Forest produced the strongest generalization and ultimately had the best fit.

MODEL_COMPARISON // VALIDATION_RESULTS TYPE: PERFORMANCE_TABLE
Model Accuracy Observation
Random Forest 64% Best predictive ability
XGBoost (XGB) 60% Overfit with small dataset
XGB Oversampling Below baseline Higher variance
XGB Feature Reduction Below baseline Removed useful information
Fig 2. Random Forest achieved the strongest predictive performance, while dimensionality reduction and resampling strategies introduced additional variance.

The final Random Forest classifier achieved 64% accuracy on the held-out testing data. Although this may appear modest compared to many benchmark datasets, it represents the strongest-performing model after systematically evaluating multiple algorithms. More complex methods, including XGBoost and oversampling techniques, consistently produced poorer generalization despite higher training performance.

3. Why Random Forest Fits Best

Random Forest proved particularly well suited for this project because the dataset contains relatively few observations, several categorical variables, and inherently noisy historical records. Unlike boosting algorithms, which sequentially learn from previous errors and often overfit small datasets, Random Forest combines the predictions of hundreds of independently trained trees. This ensemble approach produced more stable predictions and ultimately delivered the highest performance on unseen incidents.

4. Feature Analysis

By looking into the most prominent features present in this analysis it comes to light that shark attacks are not purely random and even follow certain trends.

MODELING // FEATURE_IMPORTANCETYPE: VECTOR_SVG
Predictive Power: Random Forest Features Year County Month Activity Species Season Time of Day Depth Submersion 0.0 Feature Importance Score 1.0
Fig 3. Feature Importance ranking. Year and County emerged as the primary indicators of incident severity.

5. Dataset Limitations

Full Python Notebook available here.

Impact Statement

One of the most important findings of this project was not simply the prediction accuracy, but the realization that model complexity cannot overcome limitations in the underlying data. After comparing multiple machine learning approaches, Random Forest proved to be the most reliable model because it generalized better to new observations than more sophisticated alternatives. This project demonstrates an essential principle of applied machine learning: selecting the model that best generalizes is often more valuable than pursuing increasingly complex algorithms that merely memorize the training data.