Home > Back-end >  TypeError: 'float' object cannot be interpreted as an integer , the costhistory has to be
TypeError: 'float' object cannot be interpreted as an integer , the costhistory has to be

Time:03-02

enter image description here

here cost_history is supposed to be a float array, idk what the error means, help

CodePudding user response:

The error states that iters is not an int. This seems to be because you're passing the arguments in a different order than expected. Notice the function definition:

def bgd(X, y, w, iters, lamb, alpha):

And now, checkout the variable names you provide to call the function:

bgd(X, y, w, alpha, iters, lamb)

You probably want to change your function call to:

bgd(X, y, w, iters, lamb, alpha)

CodePudding user response:

You have mixed up alpha and iters. Your definition and calling mixed up. so np.zeros is getting alpha which is float instead of iters.

  • Related