Flask + vanilla JS web app that wraps your notebook pipeline: upload a TESS light curve FITS file, and it runs BLS transit search, pulls stellar parameters from MAST, feeds the feature vector into your trained XGBoost model, and shows the classification + all diagnostic plots.
model/xgb_model.pkl, model/label_encoder.pkl, and model/imputer.pkl are
already trained on your tois.csv (8,035 rows, mapped to Planet/Candidate/
Binary/Other) and included in this package. Trained with
scikit-learn==1.8.0 and xgboost==3.3.0 (pinned in requirements.txt — use
these versions or the pickles may fail to load).
Bug fixed: Depth Radius Ratio is now computed the same way at both
training and inference time — Depth (ppm) / Stellar Radius (R_Sun).
Previously training used Planet Radius (R_Earth) instead, so one of the 12
model inputs was silently different between training and inference. Retrained
after the fix.
Test accuracy on a held-out 20% split: 80.8% overall. Classes remain imbalanced (Candidate: 6381, Planet: 976, Binary: 599, Other: 78 rows), so per-class performance is still uneven — Planet recall 0.30, Binary recall 0.17, Other unlearned (only 16 test rows, 0 predicted). The train/inference mismatch fix didn't meaningfully move overall accuracy, which tells you the real limiter here is class imbalance, not that one feature — the minority classes just don't have enough data for XGBoost to learn robust decision boundaries for them. If you want, I can add class weighting or SMOTE oversampling to improve minority-class recall — that's the next highest- leverage fix.
If you retrain later, drop new pickles into model/ to replace these.
cd exoplanet_app
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txtpython app.pyOpen http://127.0.0.1:5000, upload a .fits light curve file (e.g. a TESS
SPOC/QLP light curve file), click Analyze.
app.py -> /analyze endpoint:
- Saves the uploaded FITS to a temp file
- Reads it with
lightkurve, extractsTICIDfrom the header - Cleans (quality mask + 5-sigma outlier removal), flattens, normalizes
- Runs a BLS periodogram search over periods 0.5–20 days
- Extracts period/duration/depth/SNR/t0, folds the light curve at best period
- Queries MAST (
astroquery.mast.Catalogs) for TESS mag, stellar radius, Teff using the TIC ID - Builds the same 12-feature vector as training, imputes, predicts with XGBoost
- Returns JSON: predicted class, probabilities, transit/stellar params, and 6 base64-encoded plots (raw LC, cleaned LC, flattened LC, BLS periodogram, folded transit, probability bar chart)
The frontend (static/app.js) just posts the file and renders everything.
- MAST lookups are live network calls — expect 5–15s added latency, and
they will fail if
TICIDisn't in the FITS header or MAST is unreachable. The app degrades gracefully (fills those features with NaN, which yourimputerhandles) but flags a warning in the UI. - Pickle version sensitivity: pin
xgboost/scikit-learnversions inrequirements.txtto match what you trained with, or re-save the pickles in the same environment you deploy in. - Upload size limit is set to 50MB in
app.py(MAX_CONTENT_LENGTH) — TESS light curve FITS files are usually a few MB, so this is generous. - For production hosting (Render, Railway, Fly.io, a VPS), run behind
gunicorninstead of the Flask dev server:gunicorn -w 2 -b 0.0.0.0:8000 app:app(use-w 1if memory-constrained, since each worker loads the model into memory). - If you want to avoid the live MAST call entirely (e.g. for speed or offline use), you could let the user optionally type in TESS mag / stellar radius / Teff manually as a fallback form — happy to add that if useful.