What is Perceptron

Photo by dylan nolte on Unsplash

What is Perceptron

It is an algorithm that is used for supervised ml problems.

Note:

Perceptron can only classify linear or sort of linear data.

Code Example:

import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import requests
from io import StringIO
def get_data_from_url(url,cols=None):
    req = requests.get(url)
    data = StringIO(req.text)
    if cols != None:
        return pd.read_csv(data,usecols=cols)
    else:
        return pd.read_csv(data)
df = get_data_from_url("https://raw.githubusercontent.com/campusx-official/100-days-of-deep-learning/main/day3/placement.csv")
df.shape
df.head()
sns.scatterplot(x=df['cgpa'],y=df['resume_score'],hue=df['placed'])
plt.show()
X = df[['cgpa','resume_score']]
Y = df['placed']
from sklearn.linear_model import Perceptron
p = Perceptron()
p.fit(X,Y)
p.coef_
p.intercept_
from mlxtend.plotting import plot_decision_regions
plot_decision_regions(X.values, Y.values, clf=p, legend=2)
plt.show()