Skip to content

Add plot_decision_regions_3d for stacked 3D decision regions #488#1154

Open
mariam851 wants to merge 3 commits intorasbt:masterfrom
mariam851:feature-488-3d-decision-plot
Open

Add plot_decision_regions_3d for stacked 3D decision regions #488#1154
mariam851 wants to merge 3 commits intorasbt:masterfrom
mariam851:feature-488-3d-decision-plot

Conversation

@mariam851
Copy link
Contributor

Hi @rasbt,

I have implemented the plot_decision_regions_3d function to address the request in issue #488. Following your suggestion in the discussion, I have created this as a standalone function to maintain the modularity of the library and avoid over-complicating the existing 2D plotting logic.

Key Features:

  • Stacked 3D Visualization: The function allows users to visualize how decision boundaries shift across different values of a third feature by "stacking" 2D slices at specified $Z$ offsets.
  • Smart Grid Generation: It dynamically generates a mesh grid based on the primary features and performs predictions across the specified $Z$ slices.
  • Integrated Scatter Plotting: Includes an option to plot the original 3D data points (scatter_points=True) to provide context for the decision surfaces.
  • Polymorphic Design: Works with any scikit-learn compatible classifier that implements a predict method.

Example Output:

I have tested the implementation with a linear SVM on a 3-feature dataset. As seen in the image below, the function clearly illustrates the decision surfaces at various levels of the third feature:

Screenshot (40) Screenshot (41)

I believe this addition will be very helpful for users trying to interpret higher-dimensional models. Looking forward to your feedback!

Fixes #488

@mariam851 mariam851 force-pushed the feature-488-3d-decision-plot branch from 38dfcb5 to 06ffcea Compare January 6, 2026 16:57
@mariam851 mariam851 force-pushed the feature-488-3d-decision-plot branch from 06ffcea to 7fe774d Compare January 8, 2026 04:23
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stack Decision Region Plots in 3D

1 participant