import numpy as np
import matplotlib.pyplot as plt
X = np.array([[0,0],[0,1],[1,0],[1,1]])
y = np.array([0,0,0,1])
df = pd.read_csv("data.csv")
X = df.iloc[:,:2].values
y = df.iloc[:,-1].values
w = np.zeros(2)
b,lr = 0,0.1
for _ in range(20):
    for xi,yi in zip(X,y):
        pred = int(np.dot(w,xi)+b >= 0.5)
        w += lr*(yi-pred)*xi
        b += lr*(yi-pred)
print("Predicted:",[int(np.dot(w,xi)+b >= 0.5) for xi in X])
print("Actual:",y)
x1 = np.linspace(X[:,0].min(),X[:,0].max(),100)
plt.scatter(X[:,0],X[:,1],c=y)
if w[1] != 0:
    plt.plot(x1,(0.5-b-w[0]*x1)/w[1])
plt.show()


import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import tensorflow as tf
import time
import datetime
from tensorflow.keras import regularizers