Float Object is not callable in MPNeuron Class

Hi, I am getting below error in Perceptron Neuron Module
in MPNeuron Class

TypeError                                 Traceback (most recent call last)
<ipython-input-102-f5d991a79c52> in <module>()
      1 mp_neuron = MPNeuron()
----> 2 mp_neuron.fit(X_binarised_train, Y_train)

<ipython-input-101-330dfbb8e4a7> in fit(self, X, Y)
     22       accuracy[b] = accuracy_score(Y_pred, Y)
---> 24     best_b = max(accuracy, key = accuracy.get)
     25     self.b = best_b

TypeError: 'float' object is not callable

Hi @GuruManish,
Can you also post your code for fit() function?
It seems that you’ve also used accuracy as a float variable somewhere, which is being called as an argument for max().

Hi @Ishvinder, below is my fit method

def fit(self, X, Y):

    accuracy = {}


    for b in range(X.shape[1] + 1):

      self.b = b

      Y_pred = self.predict(X)

      accuracy[b] = accuracy_score(Y_pred, Y)


    best_b = max(accuracy, key = accuracy.get)

    self.b = best_b


    print('Optimal value of b is', best_b)

    print('Highest accuracy is', accuracy[best_b])

Can you try storing the accuracy in a list instead of dict, it will be a simplified way to do so.