ml assignment
ml assignment
ASSIGNMENT NO 2
SCREENSHOTS:
OUTPUT:
CODE:
import numpy as np
import random
data = np.array([
])
def fscaling(data):
min_val = data.min(axis=0)
max_val = data.max(axis=0)
m = len(y)
predictions = X.dot(weights)
return cost
m = len(y)
cost_history = []
for i in range(iterations):
predictions = X.dot(weights)
gradients = (1 / m) * X.T.dot(predictions - y)
cost_history.append(cost)
y = data[:, -1]
weights = np.zeros(X.shape[1])
y = data[:, -1]
weights = np.zeros(X.shape[1])
cost_history = []
for i in range(iterations):
x_i = X[random_index:random_index + 1]
y_i = y[random_index:random_index + 1]
predictions = x_i.dot(weights)
cost_history.append(cost)