Machine Learning in R: Airplanes vs Automobiles

In this tutorial I am going to teach you how to build your own Neural Network from scratch using your own photos and your own ideas. I will pull down 12 random images from the internet. Six of which are cars and 6 of which are planes (completely random downloaded images by the way). Since they are different sizes I will show you how to pre-process them (which is really the power of this tutorial) so they are ready for a Neural Network. When you are finished with this tutorial you will be able to build Neural Networks with ease and with your own photos.

Start for Free
First 2 tasks free. Then, decide to pay $4.99 for the rest
Machine Learning in R:  Airplanes vs Automobiles

Task List


We will cover the following tasks in 44 minutes:


Introduction

In this chapter I am going to set up what we’re going to do in this tutorial. I will show you the images we’re going to use, I’ll get you working on the Rhyme Interface and then I will tell you a little about me.


Loading Pictures

In this chapter we have to do some grunt work and create a vector which will make our lives easier down the road by creating a Vector with the images. There are quicker ways to do this but that’s ok. We will get to know each other better in this chapter. And in case you’re wondering why we’re creating this vector? Hint: For Loop


Images

I will show you how to upload the images into R using EBImage using a ‘for loop’. If you haven’t used a for-loop before just type along. I will explain what it is the for loop is doing while we go through it. If you want to learn more about it don’t stop the video. Wait until after and do a google search - you can learn the for loop in an hour.


Resizing

Since I pulled down random images all the images are of different sizes. We will need to resize them so they are standard. We will use a resize function to complete this. Easy squeezy.


Reshaping Data for Neural Network

Now we’re done with the pre-processing. From this step on we will be performing basic Neural Network protocol. In this lesson we will be using the array_reshape function which allows us to reshape a multi dimensional array, which in our case is our images.


Creating Training Set

As you are probably aware when doing a Machine Learning problem or in this case a Neural Network we need to create the model using a training set. We then test our model on a testing set to see if it does well. In our case we only have 12 images so we need to figure out how we’re going to set this up. Come on in and we’ll work through this.


Creating Test Set

In this chapter we will be build out the test set. Again since we’re only dealing with 12 images we will only have one image of an airplane and one image of a car. This will work but not ideal. Generally you will want a larger training and test set. But remember this is to show you how to do this in R from scratch.


Creating Labels and One Hot Encoding

We need to set up our labels in this chapter. We will use categorical variables; say “0 or 1”. 0 will represent an airplane and a 1 will represent a car. We do this so that we can pass the images through the network and it will know whether it’s a plane or an automobile at the end of the network.


Neural Network Framework

We will build out the Neural Network framework in this chapter. We will build out a Neural Network with one hidden layer. We will be using the most popular activation functions, Relu and Softmax. Come in and I’ll show you how this is done. And by the way, once you get familiar with this terminology building Neural Networks becomes easier. It takes a couple of models though before you get there. So be patient with yourself.


Running the Model

This is the moment of truth. We will be creating our Neural Network. Let’s get to it! We will need to run it a few times for it to catch. We could change the epochs but instead I just have you re-run it. Come in and you’ll see.


Testing Model

We are going to test the model’s accuracy in this chapter. Remember that we’re using a very small test set. But when we ran the model we saw that it did very well so it likely would do well on a larger test set as well. In any event this course is to show you how to set the problem up. You can make your models as big as you want or as small as the one we are creating today.


How does Model perform on new images?

In this chapter we’re going to test our model on images the model hasn’t seen. I happen to know that it works out pretty good. But I’ll show you how to get there. We will then do a quick overview of the journey we’ve taken and after that conclude.

Watch Preview

Preview the instructions that you will follow along in a hands on session in your browser.

Chris Shockley

About the Host (Chris Shockley)


I am a R enthusiast, hiker, and amateur astronomer. My favorite hike is located in Mt. Rainier National Park, my favorite Deep Sky Object is Alberio, and my favorite R package is dplyr (since I use it everyday). I am single too. Maybe because I spend too much time playing? I have a dog named Coog (Lllasa Apso), who would rather be outside than inside, which means I have to take him on a lot of walks. I work as a Data Analyst/Financial Analyst for a Metals Co. located in Seattle, WA. I have been in my current position for 4 years. My hope is that I can help you, even if its with my enthusiasm. Yes you can learn R and the Rhyme Interface will help you. But. You also must take what you learn and practice, practice, practice. So... Let's get after it. See you soon.



Frequently Asked Questions


In Rhyme, all sessions are completely hands on. You don't just passively watch someone else. You use the software directly while following the host's (Chris Shockley) instructions. Using the software is the only way to achieve mastery. With the "Live Guide" option, you can ask for help and get immediate response.
Nothing! Just join through your web browser. Your host (Chris Shockley) has already installed all required software and configured all data.
You can go to https://rhyme.com/for-companies, sign up for free, and follow this visual guide How to use Rhyme to create your own sessions. If you have custom needs or company-specific environment, please email us at help@rhyme.com
Absolutely. We offer Rhyme for workgroups as well larger departments and companies. Universities, academies, and bootcamps can also buy Rhyme for their settings. You can select sessions and trainings that are mission critical for you and, as well, author your own that reflect your own needs and tech environments. Please email us at help@rhyme.com
Please email us at help@rhyme.com and we'll respond to you within one business day.

First 2 tasks free. Then, decide to pay $4.99 for the rest