Alexis
Hi everyone. Welcome to Talk Tech with Data Dave. I am Alexis, your host of this podcast, and I’m here today, as always, with my dear friend, Data Dave. Hey Dave, how are you?
Data Dave
I’m very well, Alexis. How are you? Glad to be here.
Alexis
Yeah, it’s mid-summer for us right now. We are in conference season. We’ve got all kinds of fun things to talk about. But before we talk about our question today, I do want to remind our listeners that you can always submit a question to us at talktech@d3clarity.com or right on the D3Clarity website. We love to answer your questions about all things data, all things cloud, all things technology, all things AI, all things D3Clarity right here on the podcast.
So Dave, let me ask you this question.
How does AI learn and make decisions? We have talked about AI and machine learning quite a bit in our last few podcasts, but I want to go back to kind of the core here. How does AI make decisions? How does it learn? Because I know it does, but I don’t really get the concept of how it gets to the point.
Data Dave
Okay, so, interesting question, Alexis. That’s a very interesting question. I’m not sure a lot of people completely understand it.
Alexis
I know I don’t. So, I’m excited to hear your answer.
Data Dave
Let’s go back to a little bit of basics. We’re not going to go deeply into very modern AI. Let’s go back to very basics of a couple of fundamental technologies that are used in AI and certainly talk about more and go through this. One is a decision tree, and one is a neural network.
So, you’ve heard both of those terms before.
Alexis
Yes, we’ve definitely talked about both of those before on the pod, even here.
Data Dave
So a decision tree is a series of decisions in a tree, which allows you to lead to an ultimate decision. So, based off of these two inputs, I’m going to decide, is this green or blue? Is it green? If it’s green, maybe it’s a leaf- kind of decision tree down that path.
Alexis
Okay.
Data Dave
In coding, we often make decision trees naturally because a set of inputs leads to a set of outputs. We define the decisions, and we work through that as a logical progression to.
Alexis
Let’s simplify down to kind of Alexis basic excel level. Because my brain’s on excel right now. An IF/THEN function, right?
Data Dave
Exactly.
Alexis
If the number is between 91 and 100, then it’s an A. If it’s between 80 and 90, it’s a B, so on and so forth.
Data Dave
So, it’s this decision tree that says, “If you scored this, then it’s that.” And if you build those up into a tree structure where you say,”Iif I make that decision, then this is the next right decision to make, etc. Etc.” So, you build up this tree of decisions.
That’s a decision tree, and it’s a logical representation. You can build one, you can naturally work with them. With machine learning, what we do is we compute the decision tree. So, we feed it all the inputs, and then we feed it all the outputs, and we let it decide what set of decisions it could make to lead to this decision. And if you think about a simple decision where you say less than 80 equals B, greater than 90 equals whatever -grading a paper, right – you’d have a simple decision. It’d be fairly easy for it determined given a class of 300 students, it could fairly easily decide what the grade point is for an A and a B because you told it. I gave this person an A and she scored 91, I gave this person C, he scored 70. It wouldn’t be long before you could say, okay, a C is lower than a 70, a B is between 70 and 90, and an A is above 90.
Alexis
And that would be the decision tree.
Data Dave
It figuring that out, that would be the machine learning, deciding what the decision tree is based off of the inputs and the outputs.
Alexis
Got it.
Data Dave
And that’s a very simple one. Then you can extend that to 10 inputs, 1000 inputs, and a complex decision.
Because if you’ve got enough data, it will run through that data to produce this set of decisions.
Alexis
Yes. Okay.
Data Dave
The one I wrote the other week had about 50 decisions in it off of 16 or 17 points of data. No, more than that. I had hundreds of decisions based off of about 17 points of data, a matrix of data. But I didn’t want to compute it all myself, so I just taught a decision tree how to do it. So that’s a decision tree. Very deterministic, very interesting, pretty rigid.
Alexis
It sounds like it, right?
Data Dave
It’s pretty rigid. And then when you want it to do something else, you have to reteach it. So, then we get onto neural networks, which are a little more fluid, shall we say, a little more mathematical, a little less deterministic. And what this is computing is the relationship between the inputs and the outputs. Between the question and the answer. Does that make sense?
Alexis
Yeah, it’s figuring it out.
Data Dave
Exactly. So, it’s figuring out a mathematical relationship between the inputs and the outputs.
The first neural network that I wrote was one that I taught how to do basic arithmetic. So, I said, let’s take two numbers and add them together. But I’m not going to do math.
I’m going to teach a neural network how to do mathematics. So, I built a dataset that was a set of random numbers between one and ten, and then computed the answer for each of those numbers. And it’s about a thousand, I don’t know, some number of results. Then I wrote a neural network that took the two numbers as input and produced the output. So, what it was doing what it does, if you think back to your high school mathematics, then you think of your basic linear algebra, y =mx + b. For a linear relationship between two variables.
Alexis
Yes, I love y =mx + b. A good linear regression. I was good at high school math, Dave. Like that’s something I understand. Okay, keep going.
Data Dave
You just said a key word there. You said the word regression.
Alexis
Yes.
Data Dave
So, that’s exactly what this is doing. You’re basically creating a regressor from the points that you give it, which is the data that you’re training it on. It is generating the equation of that line that now lets it regress that mathematical relationship across any points that come in.
Alexis
You’re having it figure out what m and b are in the y =mx + b.
Data Dave
Exactly. Exactly. You’re having it figure out and work out what the m and the b are. So now you can feed in any value of x, and it will produce a value of y with any number of variables on that x axis.
Alexis
If you teach it 1+3=4, and it figures out the equation, you don’t have to teach it that 5+4=9. It can figure that out itself.
Data Dave
It can figure that out itself. If you give it enough that it’s figured out the m and the b, it will work that out. So now you’ve taught it how to do that basic arithmetic.
Alexis
So, because you’re teaching it an equation, you’re not teaching it math, you teach it wrong math. Right? Or you could teach it like a different base. Instead of doing a base ten math, you teach it base nine mathematic.
Data Dave
Absolutely.
Alexis
And just feed it in.
Data Dave
Yes, absolutely.
Alexis
That would be super fun to just mess with my dad. Be like, “Here Dad! Here’s a calculator.” And then all of a sudden, it’s feeding out that 5+4=10, right? And that’d be a good time.
Data Dave
It’s still 9, but it’s represented as 10, right?
Alexis
Right. Because it’s base nine.
Data Dave
Yeah, but yes, you could teach it base nine math. You could teach it anything. You could teach it just complete garbage. If your data is complete garbage.
Alexis
Garbage in, garbage out. We’ve talked about that before.
Data Dave
Exactly. If the data that you’re feeding it isn’t accurate, and therefore your regression line is incorrect, then your answer is always going to be wrong. That’s the fundamental of how a neural network, a decision tree, makes a decision, makes a straightforward decision, and we use it.
Alexis
We’ve talked about AI versus ML before- artificial intelligence versus machine learning. That, to me, sounds more like machine learning than artificial intelligence because you’re doing input-output, you’re not having it kind of learn in a different way. I don’t know. Is that right? Is that machine learning?
Data Dave
So from the difference here, from my definition, yes, I would agree with that 100%. This is about machine learning, and it’s teaching a machine to repeat decisions that you would have made based off of a rule set that you have defined. You’ve entered into the inputs, you’ve entered in the output, and it’s inferred the rules that lead from this input to that output.
Alexis
Okay.
Data Dave
So that, to me, is more machine learning. Now, artificial intelligence..
Alexis
I was hoping we were going to get there, so I’m happy.
Data Dave
…is interesting term, there’s a number of ways things learn. So you can learn like we just talked about, which is a supervised learning. Here’s a data set. We’re going to supervise the learning unit. Come up with this. There’s also the- We’re just about to put out a white paper that goes into some of this- different learning. So that then there’s unsupervised learning, which means as you interact with it and as you say, whether the answer that it gave you was right or wrong, it grows, it learns as it goes, less supervised or unsupervised. So those are two of the basic forms of learning. How does AI work? You have to ask, what is AI doing? A lot of it is just, again, more and very complex mathematics.
And the size of the equations that you’re solving for. For example, when you look at machine learning and AI for recognizing images, recognizing people in images or something like that, the image is just a matrix of numbers.
Alexis
Which I inherently know but don’t understand, but, yes.
Data Dave
Okay, well, okay, let’s talk about it. Let’s drill into that for a minute. You’ve got three planes of red, green and blue. Usually in an image for color, each color is broken down into. I’m just going to use a number, 4 million. It’s a four-bit, four-byte structure. So, you got 4 billion representations of the color green, blue and red, those three colors, each pixel. So, when you talk about a three-megapixel camera, there are 3 million pixels in that image.
Alexis
Okay?
Data Dave
So, 3 million of these items that reach our RBG color. So, every pixel has that amount of data behind it.
Alexis
So it has one designated color per pixel, which is why if you end up, like, zooming in, you get a super, you get a super blurry image because you end up with different colors in different places.
Data Dave
Well, you’re ending up with.
Alexis
My brain is walking through this really fast. And I’m like, wait a second, I think I understand this now.
Data Dave
You’re looking at the pixels. So, you’re looking at a pixel. It’s a color. That color is a blend of RGB. Each pixel has a number behind it for R, G, and B, and it represents like this. So, when you zoom really in far, you get it to pixelate, you get to see the individual dots versus the whole image.
Alexis
Okay. Okay, so, yes, there’s a whole bunch of numbers behind the picture of my face on the screen right now.
Data Dave
Exactly.
Alexis
There’s a whole bunch of them, basically.
Data Dave
Right, exactly. Lots of them. Right. When you look at these… AI to recognize that, you start to compute differences between pixel patterns on the RGB level. So, you’re mathematically saying there is a boundary between your face and your hair, and that boundary starts to kind of look like a face shape.
Alexis
Okay.
Data Dave
Or to the background and to other things.
Does that make sense?
Alexis
Yes, I’m following you.
Data Dave
And then it starts to say, okay, well, if that boundary is kind of that shape, then it is likely that that’s going to be a face, because I’ve been taught that faces look like this and have similar boundaries in them.
So there’s a probability that this set of things that I’ve detected are a face.
Alexis
Okay, I’m following you. Yes.
Data Dave
So there’s no magic in this. It is very similar to the way that we recognize things to a certain extent. It’s based off of a lot of science and whatever, of how the brain works and how we make decisions. But there is no magic here. It is finding the patterns or the features in the image by some mathematics, which I’m not going to go into by some mathematics. And then it’s saying, because of those patterns and because those patterns are in this pattern. And when I looked at a whole bunch of faces, they had similar patterns in similar areas, similar features, and similar patterns. So, therefore, it’s likely that this pattern matches this pattern.
Alexis
For the picture example, going back to the basic question, how does AI learn and make decisions? You’re feeding it a set of examples.
Data Dave
Yep.
Alexis
You’re saying, this is what I think a face looks like in a picture, and then you’re saying to it, giving it another picture and saying, do you think this is a face? And then saying yes or no?
Data Dave
That’s right, essentially.
Alexis
And then us telling it if it’s correct or incorrect.
Data Dave
Essentially, yes.
Essentially, yes. Or you’re feeding it a truck and saying, what’s this? Because you’ve taught it trucks and faces. So now you can say, here’s a car, here’s a face. Whatever you taught it, that’s usually called a classifier. So now you’re classifying those images.
Alexis
Okay. It’s learning from examples and correct versus incorrect. I feel like we’ve talked a little bit of that before.
Data Dave
It’s learning from examples and learning from the answers that it’s been given. Now, it can also learn when you give it feedback. You can say, well, actually, that’s not really a face. That’s a dog, not a person. If you’ve programmed that, then it will reclassify that image as a dog, not a person. And then it learns from that and continues to move forward. So often these are continually learning.
Alexis
When I ask DALL-E to make me a picture and I don’t like something about the picture, like, I tell it, I want a picture of an iceberg, and instead it gives me a picture of an iceberg with the Titanic, and I say, no, I don’t want the Titanic. I just want the iceberg. Is it learning in and of itself that when you say iceberg, it doesn’t mean you also want Titanic, it means you just want an iceberg. And next time I ask for an iceberg, will it be like, oh, I don’t want to give it Titanic.
I just asked DALL-E to make me an iceberg picture. That’s why it’s on my brain. Not necessarily so, no, it doesn’t get that feedback from me.
Data Dave
It can and some do, but it doesn’t necessarily what it is doing. Is it saying, oh, of all the libraries that I have of images that are tagged with the term iceberg, I am going to give it the best one that I can produce. It just happens to have a ship in it.
So if you then add context to say, I want an iceberg without a ship. Then you’ve essentially narrowed its classification into the image library that it can draw from as its base image set.
So you’re classifying it down to say, just this. Now, that’s if it’s just looking up and reading within an image set within a library, if it’s generating it, then a very similar thing happens. But it uses that image set to produce essentially a random image that it then feeds to a classifier and then says, does this look like what she asked for?
Alexis
Okay, talk to me a little bit more about that.
Data Dave
So the generative AI piece, rather than looking up in a library of images, says, okay, I’m going to generate an image. Well, essentially, go back to the numbers that make up an image.
Well, essentially, you could make an image just out of a whole bunch of random numbers. It might look a little odd, but it would be a whole bunch of random numbers. Then you could test it and say, does that look like Alexis? And there’s a good chance that it doesn’t.
Alexis
That’s true.
Data Dave
But now do this a billion times, and you’re into the Shakespeare and monkey analogy, right? An infinite number of monkeys with an infinite number of typewriters will eventually write the complete works of Shakespeare.
Alexis
I’ve never heard that before, but that’s good. I’ve never heard that.
Data Dave
No disrespect. It’s an old adage.
Alexis
Yeah.
Data Dave
So you can generate a whole bunch of random numbers, feed it into another classifier, and say, okay, is it one of these? The answer is highly likely to be no. And then it guesses again and does it again. Well, if you apply learning to that, so that you go back to your m and b idea and say that every pixel, you’ve actually asked it for a picture of Alexis or a picture of certain things, and every pixel is generated using some mathematics. So now you start to say, okay, every time I say no, it’s not what I want, it adjusts its mathematics to get closer.
Alexis
And if you did that an infinite amount of times, you would eventually end up with a picture of me.
Data Dave
If you do that enough times, and then seed the random number generators with a library of images, you will generate the right random numbers that are probably a good approximation towards Alexis.
Alexis
Yes.
Data Dave
Then you test it and put that through a classifier that says yes or no when they are in a good adversarial discussion, these two engines, then you’ve got an image generator, then you’ve got, what is generative AI GANN. You’ve heard the term again, right?
A generative, adversarial neural network.
Alexis
Yes.
Data Dave
So you’ve got two neural networks working adversarial to produce an image that looks like it might be one of these.
Alexis
It’s just doing it really fast.
Data Dave
It’s doing it very fast and it’s learning from it as to how it’s generating. It’s essentially random numbers. They’re not random anymore. Right. How it’s generating its numbers that produce an image. It’s then doing that. So, it’s all the mathematics behind it to do all this sets of regressions, it’s just doing a tremendous number of them. And they don’t have to be linear functions. We use linear because it’s easy to understand. But when you start talking about the nonlinear functions and fitting curves and different things to two structures, and then you’re talking about hundreds of thousands to millions of these points in an image, you start to get quite interesting.
Alexis
Okay.
Data Dave
And that’s why you need so much compute power to do this. It’s a lot of work.
Alexis
I’m going to ask you the question one more time and I want you to give me like a 30 second answer. Let’s do a recap. How does AI learn and make decisions?
Data Dave
So, AI learns by tuning mathematical algorithms that give an inference between the inputs and the outputs.
How was that?
Alexis
That was perfect.
I want to talk more about generative AI in another episode for sure, but I think that helped me understand the back end of AI a little bit more, especially as we head into the age of AI, if you will. So very, very, very interested to talk more with you about that. This was a good stuff. I like this.
Okay, well, thank you, Dave, for joining me today. Listeners, I super appreciate you being here. Make sure you send us your questions at talktech@d3clarity.com or right on the D3Clarity Website.
Dave, like I said, it’s been a good day. I feel like I’ve learned so much already.
Data Dave
Okay, thank you. And thank you listeners.