0

i need to compute this using this formula

formula this is the code so far

y_bar=np.array([0.5, 0.88079708 ,0.26894142, .1, .3])
y=np.array([1,1,0,1,0])
print(loss_fun(y, y_bar))

def compute_grad(X, y, y_bar):

    ##### this is where the fuction should be

X=np.array([[1,0.77132064, 0.02075195, 0.63364823],
 [1, 1.74880388 ,0.49850701 ,0.22479665],
 [1, 0.19806286, 0.76053071 ,0.16911084],
 [1, 0.08833981 , 3.68535982 , -0.95339335],
 [1, -0.00394827 ,0.51219226 ,0.81262096]])

print(X.shape)

y_bar=np.array([0.5, 0.88079708 ,0.26894142, .1, .3])
y=np.array([1,1,0,1,0])
g=compute_grad(X, y, y_bar)

print(g)

what is the right formula computation in python? is there any steps i should follow? thank you

Miss SHOOSH
  • 81
  • 1
  • 1
  • 7
  • If you want to calculate the derivative numerically, then have a look at https://stackoverflow.com/questions/9876290/how-do-i-compute-derivative-using-numpy. I am not entirely sure about the analytical derivative, what is ```g``` and ```y_bar``` in reference to the formula? – Kevin Mar 26 '21 at 14:52
  • If you knew what each of the terms meant in the formula, then we could tell you how to implement the equation in numpy, but we can't tell you what the terms are and how to get them from your data (unless someone recognizes that formula). Currently, you don't have a term that looks like *theta*, or *m*, or even *g* (although you have something named *g*, it doesn't seem to match the meaning of *g* in the formula). That is, generally you need the correct value (or array of values) for every term on the RHS, and currently you don't. – tom10 Mar 26 '21 at 16:05

0 Answers0