In [18]:
xx = np.linspace(-6,2 )
yy_lr = -(w1_final/w2_final)*xx - b_final/w2_final
yy_sk = -(w1_skl/w2_skl)*xx - b_skl/w2_skl

plt.figure(figsize =(10,7))
plt.scatter(X_1_test[:,0], X_1_test[:,1], label = 'class 0', color = 'r')
plt.scatter(X_2_test[:,0], X_2_test[:,1], label = 'class 1', color = 'g')
plt.plot(xx, yy_lr, label = 'Logistic Regression from scratch', color = 'g')
plt.plot(xx, yy_sk, label = 'Logistic Regression from sklearn', color = 'k')
plt.xlabel('feature1')
plt.ylabel('feature2')
plt.title('Comparation of Logistic Regression model from scratch and Logistic Regression from sklearn on test set')
plt.legend()
plt.grid()
plt.show()
In [19]:
plt.figure(figsize =(10,7))
plt.scatter(X_1_train[:,0], X_1_train[:,1],  label = 'class 0', color ='Orange')
plt.scatter(X_2_train[:,0], X_2_train[:,1],  label = 'class 1', color = 'Blue')
plt.plot(xx, yy_lr, label = 'Logistic Regression from scratch', color = 'g')
plt.plot(xx, yy_sk, label = 'Logistic Regression from sklearn', color = 'k')
plt.xlabel('feature1')
plt.ylabel('feature2')
plt.title('Comparation of Logistic Regression model from scratch and Logistic Regression from sklearn on train set')
plt.legend()
plt.grid()