supervised machine learning the prediction is either real value or {value probabilitydictionary or list the actual is either real number or key of the prediction learnproblem py -(continued class evaluate(object)""" container for the evaluation measures"" def squared_loss(predictionactual)"squared loss if isinstance(prediction(list,dict))return ( -prediction[actual])** the correct value is elsereturn (prediction-actual)** def absolute_loss(predictionactual)"absolute loss if isinstance(prediction(list,dict))return abs( -prediction[actual]the correct value is elsereturn abs(prediction-actual def log_loss(predictionactual)"log loss (bits)tryif isinstance(prediction(list,dict))return -math log (prediction[actual]elsereturn -math log (predictionif actual== else -math log ( -predictionexcept valueerrorreturn float("inf"infinity def accuracy(predictionactual)"accuracy if isinstance(predictiondict)prev_val prediction[actualreturn if all(prev_val > for in prediction values()else if isinstance(predictionlist)prev_val prediction[actualreturn if all(prev_val > for in predictionelse elsereturn if abs(actual-prediction< else all_criteria [accuracyabsolute_losssquared_losslog_losscreating test and training sets the following method partitions the data into training set and test set note that this does not guarantee that the test set will contain exactly proportion version june