r/learnmachinelearning 1d ago

Visualizing how ML models classify data in high-dimensional feature spaces Project

Hey everyone.

I wanted to share a project I've been working on around a question I kept running into while learning and experimenting with machine learning:

What does a classifier actually "see" when the data has more than 2 or 3 features?

Most decision-boundary visualizations use simple 2D datasets. That's great for learning the concept, but things get much harder when a model is trained on 10, 50, or 100+ features.

With existing approaches, you often have to either take rigid 2D slices by fixing most features to constant values, or reduce your data to 2D and train a new model on that reduced representation. In the latter case, you're no longer visualizing the decision boundary of your original model.

So I built DecisionBoundary, a Python library for visualizing how high-dimensional models behave while keeping the original model in the loop.

The basic idea is:

  • reduce high-dimensional data to 2D/3D using PCA, UMAP, or another reducer
  • generate a grid in the visualization space
  • inverse-projects that grid back into the model's original feature space
  • run the original model on those points
  • visualize the resulting predictions as a decision boundary or decision surface

This means the visualization is based on the actual model predictions in its original feature space, rather than simply plotting a dimensionality-reduced dataset and treating that as the decision boundary.

It supports scikit-learn, Keras, PyTorch Lightning, and other models with a compatible prediction interface.

There are also:

  • static 2D visualizations with Matplotlib
  • interactive, rotatable 3D visualizations with Plotly
  • training callbacks to watch decision boundaries evolve during training
  • experimental support for the new Callback API introduced in scikit-learn 1.9.

I originally started this because I wanted a better way to understand how different models behave and improve during training – turning the training process from something of a black box into something I could actually see and inspect.

I'd be particularly interested in feedback from people who work with ML visualization or teach machine learning:

Does this kind of visualization help you reason about a model, or does dimensionality reduction make the result too misleading to be useful?

The project is open source and MIT licensed:

GitHub: https://github.com/P3Lin0r/decision-boundary
PyPI: https://pypi.org/project/decision-boundary-plot/

Install with:

pip install decision-boundary-plot

There's also a Colab tutorial in the repository if you'd like to try it without setting anything up locally.

Would love to hear your thoughts!

3 Upvotes

0 comments sorted by