quick look at machine learning the last part of readmammaldata uses the values in featurevals to create list of feature vectorsone for each mammal (the code could be simplified by not constructing featurevals and instead directly constructing the feature vectors for each mammal we chose not to do that in anticipation of an enhancement to readmammaldata that we make later in this section def readmammaldata(fname)datafile open(fname' 'numfeatures #process lines at top of file for line in datafile#find number of features if line[ : ='#label'#indicates end of features break if line[ : !'#name'numfeatures + featurevals [#produce featurevalsspeciesnamesand labellist featurevalsspeciesnameslabellist [][][for in range(numfeatures)featurevals append([]#continue processing lines in filestarting after comments for line in datafiledataline string split(line[:- ]','#remove newlinethen split speciesnames append(dataline[ ]classlabel float(dataline[- ]labellist append(classlabelfor in range(numfeatures)featurevals[iappend(float(dataline[ + ])#use featurevals to build list containing the feature vectors #for each mammal featurevectorlist [for mammal in range(len(speciesnames))featurevector [for feature in range(numfeatures)featurevector append(featurevals[feature][mammal]featurevectorlist append(featurevectorreturn featurevectorlistlabellistspeciesnames figure read and process file the function testteeth in figure uses trykmeans to cluster the examples built by the other functionbuildmammalexamplesin figure it then reports the number of herbivorescarnivoresand omnivores in each cluster