CoolFace
Apppublic

AryanAstroNomad/exoplanet-classifier

sourceHugging Facemitupdated 1y agoView on Hugging Face
1likes
App README

๐ŸŒŒ Exoplanet Classification ML Model

This project uses machine learning to classify exoplanets by:

  • โ€”๐Ÿช Planet Type (Terrestrial, Super-Earth, Neptune-like, Gas Giant)
  • โ€”๐Ÿ›ฐ๏ธ Detection Method (Transit, Radial Velocity)

The model is trained on real data from NASA's Exoplanet Archive using Random Forest classifiers.


๐Ÿ“ Dataset

Features Used:

  • โ€”pl_rade: Planet radius
  • โ€”pl_bmasse: Planet mass
  • โ€”pl_orbper: Orbital period
  • โ€”pl_orbsmax: Orbital semi-major axis
  • โ€”st_rad: Stellar radius
  • โ€”st_mass: Stellar mass
  • โ€”st_teff: Stellar effective temperature

๐ŸŽฏ Targets

  1. 1.Planet Type (generated by function based on pl_rade):
  2. 2.< 1.25: Terrestrial
  3. 3.1.25โ€“2: Super-Earth
  4. 4.2โ€“6: Neptune-like
  5. 5.> 6: Gas Giant
  1. 1.Detection Method:
  2. 2.Only methods with โ‰ฅ10 samples retained
  3. 3.Balanced using SMOTE to avoid overfitting on "Transit"

๐Ÿง  Models

Both models use RandomForestClassifier from scikit-learn.

  • โ€”Planet Type Classifier
  • โ€”Detection Method Classifier

SMOTE is applied to the detection method classification to fix class imbalance.


๐Ÿ’พ Files Created

  • โ€”planet_type_model.pkl
  • โ€”detection_method_model.pkl

These are saved using joblib and downloadable in Colab.


๐Ÿงช Sample Input

python
sample_input = {
    'pl_rade': 3.8,
    'pl_bmasse': 20.0,
    'pl_orbper': 3.5,
    'pl_orbsmax': 0.04,
    'st_rad': 0.95,
    'st_mass': 0.88,
    'st_teff': 5200
}

๐Ÿš€ How to Use

1. Install Dependencies

bash
pip install pandas numpy scikit-learn imbalanced-learn joblib

2. Load Models

python
import joblib
import pandas as pd

clf_type = joblib.load('planet_type_model.pkl')
clf_method = joblib.load('detection_method_model.pkl')

3. Prepare Input & Predict

python
input_df = pd.DataFrame([sample_input])

planet_type = clf_type.predict(input_df)[0]
detection_method = clf_method.predict(input_df)[0]

print("Planet Type:", planet_type)
print("Detection Method:", detection_method)

4. Optional: Get Probabilities

python
clf_method.predict_proba(input_df)

โ— Expected Prediction Errors

Even with high accuracy, the model may produce the following prediction errors due to data limitations or feature overlap:

๐Ÿช Planet Type Prediction Errors

MistakeWhy It Happens
Super-Earth โ†’ TerrestrialThese classes have close radius thresholds (~1.25), so slight variations cause confusion.
Neptune-like โ†’ Gas GiantPlanets near the 6 Earth-radius boundary may be misclassified if other features (mass, orbit) resemble giants.
Gas Giant โ†’ Neptune-likeIf radius is just above 6 but mass is small, the model may lean toward Neptune-like.

๐Ÿ›ฐ๏ธ Detection Method Prediction Errors

MistakeWhy It Happens
Radial Velocity โ†’ TransitMost planets are discovered via Transit, and their feature profiles (short orbit, large radius) often overlap.
Transit โ†’ Radial VelocityIf a Transit planet has low radius, long orbital period, or low stellar brightness, it may resemble RV-discovered planets.
Bias toward TransitDespite SMOTE, the model can still slightly favor Transit due to feature dominance and real-world imbalance.

๐Ÿ” Tips to Reduce Errors

  • โ€”Include more distinctive features like planet inclination, eccentricity, or detection signal strength (if available).
  • โ€”Use a multi-model ensemble (e.g., add logistic regression or XGBoost).
  • โ€”Fine-tune SMOTE or try class-weighted models instead.

๐Ÿ‘จโ€๐Ÿ’ป Author

  • โ€”Made by Aryan Hotwani
  • โ€”Powered by NASA exoplanet data and scikit-learn