handling large data on single computer error count is variable to keep track of how many observations are wrongly predicted in this epoch and is returned to the calling function you add one observation to the error counter if the original prediction was wrong an epoch is single training run through all the observations if error ! error_count + for indexvalue in enumerate( )self weights[index+self learning_rate error value the second function that we'll discuss in more detail is the train(function this function has an internal loop that keeps on training the perceptron until it can either predict perfectly or until it has reached certain number of training rounds (epochs)as shown in the following listing listing using train functions training function starts at the first epoch true is always true so technically this is never-ending loopbut we build in several stop (breakconditions def train(self)initiates the number of encountered epoch errors at for each epoch this is while trueimportantbecause if an epoch ends adds one to error_count without errorsthe algorithm the current epoch + converged and we're done number of for ( ,yin zip(self xself )epochs error_count +self train_observation( , ,error_countif error_count = print "training succesfullwe loop through break the data and if epoch >self max_epochsfeed it to the train print "reached maximum epochsno perfect predictionobservation functionbreak an loop to train the data one observation at time if by the end of the epoch we don' have an errortraining was successful if we reach the maximum number of allowed runswe stop looking for solution most online algorithms can also handle mini-batchesthis wayyou can feed them batches of to , observations at once while using sliding window to go over your data you have three optionsfull batch learning (also called statistical learning)--feed the algorithm all the data at once this is what we did in mini-batch learning--feed the algorithm spoonful ( depending on what your hardware can handleof observations at time online learning--feed the algorithm one observation at time