the first thing we need is dataset to train our algorithm on in production systemyou might scrape list of colors website or survey thousands of people insteadi created simple application that renders random color and asks the user to select one of the preceding nine options to classify it this application is included with the example code for this in the kivy_color_classifier directorybut we won' be going into the details of this code as its only purpose here is to generate sample data kivy has an incredibly well-engineered object-oriented api that you may want to explore on your own time if you would like to develop graphical programs that run on many systemsfrom your laptop to your cell phoneyou might want to check out my bookcreating apps in kivyo'reilly for the purposes of this case studythe important thing about that application is the outputwhich is comma-separated value (csvfile that contains four values per rowthe redgreenand blue values (represented as floating-point number between zero and one)and one of the preceding nine names that the user assigned to that color the dataset looks something like this , , ,green , , ,grey , , ,blue , , ,pink , , ,purple , , ,yellow , , ,purple , , ,purple , , ,blue , , ,green made datapoints ( very few of them untruebefore got bored and decided it was time to start machine learning on this dataset these datapoints are shipped with the examples for this if you would like to use my data (nobody' ever told me ' color-blindso it should be somewhat reasonablewe'll be implementing one of the simpler machine-learning algorithmsreferred to as -nearest neighbor this algorithm relies on some kind of "distancecalculation between points in the dataset (in our casewe can use three-dimensional version of the pythagorean theoremgiven new datapointit finds certain number (referred to as kas in -nearest neighborsof datapoints that are closest to it when measured by that distance calculation then it combines those datapoints in some way (an average might work for linear calculationsfor our classification problemwe'll use the mode)and returns the result