supervised machine learning def conditions(self*argscolsample_bytree= **nargs)conds self base_dataset conditions(*args**nargsreturn random sample(condsint(colsample_bytree*len(conds)) boosting learner takes in dataset and base learnerand returns new predictor the base learnertakes datasetand returns learner object learnboosting py -(continued class boosting_learner(learner)def __init__(selfdatasetbase_learner_classsubsample= )self dataset dataset self base_learner_class base_learner_class self subsample subsample mean sum(self dataset target(efor in self dataset train)/len(self dataset trainself predictor lambda :mean function that returns mean for each example self predictor __doc__ "lambda :"+str(meanself offsets [self predictorlist of base learners self predictors [self predictorlist of predictors self errors [data evaluate_dataset(data testself predictorevaluate squared_loss)self display( ,"predict mean test set mean squared loss="self errors[ def learn(selfnum_ensembles= )"""adds num_ensemble learners to the ensemble returns new predictor ""for in range(num_ensembles)train_subset boosted_dataset(self datasetself predictorsubsample=self subsamplelearner self base_learner_class(train_subsetnew_offset learner learn(self offsets append(new_offsetdef new_pred(eold_pred=self predictoroff=new_offset)return old_pred( )+off(eself predictor new_pred self predictors append(new_predself errors append(data evaluate_dataset(data testself predictorevaluate squared_loss)self display( , "iteration {len(self offsets)- },treesize {new_offset num_leavesmean squared loss={self errors[- ]}"return self predictor for testingsp dt learner returns learner that predicts the mean at the leaves and is evaluated using squared loss it can also take arguments to change the default arguments for the trees version june