It seems that the code given is more to filter samples that are supposedly noisy. Because you’re actually updating the weights first and then based on the predictions, you’re removing those samples from the training set.