of the data equal to prob test [an alternative is to use random sample(which can guarantee that the test set will contain exactly particular proportion of the data however this would require knowing how many elements are in the data setwhich we may not knowas data may just be generator of the data ( when reading the data from filelearnproblem py -(continued def partition_data(dataprob_test= )"""partitions the data into training set and test setwhere prob_test is the probability of each example being in the test set ""train [test [for example in dataif random random(prob_testtest append(exampleelsetrain append(examplereturn traintest importing data from file data set is typically loaded from file the default here is that it loaded from csv (comma separated valuesfilealthough the separator can be changed this assumes that all lines that contain the separator are valid data (so we only include those data items that contain more than one elementthis allows for blank lines and comment lines that do not contain the separator howeverit means that this method is not suitable for cases where there is only one feature note that data all and data tuples are generators data all is generator of list of list of strings this version assumes that csv files are simple the standard csv packagethat allows quoted argumentscan be used by uncommenting the line for data all and commenting out the following line data tuples contains only those lines that contain the delimiter (others lines are assumed to be empty or comments)and tries to convert the elements to numbers whenever possible this allows for some of the columns to be includedspecified by include only note that if include only is specifiedthe target index is the index for the included columnsnot the original columns learnproblem py -(continued class data_from_file(data_set)def __init__(selffile_nameseparator=','num_train=noneprob_test= has_header=falsetarget_index= boolean_features=truecategorical=[]target_typenoneinclude_only=noneseed=none)#seed= )version june