Ticker

6/recent/ticker-posts

Header Ads Widget

AI In Supervised learning

Hey,Today, we’re going to try to teach JohnGreen-bot something. Hey John Green-bot! John Green-bot: “Hello humanoid friend!” Are you ready to learn? John Green-bot: “Hello humanoid friend!” As you can see, he has a lot of learning todo, which is the basic story of all artificial intelligence. But it’s also our story.


Humans aren’t born with many skills, andwe need to learn how to sort mail, land airplanes, and have friendly conversations. So computer scientists have tried to helpcomputers learn like we do, with a process called supervised learning. You ready, John Green-bot? John Green-bot: “Hello humanoid friend!” The process of learning is how anything canmake decisions, like for example humans, animals, or AI systems. They can adapt their behavior based on theirexperiences. In Crash Course AI, we’ll talk about threemain types of learning: Reinforcement Learning, Unsupervised Learning, and Supervised Learning.

Reinforcement Learning is the process of learningin an environment, through feedback from an AI’s behavior, it’s how kids learn towalk! No one tells them how, they just practice,stumble, and get better at balancing until they can put one foot in front of the other. Unsupervised Learning is the process of learning without training labels. It could also be called clustering or grouping. Sites like YouTube use unsupervised learningto find patterns in the frames of a video, and compress those frames so that videos canbe streamed to us quickly. And Supervised Learning is the process oflearning with training labels.

It’s the most widely used kind of learningwhen it comes to AI, and it’s what we’ll focus on today and in the next few videos! Supervised learning is when someone who knowsthe right answers, called a supervisor, points out mistakes during the learning process. You can think of this like when a teachercorrects a student’s math. In one kind of supervised setting, we wantan AI to consider some data, like an image of an animal, and classify it with a label,like “reptile” or “mammal.” AI needs computing power and data to learn. And that’s especially true for supervisedlearning, which needs a lot of training examples from a supervisor.

After training this hypothetical AI, it shouldbe able to correctly classify images it hasn’t seen before, like a picture of a kitten asa mammal. That’s how we know it’s learning insteadof just memorizing answers. And supervised learning is a key part of lotsof AI you interact with every day! It’s how email accounts can correctly classifya message from your boss as important, and ads as spam. It’s how Facebook tells your face apartfrom your friend’s face so that it can make tag suggestions when you upload a photo.

And it’s how your bank may decide whetheryour loan request is approved or not. Now, to initially create this kind of AI,computer scientists were loosely inspired by human brains. They were mostly interested in cells calledneurons, because our brains have billions of them.

Each neuron has three basic parts: the cellbody, the dendrites, and the axon. The axon of one neuron is separated from thedendrites of another neuron by a small gap called a synapse. And neurons talk to each other by passingelectric signals through synapses. As one neuron receives signals from otherneurons, the electric energy inside of its cell body builds up until a threshold is crossed.

Then, an electric signal shoots down the axon,and is passed to another neuron — where everything repeats. So the goal of early computer scientists wasn’tto mimic a whole brain. Their goal was to create one artificial neuronthat worked like a real one. To see how, let’s go to the Thought Bubble. In 1958, a psychologist namedFrank Rosenblatt was inspired by the Dartmouth Conference and was determined to create anartificial neuron. His goal was to teach this AI to classifyimages as “triangles” or “not-triangles” with his supervision.

That’s what makes it supervised learning! The machine he built was about the size ofa grand piano, and he called it the Perceptron. Rosenblatt wired the Perceptron to a 400 pixelcamera, which was hi-tech for the time, but is about a billion times less powerful thanthe one on the back of your modern cellphone. He would show the camera a picture of a triangleor a not-triangle, like a circle. Depending on if the camera saw ink or paperin each spot, each pixel would send a different electric signal to the Perceptron.

Then, the Perceptron would add up all thesignals that match the triangle shape. If the total charge was above its threshold,it would send an electric signal to turn on a light. That was artificial neuron speak for “yes,that’s a triangle!” But if the electric charge was too weak tohit the threshold, it wouldn’t do anything and the light wouldn’tturn on, that meant “not a triangle.” At first, the Perceptron was basically makingrandom guesses. So to train it with supervision, Rosenblattused “yes” and “no” buttons. If the Perceptron was correct, he would pushthe “yes” button and nothing would change. But if the Perceptron was wrong, he wouldpush the “no” button, which set off a chain of events that adjusted how much electricitycrossed the synapses, and adjusted the machine’s threshold levels.

So it’d be more likely to get the answercorrect next time! Thanks, Thought Bubble. Nowadays, rather than building huge machineswith switches and lights, we can use modern computers to program AI to behave like neurons. The basic concepts are pretty much the same: First, the artificial neuron receives inputsmultiplied by different weights, which correspond to the strength of each signal. In our brains, the electric signals betweenneurons are all the same size, but with computers, they can vary. The threshold is represented by a specialweight called a bias, which can be adjusted to raise or lower the neuron’s eagernessto fire. So all the inputs are multiplied by theirrespective weights, added together, and a mathematical function gets a result.

In the simplest AI systems, this functionis called a step function, which only outputs a 0 or a 1. If the sum is less than the bias, then theneuron will output a 0, which could indicate not-triangle or something else depending onthe task. But If the sum is greater than the bias, thenthe neuron will output a 1, which indicates the opposite result! An AI can be trained to make simple decisionsabout anything where you have enough data and supervised labels: triangles, junk mail,languages, movie genres, or even similar looking foods. Like donuts and bagels. Hey John Green-bot! You want to learn how to sort some disgustingbagels from delicious donuts?” John Green-bot: “Hello humanoid friend!” John Green-bot still has the talk-like-a-human program!

Remember that we don’t have generalizedAI yet… that program is pretty limited. So I need to swap this out for a perceptronprogram. Now that John Green-bot is ready to learn,we’ll measure the mass and diameter of some bagels and donuts, and supervise him so hegets better at labeling them. How about you hold on to these for me? Right now, he doesn’t know anything aboutbagels or donuts or what their masses and diameters might be. So his program is initially using random weightsfor mass, diameter, and the bias to help make a decision. But as he learns, those weights will be updated! Now, we can use different mathematical functionsto account for how close or far an AI is from the correct decision, but we’re going tokeep it simple.

John Green-bot’s perceptron program is usinga step function, so it’s an either-or choice. 0 or 1. Bagel or donut. Completely right or completely wrong. Let’s do it. This here is a mixed batch of bagels and donuts. This first item has a mass of 34 grams and a diameter of 7.8 centimeters. The perceptron takes these inputs (mass anddiameter), multiplies them by their respective weights, then adds them together. If the sum is greater than the bias — which,remember, is the threshold for the neuron firing — John Green-bot will say “bagel.” So if it helps to think of it this way, thebias is like a bagel threshold. If the sum is less than the bias, it hasn’tcrossed the bagel threshold, and John Green-bot will say “donut.” All this math can be tricky to picture.

So to visualize what’s going on, we canthink of John Green-bot’s perceptron program as a graph, with mass on one axis and diameteron the other. The weights and bias are used to calculatea line called a decision boundary on the graph, which separates bagels from donuts. And if we represent this same item as a datapoint, we’d graph it at 34 grams and 7.8 centimeters. This data point is above the decision boundary,in the bagel zone! So all this means is that when I ask JohnGreen-bot what this food is… he’ll say: John Green-bot: “Bagel!” And… he got it wrong, because this is adonut. No big deal!

With a brand new program, he’s like a babythat made a random guess! Because he’s using random weights rightnow. But we can help him learn by updating– hisweights. So we take an old weight and add a numbercalculated by an equation called the update rule. We’re going to keep this conceptual, butif you want more information about this equation, we’ve linked to a resource in the description. Now because our perceptron can only be completelyright or completely wrong, the update rule ends up being pretty simple. If John Green-bot made the right choice, likelabeling a donut as a donut, the update rule works out to be 0. So he adds 0 to the weight, and the weightstays the same. But if John Green-bot made the wrong choice,like labeling a donut as a bagel, the update rule will have a value — a small positiveor negative number. He’ll add that value to the weight, andthe weight will change.

Conceptually, this means John Green-bot learnsfrom failure but not from success. So he called this donut a bagel, and got thelabel wrong. By pressing this “no” button, I’m supervisinghis learning and letting him know he made the wrong choice. So his weights update. If we look back at the graph, we can see thatwhen the weights update, the decision boundary changes. The data point we added is now below theline, in the donut zone. Now, his perceptron will classify anotheritem with this mass and diameter as a donut! This next item [donut] has a mass of 26 gramsand a diameter of 6.1 centimeters.

What do you think, John Green-bot? John Green-bot: “Donut!” He got it right! When he took those inputs and did that samecalculation, the sum was less than the bias. That data point appeared below the decisionboundary — in the donut zone. And so I’m going to push the “yes” button. In this case, the update rule equation worksout to 0, so the weights stay the same, and so does the decision boundary. Now we’ll do this 48 more times to trainhis perceptron. After we’re done training John Green-bot’sperceptron, we have to test it on new data to see how well he learned. So I’ve got 100 new bagels and donuts forhim to classify. Woah. This is a big what? What is this? John Green Bot: “Bagel.” Alright, alright. I’m just going to write down your answer. Alright so overall, he classified 25 donutsand 75 bagels. We can visualize the results on the graphwith the decision boundary like this.

But we can also put the results in a table,called a confusion matrix, because it tells us where John Green-bot was confused. He got 8 donuts correct and 73 bagels correct. But he said that a bagel was a donut twice,and that a donut was a bagel 17 times. Using these numbers, we can calculate hisoverall accuracy by adding together what he got right, which were 8 donuts and 73 bagels,and dividing by the total 100, to get 81%. But to really understand what’s wrong, weneed to look at his precision and his recall. We can calculate these percentages for bothfoods, but we’ll focus on donuts right now.

Precision tells you how much you should trustyour program when it says it’s found something. If John Green-bot tells me something’s adonut, I’m expecting to eat a donut. I don’t want to bite into a bagel, becausethat would be a gross surprise. Of the 10 items that he said were donuts,8 were actually donuts. So he was 80% precise, and I can be 80% surehe’s only handing me donuts when he says he is. Recall tells you how much your program canfind of the thing you’re looking for. I’m really hungry, so I want as many donutsas possible. But of the 25 items that were donuts, he correctlylabeled 8 of them.

So his recall was just 32%, and he just handedme 32% of all the donuts. The precision and recall depend on the criteriaJohn Green-bot is using to make a decision: diameter and mass. And as we can see from this graph, he thinksthat donuts generally have smaller diameters and masses than bagels — they’re small,fluffy treats. So when it comes to classifying donuts, hehas high precision. Because if he says something’s a donut,we’re pretty sure it’s a donut, not a disgusting bagel. But John Green-bot has low recall, becausethis criteria didn’t account for the fact that some donuts can be way bigger than the donuts we used to train his perceptron. They have a bigger diameter and mass, andthey fall in the current “bagel zone,” so he missed a lot of donuts when he was classifying. Thanks John Green Bot. Figuring out what criteria to use is the keyto most AI challenges.

If we wanted better accuracy for this donut-bagelproblem, maybe we should of used inputs besides mass and diameter, like checking for seedsor sprinkles. Generally, more inputs are better for accuracy,but the AI will need more processing power and time to make decisions. An ideal AI system would be small, powerful,and have perfect precision and perfect recall. But in the real world, mistakes happen, sowe have to prioritize based on our goals. The AI filtering our inboxesneeds to make sure we get all the important emails, so it needs high recall. But it’s okay if it isn’t very precise,because we can deal with some spam getting through and don’t need only good emails. Most AIs handle more complicated problemsthan sorting something into one of two categories, though. The world isn’t all donuts and bagels. So to answer more complicated questions, weneed more complicated AI.

Post a comment

0 Comments