00:04Welcome to the artificial intelligence tutorial
00:06My name is Richard Kirschner, and I'm with the Simplilearn team
00:09That's www.simplilearn.com
00:17Get certified and get ahead
00:24 What's in it for you today? We will discuss what artificial intelligence is, start with a general concept, explore the four main types of artificial intelligence, cover ways of achieving artificial intelligence, and look at some general applications of artificial intelligence in today's world
00:32 Finally, we'll dive into a use case predicting whether a person has diabetes or not, using TensorFlow in the Python environment
00:39 What is artificial intelligence and why is today's world probably one of the most exciting periods for this advancement? Experiencing as humans, so what is artificial intelligence? And here we have a robot with nice little clampy hands
00:54Hey, what am I? You are what we call artificial intelligence
00:56I am your creator, reminding him who programmed him and who he's supposed to take care of
01:03Artificial intelligence is a branch of computer science dedicated to creating intelligent machines that work and react like humans
01:10In today's state with artificial intelligence, I really want to highlight the fact that they work and react like humans because that is where the development of artificial intelligence is, and that's what we're comparing it to—how it looks like next to a human
01:16Thanks
01:23Any tasks you want me to do for you? Get me a cup of
01:26Here's a cup of coffee
01:30Poof, here you go
01:32He brings him a cup of coffee
01:34That's my kind of robot—I love my coffee in the morning
01:36You'll see there's a bit of a side theme of coffee in today's tutorial
01:37So here we have a robot that's able to bring him a cup of coffee; it seems pretty far out there, you know, that we have a walking robot doing this, but it's not as far out as you might think
01:47We have automatic coffee pots; we have devices that can move an object from one point to another
01:51You know, anything from Amazon delivering packages to whatever you want
01:55All these things are in today's world
01:57We're right on the edge of all this, and that's what makes this so exciting—such an exciting topic and a fascinating area of study
02:03So, let's take a look—a general overview of the types of..
02:06Artificial intelligence in the really big picture
02:10I mean, we drill into it, there's like machine learning and all kinds of different aspects, but just a generic level of artificial intelligence
02:16So hi there, I discovered four different types
02:19Come have a look
02:22So we have our kind of Einstein-looking guy or professor at some college
02:25The very first type that we're really focusing on is called reactive machines
02:31They've been around a long time
02:33This kind of AI is purely reactive and does not hold the ability to form memories or use past experiences to make decisions
02:40These machines are designed to do specific jobs
02:42Remember I talked about the programmable coffee maker that makes coffee in the morning? It doesn't remember yesterday from..
02:49Tomorrow, it runs its program
02:50Even going back to our washing machines, they have automatic load balancers that have been around for decades
02:57So, reactive machines— we program them to do certain tasks, and they have no memory, but they're very functional
03:02Then we have limited memory; this is kind of where we're at right now
03:10This kind of AI uses past experience and the present data to make a decision
03:14Self-driving cars are a kind of limited memory AI
03:16We bring up self-driving cars because that's a big thing, especially in today's market
03:21They have all these images and videos of what has happened before, and they use that to teach the autonomous car what to do
03:29So, it's based on limited memory
03:35Limited memory means it's not..
03:41Evolving new ideas, they have to actually, when they need to make a change, they have the programming built on the memory, but then they have to make those changes outside of that and put the new setup in there, so it's continually reprogramming itself
03:47 The theory of mind—these AI machines can socialize and understand human emotions
03:48Machines with such abilities are yet to be developed
03:54Of course, that's under debate
03:56There are many efforts working on the theory of mind, enabling AI to cognitively understand somebody based on the environment, facial features, and all kinds of other cues, and to evolve with them so they have some kind of reflective ability to develop and adapt over time
04:03 And finally, self-awareness
04:09This is the future of AI
04:16These machines will be super intelligent, sentient, and conscious, so they'll be able to react very much like a human being, although they'll have their own flavor
04:23I'm sure achieving artificial intelligence, so how in today's world right now are we going to achieve artificial intelligence? Well, the main arena right now is machine learning
04:33Machine learning provides artificial intelligence with the ability to learn
04:38This is achieved by using algorithms to discover patterns and generate insights from the data they are exposed to
04:44And here we have a computer; as we get more and more into the human realm of artificial intelligence, you see this guy splits in two and he's inside his hidden networks
04:53Machine learning programs, deep learning, which is a subcategory of machine learning, provide artificial intelligence the ability to mimic a human brain's neural network
05:04It can make sense of patterns, noise, and sources of confusion in the data
05:09Let's try to segregate different kinds of photos using deep learning
05:14First, we have our pile of photographs, much more organized than my boxes in my closet of photographs
05:18The machine goes through the features of every photo to distinguish them
05:22This is called feature extraction
05:24Bingo! It figures out the different features in the photos, and based on those different features, it labels the photos
05:31It says these are landscapes, these are portraits, and these are others
05:35Separates them in there
05:39If you've ever been on Google Photos, a favorite of mine, I go through there and I type in "dog," and I get all the images of my dog
05:43It's pretty amazing how it's able to pull those features out
05:47So, when we're achieving artificial intelligence and deep learning, let's take a closer look and see just how deep learning works
05:52There are a lot of models out there; this is the most basic model used, a neural network
05:58There are three main layers in a neural network
06:03The photos that we want to segregate go into the input layer, and so we have a picture of Mona Lisa, it looks like, along with a couple of other people
06:09When it goes into the first input layer, the arrows are drawn to like individual dots—each one of those white dots in the
06:14A yellow layer or in the input layer would be a pixel in the picture, maybe a value for that pixel
06:20So, the picture of the mountains goes in there, and it fills in that whole input layer
06:25Then, the next picture of the nightscape goes in there
06:30The hidden layers are responsible for all the mathematical computations or feature extraction on our inputs
06:33 So, when you see here, we have the two kind of orangish-red layers, and there are all these lines in there
06:39Those lines are the weights; each one of those represents usually a float number or a decimal number
06:46Then, it multiplies it by the value in the input layer
06:52You'll see that as it adds all these up, in the hidden layer, each one of those dots then has a value
06:56Based on the sum of the weights, and then it takes those and puts them into another hidden layer
07:03You might ask, why do we have multiple hidden layers? Well, the hidden layers function as different alternatives to some degree
07:08So, the more hidden layers you have, the more complex the data that goes in, and what they can produce coming out
07:16The accuracy of the predicted output generally depends on the number of hidden layers we have
07:20So, there we go, the accuracy is based on how many hidden layers we have, and again, it has to do with how complex the data is going in
07:28The output layer gives us the segregated photos, so once it adds up all these weights— and you'll see, there are weights also going into the output layer based on those weights
07:32It'll say yes, it's a portrait
07:36No, it's a portrait
07:38Yes, it's a landscape
07:40No, it's a landscape
07:42And that's how we get our setup in there
07:44So now we were able to label our photos
07:46Let's take a look and see what that looks like in another domain
07:49We have the photograph domain
07:52Now let's look at it in the airline ticket domain
07:54So, let's predict the airline ticket prices using machine learning
07:56These are the factors based on which we're going to make the predictions, and choosing your factors is so important
08:03But right here, we'll just go ahead and take a look at what we got
08:07We have airlines, we have the origin airport, the destination airport, the departure date
08:10Here are some historical data of ticket prices to train the machine, so we pull in the old data
08:17Here's the refined text: It's what has happened over the years
08:22Now that our machine is trained, let's give it new data, for which it will predict the prices
08:24And if you remember, from our four different kinds of machines, we have machines with memory
08:27Well, this is the memory part: it remembers all the old data and then compares what you input to produce the new data, predicting the new prices
08:35The price is $1,000—that's an expensive flight, of course, if that's in U.S
08:39dollars
08:43If it's in India, I don't know what the price range is on that; hopefully, it's a good deal for wherever you're going
08:48So, we predict the prices, and this is kind of nice because if you're looking way ahead, it would be helpful to know if you're planning a trip for next year how much those tickets are going to cost
08:55They certainly fluctuate a lot, so let's take a look at the applications of artificial intelligence
08:59We're going to dive a little deeper because we talked about photos; we've talked about airline ticket prices, which are very specific, like getting one particular number
09:10But let's look at some more things that are probably more common in homes right now
09:15Speaking of home, this young gentleman is entering his room
09:19Of course, he makes a comment like we all do when we walk into a room
09:24This room is dark, isn't it? Let's see what happens when I enter
09:25The sensors in my room detect my presence and switch on the lights
09:30This is an example of non-memory machines
09:32You know, it senses you, but it doesn't have a memory of whether you've gone in or not
09:39The new models start running a prediction as to whether you're in the room or not when you show up, and when you don't, so they turn things on before you come down the stairs in the morning, especially if you're trying to save energy
09:48You might have one of those fancy thermostats which starts guessing when you get up in the morning, so it doesn't start the heater until it knows you're going to get up
09:58So here he comes in here, and this is one of the examples of a smart machine, and that is one of the many applications of artificial intelligence, one of the things we're developing here in our homes
10:06Okay, bye
10:07Abruptly, he leaves, leaving his nice steaming cup of coffee there on the table, and when he leaves, the sensors detect he's gone and turn off the..
10:16Lights, let's watch some TV
10:18Did someone say TV? The sound sensors on the TV detect my voice and turn on the TV
10:24Sounds kind of strange, but with the Google Chromecast and a Google Home Mini, you can actually do just that
10:29You can ask it to play a movie downstairs on your downstairs TV
10:33True
10:37Also, with the Amazon Fire TV Stick and all the different artificial intelligence home appliances that are coming out, it's pretty amazing
10:41A time to be alive and in this industry
10:43Here, you have one more application of artificial intelligence, and you can probably think of dozens of others that are right now on the cutting edge of development
10:52So, let's jump into my favorite part, which is a use case: predicting if a person has diabetes
10:58And in the medical domain, I mean, if you… Read any of these; they say a predictive model indicates a person has diabetes
11:05But in the medical domain, we would want to restate this as: what is the risk? Is a person at high risk of diabetes? Should it just be something on their radar to be looking out for? And we'll be helping out with that use case
11:16There we are with a cup of coffee again; I forgot to shave, as you can see
11:20We'll start with the problem statement
11:22The problem statement is to predict if a person has diabetes or not
11:26We might start with this prediction statement, but if you were actually using this in a real case, again, you would say their higher risk of diabetes, which would be the proper way to present that to someone if you ran their test data through here
11:37But that's very domain-specific
11:39Outside of the problem statement, as far as the computer programmers involved, we have a look at the features
11:45These are the things that have been recorded, and they already have this data from the hospitals
11:49One of them would be the number of times pregnant; obviously, if you're a guy, that would be zero
11:52Glucose concentration—so these are people who’ve had their glucose measured
11:56Blood pressure, age—age is a big factor, an easy thing to look at
12:00Insulin level—so if someone's on insulin, they probably have diabetes; otherwise, they wouldn't be taking insulin, but that would affect everything else
12:08And we add that in there if they're using insulin
12:11Let's start off with the code
12:13So we're going to start by importing parts of our..
12:14Data set, and if we're going to do this, let's jump into one of our favorite tools
12:21We're going to use the Anaconda Jupyter Notebook, so let me flip over there, and we'll talk just briefly about that, then we'll look over this code
12:28 Here we are in the Jupyter Notebook, and this is an inline editor, which is just really cool for messing with Python on the fly
12:36You can do demos in it, it's very visual, you can add pieces of code with cells, so you can run each cell individually
12:44You can delete them, but you can also set the cell to be a comment, so that instead of running it, it just skips over it
12:50There are all kinds of cool things you can do with Jupyter Notebook
12:54We're not going to go into all of that; we're actually going to work with TensorFlow, and you do have..
12:58To import all the different modules in your Python
12:59Now, if you're in a different Python IDE, that's fine; it'll work in just about any of your Python IDEs
13:04I'll point out the one difference in code when we get to that, which is the inline for doing our graph
13:10In this code we're going to go through, we're going to load our data, explore it, label it, and then we'll use TensorFlow
13:16Then we'll get to the end, where we're going to take a look at how good the model is—does it work? So, let's start with the top part here, and let me go ahead and paste that code in
13:28I've added a line in at the top, specifying the folder because I didn't put it in the same folder as the program that's running
13:33You don't..
13:35You don't need to worry too much about that, but if you have a folder issue or it says the file doesn't exist, you probably have it in the wrong folder or you need to add the folder path
13:43Then, we're going to import pandas
13:44And let me just highlight one of the cool things—since it's in Google Chrome, we can just do Control plus to zoom right in there
13:50We have the import pandas as pd, so go ahead and draw a line of code there
13:55You can see that the pandas as pd adds a little annotation to make it easier to see
14:00pandas is a data analysis package; it's a really nice library you can add to your Python projects
14:04Usually, it's imported as pandas as pd—that's very common to see
14:09Let's circle that; it's basically like an Excel spreadsheet, adding columns, headers, and a lot more
14:13Functionality to look at your data, and the first thing we're going to do with that is we're going to come down here and we're going to read
14:23This is a CSV file; you can open up the file on your computer if you want
14:27If you need access to the file, you can either search for it and download it from the main site or type a note down below on the YouTube video
14:33Simply Learn will help you get that file as well, and that's true of any questions you have on this
14:39You can add comments down there, and somebody at Simply Learn actually keeps an eye on that, and we'll try to answer those questions for you
14:46I put in the full path, but you don't have to if you have your data files saved in the same folder you're running your program from
14:49And this is just a CSV
14:53Using comma-separated variables with pandas, we can read the data into a variable called diabetes
14:57Then, we can view the data by typing diabetes.head
14:59This is a pandas command, and it's really useful because it displays the data for us
15:08Let me go ahead and erase that
15:10To run the script in this cell of our Jupyter Notebook, we click the run button above
15:12You can see that with diabetes.head, since it's a pandas DataFrame, it prints everything out nicely and neatly for us
15:17This is really great
15:22If I press Control + Minus, I can fit the entire output on the same screen
15:28The first five lines are shown when you use the head method on the data, and it just displays the information
15:34First five lines in programming, of course, we start with zero, so we have zero, one, two, three, and four
15:37There we go, we have—yeah, here we go—we start with zero, and we have zero, one, two, three, and four
15:42We have our titles going across the top, and of course, the first column is the number of pregnancies, glucose concentration, and the second one is blood pressure measurements of the triceps
15:51As we keep going, you'll see you can guess what most of these things are
15:56The group—I’m not sure if this is probably the test group—I didn’t look it up to see specifically what that is
16:03Anytime you start exploring data, and for this example, we don't really need to get too much into detail
16:06You want to know the domain—what does this information mean? Are we duplicating information? In that's beyond the scope of this for right now, though, we're just going to look at this data and we're going to take apart the different pieces of this data, so let's jump in there and take a look at what the next set of code is
16:24So, in our next setup or our next step, we have to start looking at cleaning the data, we have to start looking at these different columns and how are we going to bring them in, which columns are what
16:34I'm going to jump ahead a little bit, and also, as we look at the columns, we're going to do our import: import tensorflow as tf
16:40That's a common import; that's our TensorFlow model
16:42TensorFlow was developed by Google, and then they put it into open source so that it's free for everybody to use, which is always a nice thing
16:47So, let's take
16:51Let's look at what these two steps look like in our Jupyter Notebook
16:55So, let's paste this code in here
16:57This is something that happens when you're working with data—you'll repeat yourself numerous times
17:01We already have the variable `diabetes_head`, so I'm going to put a pound sign, which tells Python that this is just a comment; we're not going to run it a second time
17:12 In here, we have `diabetes.columns`, and then `diabetes.columns_to_norm` equals `diabetes.columns_to_norm.apply(lambda x)`
17:13Let's talk about that, but let me first run it and see what the output is
17:20 Then, we'll add the next set of code and run that as well
17:25I'll just hit the run button
17:30It might not produce an immediate output, but we have accomplished a lot of processing
17:32Let's go over what we did here
17:35I've turned on my drawing tool to help illustrate everything
17:37There's a lot going on here
17:39The first thing is we have all of our columns displayed at the top—let me just highlight that and draw a circle around it, like we did earlier
17:47We want to focus on specific columns, so I'm going to change the color to make it stand out
17:53I'll use blue
17:55We're going to look at these columns, but not at age, class, or group—they'll be addressed differently, and I'll explain that in a moment
18:08So, we're looking at the number of pregnancies, glucose, and basically any variable that can be read as a floating-point number
18:13You might say age could be included as well, but..
18:17Read as a float number
18:19We're going to address that differently because when you're doing statistics, we usually take the ages and group them into buckets, and we'll talk about that
18:25So, we're going to take these columns and normalize them, which is called normalization
18:30What is normalization? If you're using the Scikit-learn module, one of their neural network tools, they call it scaling or scalar
18:38This is true for all neural networks
18:41What happens is, if I have two pieces of data, and let's say one of them ranges from zero to six, and the other is an insulin level that ranges from zero to maybe 0.2, which is a very high level—I don't know the actual limits—they will go into the neural network, and it will process these ranges
19:02As you get into zero six, here's an eight, even a higher number, it will weigh those heavier and so it'll skew the results more based on the number of pregnancies than based on the insulin or blood pressure
19:12So, we want to level the playing field; we want these values to all be in the same range
19:19We do that by normalizing it here, and we use a lambda function
19:24This is always a kind of fun thing
19:26We take the diabetes dataset, which is a pandas DataFrame, and let me just erase all that so we can go down here, set it back to red
19:30We take our diabetes dataset, which is a pandas DataFrame, and we only want to look at the columns to normalize because that's what we built— a list of those columns—and we're going to apply a lambda function
19:42And you'll see lambda and all
19:45In Python programming, this just means it's a function where we put in x, and whatever is outside of the x here, it then takes that and returns that value
19:53So, the new value is going to be whatever x is minus x min
19:59Again, it's a pandas dataset, so we can handle that easily, which is really cool and makes it easy to read
20:06 So, we take x, look for the minimum value of x, and then divide that by the maximum value of x minus x min, or the width
20:12What this essentially does is, if you're going from 0 to 15, it will divide by 15
20:17Then, we subtract it
20:20Let’s make this 20 instead of 0, or 20 to 115
20:25There we go
20:27 First off, we set this to zero, so we subtract x min
20:31Right off the bat, the minimal value is going to be zero, and then we divide it by the difference here, which is x max minus x min
20:37Minus x max or x max minus x min
20:40This basically sets all the values between zero and one, and that's very important if we want to make sure that there's no skew in the results, and that it's not going to weight the values more in one direction or the other
20:54Zero to one—that's what this is doing
20:55Again, there are many different ways to scale our data; this is the most basic scale, which is standard scaling, and it's the most common
21:01We spelled it out in the lambda
21:02There are actual modules that do that, but lambda is just such an easy thing to use, and you can see really what we're doing here
21:10So now we’ve taken these columns, scaled them all, and changed them to a zero-to-one value
21:14We now need to let the program know the..
21:17TensorFlow model that we're going to create needs to know what these things are, so to do that I create a variable called number_pregnancy
21:25Keep it simple, and we've imported TensorFlow as tf
21:27One line of code brings our TensorFlow in for us
21:29Awesome, love Python
21:32So, you get number_of_pregnancies in tf.feature_column.numeric_column
21:34We're going to tell it that it's a numeric column so it knows that this is a float value, zero to one, and then number_pregnant
21:47So, we're taking that column and reshaping it from zero to one
21:48No, that doesn't mean you have a 0.1 pregnancy; it just means 0.1 equals one or something
21:51Number_pregnant
21:54So, we're just mapping this data so TensorFlow knows what to do
21:58With it, and we go through all of these, we go through all the way up to, again, we're not doing age
22:04Let me just separate age down here
22:06These have all been adjusted; age we're going to handle differently
22:07We still put it as a numerical column because it is, so let me just circle age and group
22:15We didn't even touch group yet; we're going to look at group and age, and we're going to do some special stuff with that class
22:21We're going to look at the last because this is whether they have diabetes or not—that's what we're testing for
22:26So, this is our history; we know these people have diabetes or not, and we want to find out
22:31We want to create a model, and then we want to test that model by predicting whether someone new has diabetes or not
22:36So, here I am still with my cup
22:38Refill number three, let's explore both the categorical group, which is going to be the B, C, and D at the end, and also the age
22:46We're going to talk about those a little bit more, and then we're going to combine all those features
22:52We'll jump into splitting the data, although that's kind of the next step, but we'll put it all together
23:00What are we doing with the age and what are we doing with the group down there? So, let's flip on over and take a look at our Jupyter Notebook
23:07The first thing is, let's put this new set of code in here and run it, and let's talk about what we're doing on this set of code
23:16I actually want to go one more step forward on the next set of code or part of it
23:20There we go, and I can go and just run that
23:22While we have it, that's fine
23:25Let's just scroll up a little bit here, and let's go through what we just did with this set of code
23:27If we go back up here to the top part, we have group B, C, B, B, C, we learned from the header
23:33So, when I come down here, we're going to create a signed group
23:35And let me get my drawing pad out
23:39 So, we're looking at this first one up here: assigned group, TF feature column, categorical column with vocabulary list
23:43That is a mouthful
23:45This is saying that this is a categorical list
23:47In this case, we have A, B, C, D
23:52You see this a lot in TensorFlow
23:56A lot of times, TensorFlow is used to analyze text or logs, error logs, and they're just full of all this information
24:00They take these—in this case, A, B, C, D—but in other cases, they'd be words, and they create..
24:05Numbers out of them, so it has 0
24:10This is one column, this is another column, this is another column, and it's just this way of being able to look at this in a different light and assigning them different values
24:19You really don't want to assign this a float value
24:21First thought might be, let's assign this 0, 1, 2, 3 for A, B, C, D
24:26But if you did that, it would try to add 1 plus 2 to get 3 as part of its math and functions, and that just isn't true
24:34C does not equal A plus B
24:37C is just a categorical name
24:40It could have been the Frank group and Laura's group in a BIDS group, but it's not
24:43These are not float numbers, so it's very important to have that distinction in your data
24:47The next step we're looking at is our map plot, and we're..
24:52We're going to do this
24:54This is a cool, useful tool
24:55We're going to import matplotlib.pyplot as plt
24:57That's a standard import, and this next line here is really important
25:02We're doing the matplotlib library, and we want it to be inline
25:08That's because we're in a Jupyter Notebook
25:13Remember I told you before that if you're running this in a different IDE, you might get a different result
25:18This is the line you need if you want to see the graph on this page
25:23And then we do diabetes; we're going to look at just the age and plot a histogram with bins equals 20
25:28What the heck is that? Well, it turns out that because this is, remember, pandas—our pd pandas as pd—because this is a pandas DataFrame, pandas automatically knows to look for the matplotlib library, and a histogram just means..
25:33It's going to be a histogram, and we're going to separate it into 20 bins, and that's what this graph is here
25:40So, when I take the diabetes data and do a histogram of it, it produces this really nice graph
25:46We can see that at age 22, most of the participants—in this case, probably around 174 of the people recorded—are in this age bracket, which is represented in this first column here
25:54As you look further down, the number of participants decreases gradually until age 80
26:01Down here, you can see that there are almost none in a couple of these categories
26:07This is important to know because, when you're doing census data analysis, the older the age group, the more likely it is that many people have passed away
26:13You will observe this pattern in any of your datasets
26:18Senses, as you take, you're always going to have a much larger group in the younger crowd, and then it gets lower and lower as they get older
26:24I mentioned the word buckets; here we go
26:25We're going to create an age bucket
26:28We're going to put people in buckets
26:30Can you imagine people sitting in buckets? Kind of a funny way of looking at it
26:32This just makes it easier for us to separate them
26:34When I go to the doctor's office, I don't want to be told, "Well, your age is 22
26:37This is," you know, you'll get a decent one at 22
26:41Here we are, back to my cup of coffee
26:44I told you coffee was an underlying theme
26:47These next couple of steps are very specific to TensorFlow
26:50Up until now, we had some TensorFlow setup as we set the categories up, but you'd have to set that up with any model you..
26:57Use to make sure they're set correctly, they'd be set up a little differently, but we run input functions, and in TensorFlow, this allows for some really cool things to happen
27:06This is why TensorFlow is so predominant in many areas
27:07So, let's take a look at these next couple of lines of code here
27:14We're going to create the input function, and we're going to go ahead and create the model
27:18Let me go ahead and put these codes in here
27:20I went ahead and split them up so they're on different lines, so we can talk a little bit about that, and then the actual model
27:28Let me go ahead and run this so we can see what it looks like
27:29In my particular environment, it just prints out a little bit of information about the model
27:33Not too worried about looking at it
27:36But we do want to take a closer look at what we did here
27:39So, we've created an input function, and again, this is very specific to TensorFlow
27:43With the input function, we have our train, we have our x equals x_train, and our y equals y_train, because we want to train it with particular data
27:51But we have these other settings in here, these two settings, and the number of epochs is how many times it's going to go over our training data
28:00Epoch means a full pass over the entire dataset, so we're going to go over it a thousand times
28:05That's actually a huge overkill for this amount of data; usually, it only needs probably about 200
28:08But, you know, when we're putting it together and trying things out, you just kind of throw the numbers in there
28:14Then you go back and fine-tune it
28:16Sometimes, the batch size is really important
28:17This is where TensorFlow does some really cool things
28:19If you're processing this over a huge amount of data and you try to batch everything at once, you end up with a problem
28:26This means we're only going to read 10 lines at a time through our data, so each one of those rows of testing they've done, we're only going to look at 10 of them at a time and put that through our model and train it
28:37Then, shuffle — self-explanatory — we're just moving, we're just randomly selecting which data and what order we go in
28:40That way, if there are like five in a row that are kind of weighted one way and vice versa, it mixes them up
28:47And then finally, we create our model, so the..
28:49The model goes in there and goes, okay, I have a tf.estimator.LinearClassifier
28:52We're going to put in the feature columns equals feature columns, which we defined all our columns above
28:57Then we have num_classes equal to 2, which just means our output result is zero or one—you have diabetes or you don't have diabetes, or, in this case, we actually call it high risk of diabetes
29:08Then I added one more line of code there, which I forgot: we've set up our model and our feature columns
29:15Now, we need to actually train it
29:17model.train, you'll see this so common in many different neural network models; this is like a standard
29:21What's different, though, is that we have to feed it the input function
29:28Remember, we created this function with all this..
29:31Information on it, and then we have steps, similar to the number of batches and batch size
29:34It's more like individual lines
29:36We step through
29:38A thousand is a lot more common for steps than epochs, but steps are used
29:44You probably leave this out in this particular example
29:47Let's go ahead and run this all together, because it has a site
29:49When we start training, we get a different output
29:53So, here we go
29:58I've run it; it’s given me the information from when I created the model, and now it just starts going through, and we get this information: tensor loss, equals global step, and all kinds of stuff going on here
30:03If you're following this, it's just going through the steps and training it
30:07It gives you information—you could dig deep into here
30:09But for this particular setup, we're not going to go too deep into what's going on; just know that we've trained our model
30:17This model now has the information we need in it to start running predictions
30:21So, as we sip our next — maybe a coffee, or perhaps tea, or if you're one of those strange late-night workers, maybe a sip of wine — we go into the next step
30:29We actually want to run some predictions on here, but we don't want to run the training again; we want to run the test on it
30:38We want to take our test data and see what it did
30:40So, that's what we're going to do next — we're going to run the test through and actually get some answers
30:44If you were actually deploying the model, you would pull the answers out of the data it's bringing back
30:48Let's back up and take a look at that in our Jupyter notebook
30:52So here we go, let's paste it in there
30:53I'm going to go ahead and run it, and you'll see that as it executes, it's actually outputting the answers
30:57If you remember correctly, we'll walk through this here in just a second, but it goes through and runs each line, giving you a prediction for each line one at a time and printing them out
31:06So, let's take a look and see what that actually looks like
31:09 Let's start with this first part
31:12We've created another function; this is just like the previous function, except that x equals x_test, and there's no y
31:14Why is there no y? Because we don't know what the answer is on this yet
31:18We don't want to tell it the answer; we want it to guess what the answer is, so we can..
31:27Evaluate that and see how well it did on that 33 percent of the data
31:29So, this is our X test batch size, which is 10 again
31:34If we were watching this roll down here, we would see that it actually processes 10 lines at a time
31:38It will only go through once; it goes through all the X test data one time
31:42We don't need it to predict multiple times, and shuffle=False is very important
31:46We set shuffle to false because if we were tracking this and actually giving people answers, we want to make sure it connects to the right person so they get the correct results
31:56Of course, we're just doing this to evaluate it
31:58So, let's take a look down here at what I output, and as I scroll down to my Jupyter Notebook, we have some information regarding TensorFlow
32:04Running, and then the actual output, and if we look at the output, we know by this first bracket in Python it's an array
32:10We know by this squiggly bracket that this is a dictionary, so that this is a label
32:14The dictionary has logistic probabilities, class IDs, classes, and so this whole first part—let me redo that—this whole first part is one output, and we know that because there is the bracket there and this bracket here for the dictionary
32:30It's a dictionary of terms, so if I pulled this out and looked at object 0 in here, I would go down to—and let me just find it here—there it is, classes
32:42Remember how we define classes? We define classes as our answers
32:46And so, it's guessing, and our TensorFlow says, based on all the information you gave me, I'm..
32:51Guessing, this first entry of our initial test data indicates high risk of diabetes
32:54Uh oh, go get tested, change your diet, watch what you're eating
32:58You know, high risk one
32:59And if we go down far enough, we can see down here is another one where the class equals zero
33:06I skipped a couple because they're all ones up here
33:08The B, this particular output B in front of the one, means it's a binary output; it only comes out as zero or one
33:15There’s a lot of other information in here; you can dig deep into TensorFlow and explain these different numbers
33:21That’s way beyond the scope of what we're working on today
33:24So, the basics of it, though, is you get an output, and we have an output of whether the person has diabetes or not
33:32Well, in this case, it’s high risk of diabetes or not
33:33So now that we've run our predictions, take a sip of coffee, have a little short break, and we say, "Well, what do we need to do?" We need to know how good our predictions were; we need to evaluate our model
33:43So, if you're going to publish this to a company or something like that, they want to know how well you performed
33:48Let's take a look at what that looks like in the code
33:50So, let's paste that in here and just quickly go over this again
33:53By now, this function should look very similar
33:55This is the one we're going to call the eval_input_fn
33:56It should be pretty straightforward
33:59Here, we have our TensorFlow estimator input function, pandas input function, and then we have our X_test and Y_test, because this time we want to give it the answers so it can see how well it did on a batch size of 10
34:12Processing 10 at a time, we're only going once through the data; we're not shuffling it, although it doesn't really matter with this
34:20Then we're going to do results equals model.evaluate, and we put our evaluation function in there
34:24This should all look familiar because we're repeating the same thing; it's very similar with a couple of different changes as far as what we're feeding it and the fact that we're doing an evaluation
34:36Let's see what that looks like when we run it
34:38Up here in our Run Model, you'll see warnings on some of these because I didn't install this separately, so a lot of it is just temporary files because I'm using the Jupyter Notebook instead of setting it up on a regular machine, and we get our..
34:50Output, and we'll go ahead and just look at this output real quick, and then we'll flip over
34:53From here, you'll see that it generates an accuracy, a baseline, average loss, the mean, which gives you a precision prediction
34:58It provides all kinds of information here, so let's flip over and see what's important
35:02We'll look at the slide
35:06Here we are in this slide, and this should be exciting because we just about wrapped up our whole TensorFlow
35:12TensorFlow is one of the more complicated models out there, so give yourself a pat on the back for getting all the way through this
35:17When we look at this output, we have an accuracy of 0.7165 — that's really what we want to look at
35:25That means we have an accuracy, if you're just truncating it, of 71%
35:26That's quite good for our model
35:30You know, given a small amount of data, we achieved 71 percent accuracy in predicting whether people are at high risk or not for diabetes
35:37So, we created a model that can predict if a person has diabetes based on previous records of individuals diagnosed with diabetes, and we've managed to reach an accuracy of 71 percent, which is quite good
35:46The model was implemented in Python using TensorFlow
35:49Again, pat yourself on the back because TensorFlow is one of the more complex frameworks out there; it's also one of the most diverse and useful
35:59So, the key takeaways today are that we've covered what artificial intelligence is, with our robot that brings us coffee, and we noted that we are comparing it
36:07To see how it reacts and looks like humans, very important to note that in today's world, where we're at, we looked at types of artificial intelligence from reactive machines to limited memory, and we also explored the future of theory of mind and self-awareness
36:21Then we examined how taking photos works and how artificial machine learning is applied
36:24We took a glance at deep learning with neural networks and how we have hidden layers in our input layer and our output layer
36:34We then looked at a use case of somebody walking into a room and activating their TV using artificial intelligence, which is part of the AI category
36:43Finally, we deepened our understanding by doing some coding in TensorFlow with Python
36:47With that, let's wrap it up
36:49I’d like to thank you for joining us today
36:51For more information, visit www.simplilearn.com
36:56Get certified, get ahead
37:00Again, if you have any questions, need verification, or want more information, please feel free to leave a note in the YouTube video comment section
37:04We look forward to hearing from you, and I wish you a wonderful day
37:11Hi there! If you like this video, subscribe to the Simplilearn YouTube channel and click here to watch similar videos
37:16Turn it up and get certified
37:23Click here.