function train_boosted(data, num_rounds):
   weights = [1 / length(data)] * length(data)

   models = []
   for round in range(num_rounds):
      model = train_weak_model(data, weights)
      errors = [1 if model.predict(x) != y else 0 for x, y in data]
      for i in range(length(data)):

        if errors[i]:
           weights[i] *= 1.5 # focus the next round on missed exampl
 es
      models.append(model)
   return models # final prediction combines every model's weighted vote
