Skip to content

Instantly share code, notes, and snippets.

@Arunprakash-A
Created January 5, 2022 11:39
Show Gist options
  • Save Arunprakash-A/009fbdf154c26286d388ed86a663770d to your computer and use it in GitHub Desktop.
Save Arunprakash-A/009fbdf154c26286d388ed86a663770d to your computer and use it in GitHub Desktop.
# import required packages
import numpy as np
import seaborn as sns
from sklearn.datasets import make_classification
from sklearn.linear_model import Perceptron
from sklearn.metrics import hinge_loss
# create a linearly separable datapoints
x,y = make_classification(n_redundant=0,n_features=2,n_clusters_per_class=1)
# convert the labels to 1 and -1 as we use perceptron loss
y = np.where(y==0,1,-1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment