Training Error

Hi All,

Can somebody explain what training method is doing esp prediction line I have not sure I understand the nested function in the method

Perceptron | Codecademy

class Perceptron:
  def __init__(self, num_inputs=2, weights=[1,1]):
    self.num_inputs = num_inputs
    self.weights = weights
  def weighted_sum(self, inputs):
    weighted_sum = 0
    for i in range(self.num_inputs):
      weighted_sum += self.weights[i]*inputs[i]
    return weighted_sum
  def activation(self, weighted_sum):
    if weighted_sum >= 0:
      return 1
    if weighted_sum < 0:
      return -1
# Can somebody explain what is happening in this loop?  what is prediction doing? it is a nested function 

  def training(self, training_set):
    for inputs in training_set:
      prediction = self.activation(self.weighted_sum(inputs))
      actual = training_set[inputs]
      error = actual - prediction
cool_perceptron = Perceptron()
print(cool_perceptron.weighted_sum([24, 55]))