You need to agree to share your contact information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this model content.

YAML Metadata Warning: empty or missing yaml metadata in repo card (https://huggingface.co/docs/hub/model-cards#model-card-metadata)

πŸš€ NASA NEO Risk Prediction AI

This project demonstrates how to fetch real Near-Earth Object (NEO) data from NASA’s API, preprocess it, and train machine learning models (Random Forest, Gradient Boosting, etc.) to predict asteroid hazard risk scores.


πŸ“Œ Features

  • Fetch asteroid data from the NASA NEO API.
  • Preprocess raw JSON into structured features.
  • Train multiple ML models (Random Forest, Gradient Boosting).
  • Evaluate models with MAE, RMSE, RΒ².
  • Save trained models with joblib.
  • Serve predictions using FastAPI + Swagger UI.

βš™οΈ Setup

1. Clone repo and install dependencies

git clone https://github.com/waqarali5498/nsa-hackathon-ml-model
cd nsa-hackathon-ml-model
python -m venv venv
source venv/bin/activate     # On Mac/Linux
venv\Scripts\activate        # On Windows

pip install -r requirements.txt

2. Get NASA API Key

Go to: https://api.nasa.gov/

Generate a free API key.

Set it as an environment variable:

Mac/Linux:
export NASA_API_KEY="YOUR_KEY_HERE"

Windows (PowerShell):
setx NASA_API_KEY "YOUR_KEY_HERE"

(Restart terminal after setting this.)

πŸ“₯ Fetching NEO Data

Run:

python fetch_data.py --start_date 2024-01-01 --end_date 2024-01-07

This will save asteroid data into:

data/neo_data.csv

🧠 Training ML Models

Run:

python train_model.py

Example output:

RandomForest     | MAE: 9504.88 | RMSE: 363066.06 | RΒ²: 0.731
GradientBoosting | MAE: 9072.66 | RMSE: 320519.61 | RΒ²: 0.790


The best model is saved to:

models/neo_model_v1.joblib

🌐 Running API (FastAPI + Swagger)

Start the API:

uvicorn app:app --reload

Open Swagger UI: http://127.0.0.1:8000/docs

Test predictions with JSON input:

{
  "diameter_km": 0.5,
  "velocity_kms": 12.3,
  "miss_distance_km": 150000,
  "absolute_magnitude": 22.1
}

πŸ“Š Evaluation Metrics

MAE (Mean Absolute Error) β†’ Lower is better.

RMSE (Root Mean Squared Error) β†’ Penalizes large errors.

RΒ² (Coefficient of Determination) β†’ Closer to 1 is better.

πŸ“‚ Project Structure


nsa-hackathon-ml-model/
│── data/                 # Raw and processed NEO data
│── models/               # Saved ML models (.joblib)
│── app.py                # FastAPI app for predictions
│── fetch_data.py         # Script to fetch NASA NEO data
│── train_model.py        # Train and evaluate ML models
│── requirements.txt      # Python dependencies
│── README.md             # Project documentation

πŸ™Œ Acknowledgements


NASA Open APIs
 for providing NEO datasets.

Scikit-learn for ML models.

FastAPI + Swagger UI for serving predictions.
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support