from numpy import * import operator def createDataSet(): group = array([[3,104],[2,100],[1,81],[101,10],[99,5],[98,2]]) labels = ['爱情片','爱情片','爱情片','动作片','动作片','动作片'] return group, labels def classify0(inX, dataSet, labels, k): dataSetSize = dataSet.…