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.
Inference Providers
NEW
This model isn't deployed by any Inference Provider.
π
Ask for provider support