home machine learning project : identifying cutlery items

home machine learning project : identifying cutlery items

machine learning is becoming crucial to add to your backpack. this post attempts to show a basic application of machine learning. we need to determine whether some cutlery items are bowls or mugs or plates. this is a practical demonstration of applied theory

machine learning is just applied maths

from start to finish, machine learning is just statistics, equations, calculations and repetitions. you just code an algorithm. tensors are just big words for matrices.

the project

we are identifying items from my kitchen so that when presented with an unidentified cutlery, we can attempt to classify it

characteristics of our target

we will be identifying plates, mugs and bowls. here is an overview of their common characteristics

target data
target data

our collected data

here is our measurement sheet, it could have been a spreadsheet. heights in cm

data sheet
our data

we reformat it into cutlery.csv as follows :

reformatting for calculations : plotting

let us plot our data :

cutlery Jupyter

now to select the entire D column we do :

outputs :

same for df[‘h’]

viewing our data

please see this article on annotating data

code :

output :

machine learning intro view
view data

our sample

now let us say that we have this :

width D : 8 and h : 7.5

cup from kitchen
cup from kitchen

without seeing the image, having D:9 and h:14, how do we guess what type of cutlery it is?

guess by distance

since this is but points on graph, we’ll measure the distance between D:9 and h:14 i.e. (9,14) to each point

we’ll use the simple distance formula :

distance = square_root(  ( X2-X1)^2  +  (Y2-Y1)^2 )

code :

output :

distance to target
distance to target

we’ll see that the distance is nearest to all mug samples i.e. from 1.5 to 4 than it is to the nearest bowl (dist:6.02) or plate (dist:15.89)

so we can say that it is a mug / cup

of course, since we are only calculating dist, we can tweak our code to do everything without graphs

another sample

consider the following cup with D:9 and h:14

mug sample
mug sample

we set our target to

and our output is :

sample two from kitchen
sample two graph

machine learning concept applied

this is a k-nearest neighbour application which is labelled under classification aka the basic of machine learning.

learning type: supervised learning

this was a demo project normally much more data has to be collected !

about the title

i wanted to put up something that would not scare beginners off. my first title was :

identifying home cutlery items with a k-nearest neighbours inspired method 

but no uninitiated would probably want to click on the link!

Lives in Mauritius, cruising python waters for now.