Machine Learning is Fun!

The world’s easiest introduction to Machine Learning

What is machine learning?

This machine learning algorithm is a black box that can be re-used for lots of different classification problems.

Two kinds of Machine Learning Algorithms

Supervised Learning

This is our “training data.”
We want to use the training data to predict the prices of other houses.
Oh no! A devious student erased the arithmetic symbols from the teacher’s answer key!

Unsupervised Learning

Even if you aren’t trying to predict an unknown number (like price), you can still do interesting things with machine learning.

That’s cool, but does being able to estimate the price of a house really count as “learning”?

Let’s write that program!

def estimate_house_sales_price(num_of_bedrooms, sqft, neighborhood):
price = 0
# In my area, the average house costs $200 per sqft
price_per_sqft = 200
if neighborhood == "hipsterton":
# but some areas cost a bit more
price_per_sqft = 400
elif neighborhood == "skid row":
# and some areas cost less
price_per_sqft = 100
# start with a base price estimate based on how big the place is
price = price_per_sqft * sqft
# now adjust our estimate based on the number of bedrooms
if num_of_bedrooms == 0:
# Studio apartments are cheap
price = price — 20000
else:
# places with more bedrooms are usually
# more valuable

price = price + (num_of_bedrooms * 1000)
return price
def estimate_house_sales_price(num_of_bedrooms, sqft, neighborhood):
price = <computer, plz do some math for me>
return price
def estimate_house_sales_price(num_of_bedrooms, sqft, neighborhood):
price = 0
# a little pinch of this
price += num_of_bedrooms * .841231951398213
# and a big pinch of that
price += sqft * 1231.1231231
# maybe a handful of this
price += neighborhood * 2.3242341421
# and finally, just a little extra salt for good measure
price += 201.23432095
return price

Step 1:

def estimate_house_sales_price(num_of_bedrooms, sqft, neighborhood):
price = 0
# a little pinch of this
price += num_of_bedrooms * 1.0
# and a big pinch of that
price += sqft * 1.0
# maybe a handful of this
price += neighborhood * 1.0
# and finally, just a little extra salt for good measure
price += 1.0
return price

Step 2:

Use your function to predict a price for each house.

Step 3:

Mind Blowage Time

What about that whole “try every number” bit in Step 3?

This is your cost function.
θ is what represents your current weights. J(θ) means the ‘cost for your current weights’.
The graph of our cost function looks like a bowl. The vertical axis represents the cost.

What else did you conveniently skip over?

Is machine learning magic?

You can only model relationships that actually exist.

How to learn more about Machine Learning

Interested in computers and machine learning. Likes to write about it.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store