cosmoclassifier
An ML classifier web app trained on SDSS dataset which can classify celestial objects
1.4K
The project is well-maintained on GitHub. To check the GitHub repo, click hereβ
A machine learningβpowered web application that classifies celestial objects (Galaxies, Stars, and Quasars) using data from the Sloan Digital Sky Survey DR18 (SDSS DR18).
Built with Flask, Scikit-Learn, and Pandas, this project blends astronomy with machine learning to create an interactive and educational tool for space data analysis.
This project demonstrates the intersection of astrophysics and applied machine learning which has made space data exploration more accessible.
The CosmoClassifier uses a trained Random Forest Classifier optimized through Sequential Feature Selection (SFS) to predict whether a given object in the universe is a Galaxy, Star, or Quasar (QSO).
The model is hosted via a Flask web app where users can input photometric parameters (like magnitudes and redshift) and get instant predictions with probability scores.
The Sloan Digital Sky Survey (SDSS) is one of the largest astronomical databases ever created. But handling its raw data isnβt exactly beginner-friendly.
This project simplifies that complexityβtransforming high-dimensional SDSS data into an approachable, real-time classification tool.

GALAXY β 0STAR β 1QSO β 2u_g_color = u β gg_r_color = g β rr_i_color = r β ii_z_color = i β z| Step | Description |
|---|---|
| Imputation | Missing values handled using median strategy |
| Scaling | Standardized with StandardScaler |
| Feature Selection | Sequential Feature Selector (SFS) with Random Forest |
| Classifier | Random Forest Classifier (max_depth = 10, n_estimators = 150, class_weight = "balanced") |
Final model artifacts are serialized with joblib as:
models/
βββ pipe.pkl
βββ column_names.pkl
Multiple combinations of models and dimensionality-reduction methods were tested before finalizing the architecture:
| Dimensionality Reduction / Model β β | Random Forest | Support Vector Classifier | Logistic Regression |
|---|---|---|---|
| Principal Component Analysis (PCA) | 0.9803 | 0.9471 | 0.9725 |
| Linear Discriminant Analysis (LDA) | 0.9846 | 0.9832 | 0.9832 |
| Sequential Feature Selection (SFS) | 0.9870 | β | β |
β Chosen Model: Random Forest + SFS (Accuracy β 98.7 %)
You can find the code for other algorithms in the notebooks folder of the repository.
THE_COSMOCLASSIFIER/
βββ Datasets/
β βββ SDSS_DR18.csv # Primary dataset for training and analysis
βββ models/
β βββ column_names.pkl # List of column names used in the model
β βββ pipe.pkl # Serialized machine learning pipeline (model)
βββ notebooks/
β βββ research_2.ipynb # Research notebook used later for implementing feature reduction
β βββ research_LR.ipynb # Research notebook for Logistic Regression
β βββ research_RF.ipynb # Research notebook for Random Forest
β βββ research_SVC.ipynb # Research notebook for Support Vector Classifier
βββ static/ # Static assets for the web application
β βββ script.js # Frontend JavaScript logic
β βββ style.css # Frontend CSS styling
βββ templates/
β βββ index.html # HTML template for the web application
|
βββ .gitignore # Files and directories to be excluded from version control
βββ app.py # Main Flask application file for the web service
βββ fit.py # Script for training and saving the machine learning model
βββ LICENSE # Licensing information
βββ requirements.txt # Python package dependencies
git clone https://github.com/ByteBard58/The_CosmoClassifier
cd The_CosmoClassifier
pip install -r requirements.txt
python app.py
Then open your browser at http://127.0.0.1:5000/β
If the serialized model isnβt found, app.py automatically trains and saves a new one using fit.py.
A Dockerhub repositoryβ is created where I have pushed the docker image which contains the entire Cosmoclassifier app.
The image is built on both ARM64 and AMD64 architectures, so that it can run on almost all major computers. You can run the app easily by using the Dockerhub Image. Here's how you can do it:
Install Docker Desktopβ and sign-in. Make sure the app is functioning properly.
Open Terminal and run:
docker pull bytebard101/cosmoclassifier:latest
docker run --rm -p 5000:5000 bytebard101/cosmoclassifier:latest
docker run --rm -p 5001:5000 bytebard101/cosmoclassifier:latest
If you followed Step 2 and the command ran successfully, then DO NOT follow this step.
Check Docker Documentationβ to learn more about Docker and it's commands.
Users can input photometric parameters such as:
Right Ascension (deg)
Declination (deg)
Redshift
PSF Magnitude (r band)
Color contrast features (u_g_color, g_r_color, r_i_color, i_z_color)
The app returns the predicted class with its confidence probabilities.
Note: Due to the absence of front-end web development expertise and the lack of other contributors for the project, I had to resort to using AI tools (such as LLM services like ChatGPTβ’, Grokβ’, and GitHub Copilotβ’) to create a sophisticated front-end for the web app.
Languages: Python, HTML, CSS, JavaScript
Libraries: Flask, Scikit-Learn, Pandas, NumPy, Joblib, Notebook
Dataset Source: Sloan Digital Sky Survey DR18 (Kaggle)
Sakib ( ByteBard58 )
Student | Aspiring Computer Engineer | AI & ML Enthusiast
π GitHub Profile: ByteBard58β
Thank You for taking the time to review my work. I hope you enjoyed it and found it interesting. It would mean a lot to me if you could star it on GitHub π
If you have any questions, suggestions, or anything youβd like to discuss, please donβt hesitate to reach out. You can find my contact information on my GitHub profile pageβ . Iβm all ears! π
Have a great day !
Content type
Image
Digest
sha256:32b03b179β¦
Size
1.2 GB
Last updated
3 months ago
docker pull bytebard101/cosmoclassifier