M1 mini-project — Machine Learning and Modeling course. Authors: Wilfried Aribaud, Camille Frank
Notebook: MiniProjetFinal.ipynb
Dataset: SDSS17 Stellar Classification Dataset (Kaggle)
Can astronomical objects (stars, galaxies, quasars) be classified from photometric data alone — five broadband magnitudes (u, g, r, i, z) — and how much does adding the redshift actually help?
Magnitudes are cheap: they come for free from any image. Redshift is expensive: it normally requires spectroscopy. So the practical question behind this project is whether a classifier can do without it, and if not, how much it is worth.
- Cleaning. Drop flagged outliers (magnitude values of -9999) and unrealistic color indices (u-g, g-r, r-i, i-z outside [-3, 6]).
- Exploration. Histograms and scatter plots of magnitudes, color indices and redshift per class; color indices alone barely separate the classes, redshift does much better.
- Projection. PCA (3 components, ~98% explained variance) and UMAP manifold learning, both with and without redshift, as a preprocessing step for clustering.
- Unsupervised classification. KMeans and a Gaussian Mixture Model, compared across four feature spaces (raw magnitudes, PCA, color indices, UMAP), with and without redshift, and with and without class rebalancing (the raw dataset is ~60% galaxies).
- Supervised classification. Decision tree, random forest, and a Keras MLP, again with and without redshift.
- Redshift is the single most useful feature. Unsupervised accuracy jumps from ~60-62% (magnitudes/color indices only) to 74% (raw KMeans with redshift), and to 79% for the best combination found (GMM on a PCA of magnitudes + redshift). Supervised MLP training loss plateaus around 0.4 without redshift vs. ~0.1 with it.
- Class imbalance silently breaks KMeans. With ~60% galaxies in the raw data, KMeans never identifies stars as their own cluster (0% recall) — it isn't a feature-space problem, it's a structural one: undersampling the majority classes to match the quasar count raises star recall to 53-54%.
- Color indices beat PCA for unsupervised separation, in particular for isolating quasars (recall 0.90 vs. 0.00 for PCA) — they capture flux ratios tied to the objects' physics rather than raw statistical variance.
- Supervised methods are more accurate but less realistic. They need labeled data, which real observation pipelines don't have upfront — their practical role is to bootstrap and validate the unsupervised methods that are actually usable in production.
- Stars and galaxies remain the hardest pair to separate in every setup: even on a balanced dataset, about 30% of them are still confused by KMeans, meaning the class boundary in color space isn't spherical or geometrically simple.
pip install kagglehub pandas numpy seaborn matplotlib scikit-learn umap-learn keras tensorflow
jupyter notebook MiniProjetFinal.ipynbThe first code cell downloads the dataset via kagglehub (a Kaggle account/API
token is required). The notebook also includes optional cells for ipympl /
Google Colab interactive widgets, which can be skipped if not needed.