Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

TESS Exoplanet Detector — Web App

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.

1. Model files — already included

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.

2. Install dependencies

cd exoplanet_app
python -m venv venv
source venv/bin/activate   # Windows: venv\Scripts\activate
pip install -r requirements.txt

3. Run it

python app.py

Open http://127.0.0.1:5000, upload a .fits light curve file (e.g. a TESS SPOC/QLP light curve file), click Analyze.

How it works

app.py -> /analyze endpoint:

  1. Saves the uploaded FITS to a temp file
  2. Reads it with lightkurve, extracts TICID from the header
  3. Cleans (quality mask + 5-sigma outlier removal), flattens, normalizes
  4. Runs a BLS periodogram search over periods 0.5–20 days
  5. Extracts period/duration/depth/SNR/t0, folds the light curve at best period
  6. Queries MAST (astroquery.mast.Catalogs) for TESS mag, stellar radius, Teff using the TIC ID
  7. Builds the same 12-feature vector as training, imputes, predicts with XGBoost
  8. 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.

Notes / things to check before deploying

  • MAST lookups are live network calls — expect 5–15s added latency, and they will fail if TICID isn't in the FITS header or MAST is unreachable. The app degrades gracefully (fills those features with NaN, which your imputer handles) but flags a warning in the UI.
  • Pickle version sensitivity: pin xgboost/scikit-learn versions in requirements.txt to 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 gunicorn instead of the Flask dev server: gunicorn -w 2 -b 0.0.0.0:8000 app:app (use -w 1 if 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.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages