Machine Learning Lab: Raheel Aslam (74-FET/BSEE/F16)
Machine Learning Lab: Raheel Aslam (74-FET/BSEE/F16)
Machine Learning Lab: Raheel Aslam (74-FET/BSEE/F16)
# Input
x = dataset.iloc[:, [2, 3]].values
# Output /
y = dataset.iloc[:, 4].values
plt.contourf(X1, X2,
classifier.predict(np.array([X1.ravel(),X2.ravel()]).T).reshape(X1.shape), alpha =
0.75, cmap = ListedColormap(('red', 'green')))
plt.xlim(X1.min(), X1.max())
plt.ylim(X2.min(), X2.max())
for i, j in enumerate(np.unique(y_set)):
plt.scatter(X_set[y_set == j, 0], X_set[y_set == j, 1],c = ListedColormap(('red',
'green'))(i), label = j)
Output:
[[-0.81649658 -0.81649658]
[-0.81649658 -0.81649658]
[-0.81649658 -0.81649658]
[-0.81649658 -0.81649658]
[ 1.22474487 1.22474487]
[-0.81649658 1.22474487]
[-0.81649658 1.22474487]
[ 1.22474487 -0.81649658]
[ 1.22474487 1.22474487]
[ 1.22474487 -0.81649658]]
Confusion Matrix :
[[1 0]
[0 3]]
Accuracy : 1.0
Analysis:
Therefore, the analysis of the result is that by using logistic regression using scikit learn the
accuracy can be almost 100 percent and the classes are accurately differentiated and as you can
see both the classes 0 and 1 are differentiated using result and present a way better result than
linear regression.