The class, of course, was the complete introduction to data science with Python.
So until now, we talked about many interesting things that are around that are science and this class.
We are still going to talk about machine learning and some algorithms.
So all of this class today would be to create another machine learning algorithm, which would be that
key means.
So for the purpose of this class, what we'll do is pretty simple.
We are going to generate random numbers and we are going what random points on each word and we are
going to define the center of those random points.
So you'll see it's pretty simple to do.
And once again, it's one of the algorithms that we are going to learn what we are going to learn to
work with.
So let's start.
So pretty simple for the purpose of this class will need to import some tools.
So basically, we'll need to import numbers so worth by as an.
We also need to import Seabourne.
We will need to import Muttalib.
You will, and we will need also to import well, since we're working with and we will need to import
key means, the algorithm that we are going to work with and also make blob's, which which is a tool
that works with key to be able to generate random numbers.
So pretty simple.
So it's going to be from Escalon, the cluster import means, which would be the first thing that we
will import and also we will import from.
Ezekial learned that data sets the samples to later import make blob's.
All right.
So right now we have all the tools that we need to be able to work with all this.
So the first thing that we are going to do would be writing our well, creating our well, creating
our points.
So pretty simple, but we are going to read them right here.
So we'll have our X Y
will be equal to, in our case, make blob's.
So the first argument that we will need is the sample size in our case, what will be the sample size
that we are going to work with?
Let's say we need a sample size of 800.
So basically you guys can decide of the sample size that you want.
So in our case, we are going to work with the 800 or so and samples would be equal to, let's say,
800.
All right, then you can decide of the number of centers that you want.
So let's say we want I don't know, let's say we want five centers.
So we have 800 points, five centers, then cluster study.
Let's put it at zero point forty five and random state states zero.
Random state would be equal to zero.
All right, so we have all our arguments to be able to make it work, then we'll use a scatterplot to
put everything together.
So we'll write it down right here, Superyacht, since we are making reference to Muttalib that by but
scatter.
In this case, we'll have our X.
Uh, here we go, and would have our eggs, for one.
This case points and one.
And we will define our so what the value will give to us.
So I think our case will give a value of around third.
All right.
So right now we have everything that we need.
Not forget your on.
It's pretty important.
All right.
Next thing we are going to create our function.
So right now, it's time to create our function.
So, as always, we should give meaning to a function.
So let's say we are giving to our elect.
We are naming our function like always function.
So let's call it function.
And what's the type of function that we are going to work with?
It's pretty simple.
We are going to work with Kenyans.
So as always, key means the function is just here and then we can decide of the number of clusters.
So in our case, the number of clusters that we want to have would be, let's say, four and clusters.
So we want to have four clusters.
So basically four movements of points.
All right.
Next thing we are going to fit our function so we will use the fit function for this will have function
that fit.
And one of it ex.
Here we go.
All right, so everything is done.
I to give a wide value to our function, so why function and what to do right now?
We want to predict our X.
So basically, we are going to predict our centers.
OK, the verdict.
All right, so right now we have everything that we need.
Next thing that we will do is we are going to, well, make our graph a little bit more beautiful.
To want to generate would be a bladder well, will be a scatterplot.
So plg the scatter.
So in this case, it's going to be the same thing as here, so we're just going to come here and copy
the elements right there.
Then we'll need to give a C argument to our function, so the C would be the why function right here.
So it will be a reference to this function right there.
So basically, it's going to be fun to predict because we want to predict our X in this case.
Our goal is to predict the experts predict descenders.
And finally will have or as that will be equal to, let's say I don't know, 15.
All right, then, what to do?
Well, we need to add centers in this case, we got to write down the center's.
He would have centers.
And finally, the last thing that will do, I will simply write down our scatterplot, so basically
we will write down what color we want our centers to be if we want them to be really bright or not that
bright and all this type of stuff.
So pretty simple.
Just write down.
So if we want, we can write down the actual function now, but we won't do it so filthy that scatter.
And here we're going to write down our centers.
Here we go.
And here we'll have our centers,
that would be two points one.
So the color that we want so far to see, it's pretty simple, it's the color that we want.
So basically what color we want to want the red color, let's put red.
So if you guys want to be blue center, you can write down blue.
If you want a white center, we can write down white.
So we want a red center for our S. We want it to be not 100, because one hundred would be really,
really bright.
So let's say we wanted seventy.
And finally, the alpha will be.
All right, so right now we have everything that we need.
The last thing would be simply showing our blood.
So basically the show and we can just run our up right now.
And as you can see, we have everything that we need right here.
So basically, we have our center of what we have all our sensors that are generated.
We have our 800 send 800 samples.
So basically, as you can see, 800 samples, as we said, we want well, five centers.
So basically our centers, it's right here, we have it's divided in five.
So one, two, three, four, five, six selected four clusters is going to be only for centers that
will be created.
So we have one, two, three, four.
If we change it to fight, for example, you'll see it's going to change as well if we run up.
So you can see right now it became five also for the color, as you can see, we said red.
So it's all red.
So basically it works pretty fine.
And for the air, as you can see right here, is simply how you want to be, right.
So right now, we have it pretty bright.
So if we put, for example, zero right here, we won't see the centers at all.
So basically, this is just to make it a little bit more beautiful.
So what does this tell us?
It's simply tell us where exactly is the center inside of the center point inside of all the points
that we have right here.
So basically what it does, it will simply find the center point.
And what we have done with the function right here, we have generated random points.
So basically we have random points a bit everywhere on the ground.
And from those random points, we simply have found the center of each of those random points.
So those are the basic functions that we are going to talk about in our machine learning part.
So right now, you guys should be able to create your own well, your own little function, your own
machine learning, little systems, really basic systems with those functions.
So you have really the basics and introduction to be able to work with those basic systems.
So that's a first class guys and see all in our next class.