This project analyzes the NASA DASHlink multi-class flight anomaly detection dataset. The analysis includes source-data inspection, derived trajectory quantities, trajectory visualization, vertical-acceleration anomaly detection, and a targeted binary classification model to predict Late Flaps events.
The script is organized into five functions and runs end-to-end from one Python file. Plots are saved automatically to a results/ folder and are not displayed interactively by default.
Dataset source: NASA DASHlink Flight Anomaly Detection Dataset
URL: https://c3.ndc.nasa.gov/dashlink/resources/1018/
Dataset citation:
Matthews, B. (2022). Curated 4 Class Anomaly Detection Data Set. NASA DASHlink. Updated December 22, 2022. https://c3.ndc.nasa.gov/dashlink/resources/1018/
Required input file:
DASHlink_full_fourclass_raw_comp.npz
Place the .npz file in the same directory as the Python script before running the analysis.
NASA_DASHlink_Flight Anomaly_Detection_Analysis_AS.py
README.md
requirements.txt
DASHlink_full_fourclass_raw_comp.npz
The script creates the following output folder automatically:
results/
The analysis was developed and tested using:
Python Version: 3.13.3
Platform/OS: macOS-13.7.8-x86_64-i386-64bit-Mach-O
The recommended package versions are provided in requirements.txt:
numpy==2.5.0
pandas==3.0.3
matplotlib==3.10.9
scikit-learn==1.9.0
xgboost==3.3.0
To confirm installed package versions after setup, run:
python -c "import numpy, pandas, matplotlib, sklearn, xgboost; print('numpy:', numpy.__version__); print('pandas:', pandas.__version__); print('matplotlib:', matplotlib.__version__); print('scikit-learn:', sklearn.__version__); print('xgboost:', xgboost.__version__)"Create and activate a fresh virtual environment:
python3 -m venv venv
source venv/bin/activateUpgrade packaging tools:
python -m pip install --upgrade pip setuptools wheelInstall the required packages:
python -m pip install -r requirements.txtFrom the project directory, run:
python NASA_DASHlink_Flight Anomaly_Detection_Analysis_AS.pyThe script assumes that DASHlink_full_fourclass_raw_comp.npz is available in the same directory as the Python script.
The script is organized into five main functions.
load_source_data()This function loads the .npz file, extracts the data and label arrays, prints dataset dimensions, class distribution, missing-value checks, and returns:
data
label
class_names
compute_derived_quantities()This function computes:
Height Above Last
Pitch Angular Velocity
Roll Velocity
It returns:
height_above_last
pitch_angular_velocity
roll_velocity
plot_height_above_last_trajectories()This function selects the first 25 flights from each class, plots Height Above Last trajectories, creates the results/ folder if needed, and saves the plot without displaying it.
analyze_vertical_acceleration()This function identifies vertical-acceleration edge cases, removes apparent placeholder/sensor-artifact values near -3.375 G, derives nominal-reference thresholds using the 0.1st and 99.9th percentiles, summarizes extreme-event counts by class, and saves all Question 4 plots.
run_late_flaps_classification()This function creates a binary Late Flaps target, generates candidate flight-level features, ranks features using Mutual Information and ANOVA F-scores, compares Logistic Regression, Random Forest, and XGBoost models, and saves classification plots.
Run the script once from the project directory:
python JR2026501623_Assessment_AnjaliSilva.pyThis reproduces the following outputs.
Data and label array structure
Dataset shape
Class distribution
Missing and infinite value checks
Overall data summary
Height Above Last
Pitch Angular Velocity
Roll Velocity
First 25 Height Above Last trajectories from each class
Edge-case flight identification near -3.375 G
Nominal-reference threshold calculation
Extreme vertical-acceleration event counts by class
Binary target creation
Candidate feature generation
Mutual Information and ANOVA feature ranking
Logistic Regression, Random Forest, and XGBoost model comparison
XGBoost confusion matrix, ROC curve, and feature importance plot
The script saves the following plots to results/.
results/q3_height_above_last_trajectories_first25_by_class.png
results/q4_edge_case_vertical_acceleration_trajectories.png
results/q4_nominal_vertical_acceleration_thresholds.png
results/q4_extreme_va_observations_by_class_log_scale.png
Figure 1. Edge-case vertical-acceleration trajectories showing flights persistently near -3.375 G.
Figure 2. Nominal vertical-acceleration distribution with 0.1st and 99.9th percentile extreme-event thresholds.
Figure 3. Distribution of extreme vertical-acceleration observations by flight class on a log scale.
results/q5_feature_separation_boxplot_airspeed_mean.png
results/q5_feature_separation_boxplot_vertical_accel_extreme_count.png
results/q5_feature_separation_boxplot_height_above_last_mean.png
results/q5_feature_separation_boxplot_roll_angle_std.png
results/q5_xgboost_late_flaps_confusion_matrix.png
results/q5_xgboost_late_flaps_roc_curve.png
results/q5_xgboost_feature_importance.png
Figure 4. XGBoost confusion matrix for the targeted Late Flaps binary classification task.
Figure 5. XGBoost ROC curve showing discrimination performance for Late Flaps classification.
The script saves the following tables to results/.
results/q4_vertical_acceleration_summary_by_class.csv
results/q5_mutual_information_feature_ranking.csv
results/q5_anova_feature_ranking.csv
results/q5_late_flaps_feature_separation_summary.csv
results/q5_model_comparison.csv
results/q5_xgboost_feature_importance.csv
Table 1. Performance comparison of three machine learning models for predicting Late Flaps events. XGBoost achieved the highest overall discrimination (ROC AUC = 0.95) and recall (0.91), indicating the strongest ability to identify Late Flaps flights. Logistic Regression produced comparable performance (ROC AUC = 0.94) while offering greater interpretability. Random Forest achieved the highest precision (0.47) but identified only a small proportion of Late Flaps flights (recall = 0.08), making it less suitable for detecting rare events. Consequently, XGBoost was selected as the final model because it provided the best balance between discrimination and detection of Late Flaps flights.
| Model | ROC AUC | Precision | Recall | F1 Score |
|---|---|---|---|---|
| Logistic Regression | 0.94 | 0.07 | 0.89 | 0.12 |
| Random Forest | 0.87 | 0.47 | 0.08 | 0.13 |
| XGBoost | 0.95 | 0.07 | 0.91 | 0.13 |
The script uses fixed random seeds where applicable:
random_state=42
This is used in train/test splitting and model training to improve reproducibility.
Use a fresh virtual environment when installing numpy==2.5.0. Installing NumPy 2.x into an existing environment that contains packages compiled against NumPy 1.x may cause binary compatibility errors.
The script uses XGBoost. If GPU support is not needed and installation issues occur, a CPU-only XGBoost installation may be preferable depending on the system.
Plots are saved to the results/ folder and are not displayed by default. To display plots interactively, change show_plot=False or show_plots=False to True in the relevant function call.
The vertical-acceleration analysis treats values near -3.375 G as apparent placeholder or sensor-artifact values after exploratory inspection showed that edge-case flights contained this value persistently across the trajectory.
The classification task is highly imbalanced because Late Flaps flights represent approximately 0.96% of the data. For this reason, recall, precision, F1-score, and ROC AUC are more informative than overall accuracy.
Author of this project is Anjali Silva. This project welcomes issues, enhancement requests, and other contributions. To submit an issue, use the GitHub issues page: https://github.com/anjalisilva/NASADashlink/issues.




