3
from sklearn import datasets
import numpy as np
import pandas as pd from sklearn.model_selection
import train_test_split
from sklearn.linear_model import Perceptron

data = pd.read_csv('student_selection.csv')

x = data[['Average','Pass','Division','Domicile']]
y = data[['Selected']]

x_train,x_test,y_train,y_test train_test_split(x,y,test_size=1,random_state=0)

ppn = Perceptron(eta0=1.0, fit_intercept=True, max_iter=1000, n_iter_no_change=5, random_state=0)

ppn.fit(x_train, y_train)

y_pred = ppn.predict(x_train)

x_train['Predicted'] = pd.Series(y_pred)

How to see the actual vs predicted as a table and along with a plot? x_train is the value I am getting as predicted, but I am unable to merge it with the actual data to see the deviation.

technogeek1995
  • 3,185
  • 2
  • 31
  • 52
Output Scream
  • 27
  • 1
  • 4

1 Answers1

2

How to see the actual vs predicted as a table and along with a plot?

Just run:

y_predict= pnn.predict(x)

data['y_predict'] = y_predict

and have the column in your dataframe, if you want to plot it you can use:

import matplotlib.pyplot as plt
plt.scatter(data['Selected'], data['y_predict'])
plt.show()
PV8
  • 5,799
  • 7
  • 43
  • 87