supervised machine learning col colors[degree len(colors)plt plot(x_values,[learner predictor([ ]for in x_values]linestyle=lscolor=collabel="degree="+str(degree)plt legend(loc='upper left'plt draw( trydata data_from_file('data/simp_regr csv'prob_test= boolean_features=falsetarget_index=- plot_prediction(data plot_polynomials(data #datam data_from_file('data/mail_reading csv'target_index=- #plot_prediction(datambatched stochastic gradient descent this implements batched stochastic gradient descent if the batch size is it can be simplified by not storing the differences in dbut applying them directlythis would the be equivalent to the original codethis overrides the learner linear learner note that the comparison with regular gradient descent is unfair as the number of updates per step is not the same (how could it me made more fair?learnlinearbsgd py -linear learner with batched stochastic gradient descent from learnlinear import linear_learner import randommath class linear_learner_bsgd(linear_learner)def __init__(self*argsbatch_size= **kargs)linear_learner __init__(self*args**kargsself batch_size batch_size def learn(self,num_iter=none)if num_iter is nonenum_iter self number_iterations batch_size min(self batch_sizelen(self train) {feat: for feat in self weightsfor it in range(num_iter)self display( ,"prediction=",self predictor_string()for in random sample(self trainbatch_size)error self predictor(eself target(eupdate self learning_rate*error for feat in self weightsd[feat+update*feat(efor feat in self weightsself weights[feat- [featd[feat]= return self predictor version june