The problem
An AI-Based Flight Price Predictor using XGBoost answers a question every traveller asks before booking: what should this ticket cost? Flight fares change with airline, route, departure hour, number of stops and how many days remain before travel, so prices checked on different days jump by thousands of rupees for no visible reason. Booking sites show the current price but never explain which factor moved it, and tutorials usually fit a model without explaining feature engineering, train-test discipline or how a prediction is checked. This project closes that gap by training an XGBoost regressor on 10,683 real Indian domestic flight records from Kaggle, turning raw booking fields into features such as days to departure, departure hour and duration in minutes, and reporting RMSE, MAE and R² on a held-out test split. The demo makes the model tangible: change the airline, route or booking window and watch the fare move, with the cheapest-date chart showing which day costs least.
10,683 Indian domestic flight records with airline, route, times, stops and price in INR.
Follow the working sequence
How it works
The AI-Based Flight Price Predictor using XGBoost works end to end as a regression pipeline: raw flight records from the Kaggle Flight Fare Prediction dataset are cleaned and turned into model-ready features, an XGBoost regressor learns how each feature relates to the ticket price, the trained model is checked once on a held-out test split with RMSE, MAE and R², and the saved model powers a web demo where any combination of airline, route, times, stops and booking window returns a predicted fare in INR. Feature engineering is where most of the learning happens: Date_of_Journey becomes days to departure and day of week, Dep_Time becomes departure hour, Duration becomes minutes, and airline, source and destination become one-hot columns. Training uses XGBoost's scikit-learn interface, XGBRegressor with the reg:squarederror objective, and the demo applies the same fare drivers the model ranks — days to departure first, then route and airline — so the interface and the model always agree about what matters.
- The 10,683-row Kaggle dataset is loaded and checked: 11 columns (Airline, Date_of_Journey, Source, Destination, Route, Dep_Time, Arrival_Time, Duration, Total_Stops, Additional_Info, Price), with duplicate rows (220 rows, as reported in the dataset's EDA notes) and missing values in Route and Total_Stops handled before training.
- Features are engineered from the raw fields: days to departure and day of week from Date_of_Journey, departure and arrival hour from the time fields, duration parsed from hours-minutes text into total minutes, and stops converted to a number.
- Categorical fields (airline, source, destination) are one-hot encoded and the data is split 80% train / 20% test with a fixed random seed, so the split is reproducible.
- An XGBRegressor (objective reg:squarederror) is trained on the training split, with early stopping on a validation slice to choose the number of boosting rounds.
- The trained model is evaluated once on the held-out test split: RMSE and MAE in INR and R² are computed and recorded with residual plots for the report.
- The saved model is wired into the web demo: the user picks route, airline, times, stops and booking window, the same preprocessing runs, and the model returns a predicted fare with a typical range.
- The cheapest-date view re-runs the prediction across seven departure dates on the selected route and highlights the lowest fare.
Tech stack:
-
Python 3
-
XGBoost · XGBRegressor
-
pandas · NumPy
-
scikit-learn
-
Matplotlib
-
Jupyter Notebook
-
HTML · CSS · JavaScript demo
-
Kaggle Flight Fare Prediction dataset
-
Dataset: Flight Fare Prediction, Kaggle (Nikhil Mittal) — 10,683 rows and 11 columns of Indian domestic flight records from March–June 2019; fields are Airline, Date_of_Journey, Source, Destination, Route, Dep_Time, Arrival_Time, Duration, Total_Stops, Additional_Info and Price in INR.
-
Task: Regression; input = airline, source, destination, route, departure/arrival time, duration, stops, days to departure and day of week; output = predicted ticket price in INR (continuous).
-
Model: XGBoost regressor (XGBRegressor, objective reg:squarederror, tree booster) with one-hot encoded categorical features and engineered numeric features; hyperparameters (n_estimators, max_depth, learning_rate) tuned on a validation slice with early stopping.
-
Metrics: RMSE in INR, MAE in INR and R² on the held-out 20% test split, plus residual plots. No RMSE, MAE or R² figure is claimed as measured until the training run is executed for the order; the design target is test RMSE under ₹1,500.
| Parameter | Value |
|---|---|
| Dataset size | 10,683 rows (verified, Kaggle) |
| Dataset columns | 11 columns (verified, Kaggle) |
| Input features | 10 features (airline, route, times, stops, booking window) |
| Target | Price in INR (continuous, regression) |
| Model | XGBoost regressor (XGBRegressor, reg:squarederror) |
| Train / test split | 80% train / 20% test (fixed seed) |
| Test RMSE | Under ₹1,500 (design target, not a measured claim) |
| Training time | Approximately 2–5 min on a laptop CPU (expected) |
| Inference | Approximately 5 ms per prediction on CPU (expected) |
| Demo | Single-file web app, runs offline after download |
Project features
The AI-Based Flight Price Predictor using XGBoost is built around four capabilities: a fare estimator that predicts a ticket price from airline, route, times, stops and booking window; a cheapest-date chart that compares predicted fares across a week of departures; a feature-importance view that shows which inputs move the price most; and a training notebook that documents every step from raw Kaggle records to the evaluated model. The estimator is the centrepiece: pick Delhi to Mumbai on IndiGo, slide the booking window from 60 days down to 1 day, and the predicted fare rises as departure nears, the pattern the model learns from the data. The cheapest-date chart turns that pattern into a decision: in the demo's sample week the cheapest day is Wednesday 16 December 2026 at ₹4,150 against ₹6,480 on Saturday 19 December 2026, a 56% weekend premium. The feature-importance view ranks days to departure first, followed by route and airline, for the viva discussion.
- [Fare estimator web demo] Enter airline, source, destination, departure date and time, stops and days to departure, and the app returns a predicted one-way economy fare in INR with a typical range, plus a per-factor breakdown of what moved the price.
- [Cheapest-date chart] Predicted fares for seven departure dates on one route, with the cheapest day highlighted, so the traveller can see at a glance which day in the week costs least.
- [Feature-importance view] A gain-based ranking of the model inputs — days to departure, route, airline, duration, departure hour, stops and day of week — with a model card stating the algorithm, dataset, split and metrics.
- [Full training notebook] Data loading, cleaning, feature engineering, one-hot encoding, XGBoost training with the reg:squarederror objective, and evaluation in one reproducible Jupyter notebook.
- [RMSE, MAE and R² evaluation] The model is scored on a held-out 20% test split that is touched once, with residual plots included in the report; no accuracy figure is claimed before the training run is executed.
- [Route and airline comparison table] Sample fare observations across six airlines and three stop patterns on Delhi to Mumbai, so the demo shows realistic fare spread rather than a single number.
- [Viva-ready documentation] Report, PPT and Q&A notes covering gradient boosting, feature engineering, train-test discipline and the model's limitations.
What is included
- Complete training & evaluation Jupyter notebook
- Trained XGBoost model file with preprocessing code
- Fare-estimator web demo with cheapest-date chart and feature-importance view
- RMSE, MAE and R² evaluation report with residual plots
- Project report PDF (background, regression theory, feature engineering, methodology, results)
- PPT presentation for final review
- Viva Q&A preparation document (gradient boosting, overfitting, feature importance, train-test discipline)
Limitations & prerequisites
- Trained on Indian domestic flights from March–June 2019 — fares from other years, international routes and other markets are out of scope.
- The dataset has no seat-class split for most rows and no live pricing feed, so the model cannot track real-time fare changes or flash sales.
- 220 duplicate rows and missing values in Route and Total_Stops exist in the raw data and must be handled in preprocessing; results depend on how they are handled.
- Predictions are estimates from historical patterns, not quoted fares — a predicted fare can differ from the price an airline shows on a given day.
- Test RMSE under ₹1,500 is a design target for the training run, stated honestly — the report documents the actual achieved figure after training.
- The demo's fare table uses illustrative sample fares for teaching; only the trained model produces predictions from the real dataset.
Frequently Asked Questions
Which dataset is used and why?
The Kaggle Flight Fare Prediction dataset by Nikhil Mittal — 10,683 rows and 11 columns of Indian domestic flight records from March to June 2019, with airline, route, times, duration, stops and price in INR. It is the standard public dataset for this task, small enough to train on a laptop in minutes, and its fields map directly onto the features a fare model needs.
Every field the model uses is present in the raw data, so no feature has to be invented.
Which model is used and why XGBoost?
An XGBoost regressor (XGBRegressor with the reg:squarederror objective) — gradient-boosted decision trees that handle mixed categorical and numeric features well and give a gain-based feature-importance ranking. That ranking is part of the deliverable: it shows days to departure, route and airline as the top fare drivers, which makes the viva discussion concrete. Linear regression is run as a baseline in the notebook for comparison.
Is the predicted fare a real ticket price?
No — it is an estimate learned from historical fares in the 2019 dataset, not a live quote from an airline. The model predicts what a ticket with those features typically cost in the training data, so it is useful for learning fare drivers and for comparing routes, airlines and booking windows.
It cannot track today's prices, flash sales or seat availability, and the demo labels its illustrative fare table as sample data.
What accuracy can I expect?
No accuracy figure is promised before training, because regression is scored with RMSE, MAE and R², not accuracy, and the numbers depend on the training run. The design target is a test RMSE under ₹1,500 on the held-out 20% split, and the report records the actual RMSE, MAE and R² achieved after the run.
Residual plots show where the model errs most. If the target is missed, the report says so and explains why.
Can the model predict fares for other routes or international flights?
Only routes covered by the training data give trustworthy predictions — the dataset covers Indian domestic city pairs from 2019, so international routes and new city pairs are out of scope as shipped. Adding a route means adding training rows for it; the notebook documents the retraining steps, and a newer, roughly 300,000-row EaseMyTrip dataset from Kaggle can be swapped in as an extension with the same pipeline.
Is this project suitable for a final-year project?
Yes — for Computer Science, IT and AI & Machine Learning programs, because it demonstrates the full regression workflow: dataset validation, feature engineering, gradient-boosted model training, held-out evaluation with RMSE, MAE and R², and a working demo that makes the model testable. The viva kit covers the theory behind every step, from boosting rounds to train-test discipline.
Components & software requirements
- Python 3
- XGBoost · XGBRegressor
- pandas · NumPy
- scikit-learn
- Matplotlib
- Jupyter Notebook
- HTML · CSS · JavaScript demo
- Kaggle Flight Fare Prediction dataset
Delivery information
Built-to-order project. Delivery timeline is shared after order confirmation based on current queue.
Support terms
Complete documentation, setup guide, and viva preparation included. Support for setup and explanation provided.
Download free synopsis (PDF)
Enter your name and WhatsApp number — the synopsis PDF downloads immediately. We may send occasional project updates on WhatsApp; no spam.