Search code examples
pythonmatplotlibscatter-plotmultilabel-classificationsupervised-learning

Scatter plot for Multi-label classification For Two Features With Decision Boundary


Dataset containing two labels 0,1 , how to plot a scatter plot for it..?

    Age EstimatedSalary Purchased
0   19  19000             0
1   35  20000             0
2   26  43000             0
3   27  57000             0
4   19  76000             0 
... ... ... ...         .....
395 46  41000             1
396 51  23000             1
397 50  20000             1
... ... ... ...         .....

Solution

  • Set the "c" parameter equal to the target variable

    data.head()
    

    data frame

    X = data.iloc[:,0:2].values
    y = data.iloc[:,2:3].values
    plt.scatter(X[:,0:1], X[:,1:2], c=y)
    plt.show
    

    scatter plot