Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Plot the decision boundaries of a classifier
ResourceFunction["DecisionBoundaryPlot"][data] plots the decision boundaries of a classifier trained on data. | |
ResourceFunction["DecisionBoundaryPlot"][data, classifier] plots the decision boundaries of a pre-trained ClassifierFunction classifier trained on data. |
| Method | Automatic | classification algorithm used to classify the data |
| "DataColors" | ColorData[97,"ColorList"] | color scheme representing data classes |
| PointSize | Large | size of points representing the data |
Generate labeled 2D data:
| In[1]:= |
| Out[1]= |
Plot their classification regions:
| In[2]:= |
| Out[2]= | ![]() |
Generate labeled 2D data with three class labels:
| In[3]:= |
| Out[3]= | ![]() |
Plot their classification boundaries:
| In[4]:= |
| Out[4]= | ![]() |
Plot the classification boundary of data as a List of rules:
| In[5]:= |
| Out[5]= | ![]() |
Plot the classification boundary of data as a Rule between points and classes:
| In[6]:= |
| Out[6]= | ![]() |
Generate clusters of 2D data:
| In[7]:= | ![]() |
Classify the data:
| In[8]:= |
| Out[8]= |
Plot the decision regions:
| In[9]:= |
| Out[9]= | ![]() |
Generate data and use the Method option to specify the classification algorithm used to classify the data:
| In[10]:= |
| Out[10]= | ![]() |
| In[11]:= |
| Out[11]= | ![]() |
Compare it with a different classification method:
| In[12]:= |
| Out[12]= | ![]() |
Change the color of each class using the "DataColors" option:
| In[13]:= |
| In[14]:= |
| Out[14]= | ![]() |
Change the size of data points with the PointSize option:
| In[15]:= |
| In[16]:= |
| Out[16]= | ![]() |
Generate data and compare different classification algorithms:
| In[17]:= | ![]() |
| In[18]:= | ![]() |
| Out[18]= | ![]() |
Each classification method accepts its own suboptions. Use the Method option to specify them and visualize how the classification regions change:
| In[19]:= | ![]() |
| In[20]:= | ![]() |
| Out[20]= | ![]() |
The training data must be two dimensional:
| In[21]:= |
| Out[21]= |
The training data must be labeled and formatted correctly:
| In[22]:= |
| Out[22]= |
Generate data for four different classes:
| In[23]:= | ![]() |
Specify different "GammaScalingParameter" values in the "SupportVectorMachine" classifier and notice how it overfits the data as this parameter increases:
| In[24]:= | ![]() |
| Out[24]= | ![]() |
Wolfram Language 14.0 (January 2024) or above
This work is licensed under a Creative Commons Attribution 4.0 International License