1 00:00:00,260 --> 00:00:04,200 The class, of course, was the complete introduction to data science with Python. 2 00:00:04,650 --> 00:00:10,530 So until now, we talked about many interesting things that are around that are science and this class. 3 00:00:10,530 --> 00:00:14,060 We are still going to talk about machine learning and some algorithms. 4 00:00:14,520 --> 00:00:18,980 So all of this class today would be to create another machine learning algorithm, which would be that 5 00:00:18,990 --> 00:00:19,590 key means. 6 00:00:20,040 --> 00:00:22,620 So for the purpose of this class, what we'll do is pretty simple. 7 00:00:22,620 --> 00:00:29,220 We are going to generate random numbers and we are going what random points on each word and we are 8 00:00:29,220 --> 00:00:32,550 going to define the center of those random points. 9 00:00:33,390 --> 00:00:35,210 So you'll see it's pretty simple to do. 10 00:00:35,640 --> 00:00:41,370 And once again, it's one of the algorithms that we are going to learn what we are going to learn to 11 00:00:41,370 --> 00:00:41,850 work with. 12 00:00:42,330 --> 00:00:43,480 So let's start. 13 00:00:43,780 --> 00:00:48,730 So pretty simple for the purpose of this class will need to import some tools. 14 00:00:48,730 --> 00:00:54,510 So basically, we'll need to import numbers so worth by as an. 15 00:01:00,690 --> 00:01:04,200 We also need to import Seabourne. 16 00:01:11,660 --> 00:01:13,400 We will need to import Muttalib. 17 00:01:31,640 --> 00:01:38,810 You will, and we will need also to import well, since we're working with and we will need to import 18 00:01:38,810 --> 00:01:45,920 key means, the algorithm that we are going to work with and also make blob's, which which is a tool 19 00:01:45,920 --> 00:01:49,460 that works with key to be able to generate random numbers. 20 00:01:50,450 --> 00:01:51,320 So pretty simple. 21 00:01:52,850 --> 00:02:07,490 So it's going to be from Escalon, the cluster import means, which would be the first thing that we 22 00:02:07,490 --> 00:02:11,360 will import and also we will import from. 23 00:02:11,900 --> 00:02:27,570 Ezekial learned that data sets the samples to later import make blob's. 24 00:02:29,780 --> 00:02:30,120 All right. 25 00:02:30,150 --> 00:02:35,120 So right now we have all the tools that we need to be able to work with all this. 26 00:02:36,710 --> 00:02:42,800 So the first thing that we are going to do would be writing our well, creating our well, creating 27 00:02:42,800 --> 00:02:43,460 our points. 28 00:02:43,820 --> 00:02:46,690 So pretty simple, but we are going to read them right here. 29 00:02:46,700 --> 00:02:49,400 So we'll have our X Y 30 00:02:52,100 --> 00:02:58,360 will be equal to, in our case, make blob's. 31 00:03:00,230 --> 00:03:05,060 So the first argument that we will need is the sample size in our case, what will be the sample size 32 00:03:05,060 --> 00:03:06,380 that we are going to work with? 33 00:03:06,950 --> 00:03:09,700 Let's say we need a sample size of 800. 34 00:03:10,070 --> 00:03:13,910 So basically you guys can decide of the sample size that you want. 35 00:03:14,180 --> 00:03:23,960 So in our case, we are going to work with the 800 or so and samples would be equal to, let's say, 36 00:03:23,990 --> 00:03:24,830 800. 37 00:03:27,000 --> 00:03:30,720 All right, then you can decide of the number of centers that you want. 38 00:03:30,760 --> 00:03:35,940 So let's say we want I don't know, let's say we want five centers. 39 00:03:36,450 --> 00:03:43,070 So we have 800 points, five centers, then cluster study. 40 00:03:48,300 --> 00:03:54,900 Let's put it at zero point forty five and random state states zero. 41 00:04:01,220 --> 00:04:07,230 Random state would be equal to zero. 42 00:04:07,500 --> 00:04:14,310 All right, so we have all our arguments to be able to make it work, then we'll use a scatterplot to 43 00:04:14,310 --> 00:04:15,710 put everything together. 44 00:04:16,850 --> 00:04:21,960 So we'll write it down right here, Superyacht, since we are making reference to Muttalib that by but 45 00:04:23,710 --> 00:04:24,450 scatter. 46 00:04:30,360 --> 00:04:32,070 In this case, we'll have our X. 47 00:04:42,510 --> 00:04:49,020 Uh, here we go, and would have our eggs, for one. 48 00:04:50,540 --> 00:04:54,320 This case points and one. 49 00:04:56,390 --> 00:05:00,830 And we will define our so what the value will give to us. 50 00:05:00,850 --> 00:05:04,960 So I think our case will give a value of around third. 51 00:05:06,410 --> 00:05:06,770 All right. 52 00:05:06,770 --> 00:05:08,780 So right now we have everything that we need. 53 00:05:12,380 --> 00:05:13,630 Not forget your on. 54 00:05:13,670 --> 00:05:14,870 It's pretty important. 55 00:05:34,960 --> 00:05:35,330 All right. 56 00:05:36,340 --> 00:05:38,560 Next thing we are going to create our function. 57 00:05:38,590 --> 00:05:40,270 So right now, it's time to create our function. 58 00:05:40,300 --> 00:05:42,850 So, as always, we should give meaning to a function. 59 00:05:43,630 --> 00:05:45,910 So let's say we are giving to our elect. 60 00:05:45,940 --> 00:05:48,090 We are naming our function like always function. 61 00:05:48,250 --> 00:05:49,660 So let's call it function. 62 00:05:51,370 --> 00:05:54,190 And what's the type of function that we are going to work with? 63 00:05:54,820 --> 00:05:55,620 It's pretty simple. 64 00:05:55,630 --> 00:05:57,260 We are going to work with Kenyans. 65 00:05:57,270 --> 00:06:03,380 So as always, key means the function is just here and then we can decide of the number of clusters. 66 00:06:03,380 --> 00:06:13,990 So in our case, the number of clusters that we want to have would be, let's say, four and clusters. 67 00:06:15,580 --> 00:06:17,550 So we want to have four clusters. 68 00:06:19,360 --> 00:06:22,420 So basically four movements of points. 69 00:06:23,440 --> 00:06:23,820 All right. 70 00:06:23,860 --> 00:06:30,430 Next thing we are going to fit our function so we will use the fit function for this will have function 71 00:06:31,930 --> 00:06:32,890 that fit. 72 00:06:34,160 --> 00:06:35,540 And one of it ex. 73 00:06:44,950 --> 00:06:45,910 Here we go. 74 00:06:46,810 --> 00:06:48,170 All right, so everything is done. 75 00:06:48,740 --> 00:06:56,460 I to give a wide value to our function, so why function and what to do right now? 76 00:06:56,470 --> 00:06:57,770 We want to predict our X. 77 00:06:57,790 --> 00:06:59,980 So basically, we are going to predict our centers. 78 00:07:03,280 --> 00:07:04,890 OK, the verdict. 79 00:07:08,210 --> 00:07:09,930 All right, so right now we have everything that we need. 80 00:07:10,280 --> 00:07:16,880 Next thing that we will do is we are going to, well, make our graph a little bit more beautiful. 81 00:07:18,170 --> 00:07:22,280 To want to generate would be a bladder well, will be a scatterplot. 82 00:07:23,270 --> 00:07:25,400 So plg the scatter. 83 00:07:28,640 --> 00:07:34,670 So in this case, it's going to be the same thing as here, so we're just going to come here and copy 84 00:07:34,670 --> 00:07:35,870 the elements right there. 85 00:07:46,880 --> 00:07:54,120 Then we'll need to give a C argument to our function, so the C would be the why function right here. 86 00:07:55,160 --> 00:07:58,380 So it will be a reference to this function right there. 87 00:07:58,400 --> 00:08:02,770 So basically, it's going to be fun to predict because we want to predict our X in this case. 88 00:08:02,780 --> 00:08:05,330 Our goal is to predict the experts predict descenders. 89 00:08:08,370 --> 00:08:14,100 And finally will have or as that will be equal to, let's say I don't know, 15. 90 00:08:16,990 --> 00:08:19,630 All right, then, what to do? 91 00:08:19,660 --> 00:08:23,620 Well, we need to add centers in this case, we got to write down the center's. 92 00:08:30,100 --> 00:08:31,750 He would have centers. 93 00:08:33,960 --> 00:08:39,030 And finally, the last thing that will do, I will simply write down our scatterplot, so basically 94 00:08:39,030 --> 00:08:46,160 we will write down what color we want our centers to be if we want them to be really bright or not that 95 00:08:46,200 --> 00:08:49,480 bright and all this type of stuff. 96 00:08:50,490 --> 00:08:51,410 So pretty simple. 97 00:08:51,480 --> 00:08:52,260 Just write down. 98 00:08:52,290 --> 00:08:59,660 So if we want, we can write down the actual function now, but we won't do it so filthy that scatter. 99 00:09:00,480 --> 00:09:02,640 And here we're going to write down our centers. 100 00:09:06,390 --> 00:09:07,080 Here we go. 101 00:09:11,890 --> 00:09:13,450 And here we'll have our centers, 102 00:09:16,720 --> 00:09:19,120 that would be two points one. 103 00:09:22,730 --> 00:09:27,140 So the color that we want so far to see, it's pretty simple, it's the color that we want. 104 00:09:27,150 --> 00:09:31,620 So basically what color we want to want the red color, let's put red. 105 00:09:31,640 --> 00:09:34,420 So if you guys want to be blue center, you can write down blue. 106 00:09:34,420 --> 00:09:36,940 If you want a white center, we can write down white. 107 00:09:37,850 --> 00:09:45,230 So we want a red center for our S. We want it to be not 100, because one hundred would be really, 108 00:09:45,230 --> 00:09:45,730 really bright. 109 00:09:46,160 --> 00:09:49,620 So let's say we wanted seventy. 110 00:09:51,530 --> 00:09:53,630 And finally, the alpha will be. 111 00:10:00,920 --> 00:10:02,750 All right, so right now we have everything that we need. 112 00:10:02,930 --> 00:10:06,100 The last thing would be simply showing our blood. 113 00:10:06,170 --> 00:10:13,210 So basically the show and we can just run our up right now. 114 00:10:14,720 --> 00:10:17,360 And as you can see, we have everything that we need right here. 115 00:10:17,370 --> 00:10:22,220 So basically, we have our center of what we have all our sensors that are generated. 116 00:10:22,640 --> 00:10:25,780 We have our 800 send 800 samples. 117 00:10:25,790 --> 00:10:32,040 So basically, as you can see, 800 samples, as we said, we want well, five centers. 118 00:10:32,040 --> 00:10:35,640 So basically our centers, it's right here, we have it's divided in five. 119 00:10:35,640 --> 00:10:41,360 So one, two, three, four, five, six selected four clusters is going to be only for centers that 120 00:10:41,360 --> 00:10:42,020 will be created. 121 00:10:42,030 --> 00:10:43,780 So we have one, two, three, four. 122 00:10:43,940 --> 00:10:49,640 If we change it to fight, for example, you'll see it's going to change as well if we run up. 123 00:10:52,850 --> 00:10:59,360 So you can see right now it became five also for the color, as you can see, we said red. 124 00:10:59,390 --> 00:11:00,430 So it's all red. 125 00:11:00,620 --> 00:11:02,380 So basically it works pretty fine. 126 00:11:03,230 --> 00:11:07,910 And for the air, as you can see right here, is simply how you want to be, right. 127 00:11:07,940 --> 00:11:09,940 So right now, we have it pretty bright. 128 00:11:09,950 --> 00:11:13,790 So if we put, for example, zero right here, we won't see the centers at all. 129 00:11:14,360 --> 00:11:17,180 So basically, this is just to make it a little bit more beautiful. 130 00:11:17,630 --> 00:11:19,770 So what does this tell us? 131 00:11:19,790 --> 00:11:26,360 It's simply tell us where exactly is the center inside of the center point inside of all the points 132 00:11:26,360 --> 00:11:27,590 that we have right here. 133 00:11:27,620 --> 00:11:30,090 So basically what it does, it will simply find the center point. 134 00:11:30,320 --> 00:11:34,410 And what we have done with the function right here, we have generated random points. 135 00:11:34,410 --> 00:11:37,820 So basically we have random points a bit everywhere on the ground. 136 00:11:38,330 --> 00:11:44,630 And from those random points, we simply have found the center of each of those random points. 137 00:11:45,590 --> 00:11:50,750 So those are the basic functions that we are going to talk about in our machine learning part. 138 00:11:51,890 --> 00:11:57,980 So right now, you guys should be able to create your own well, your own little function, your own 139 00:11:57,980 --> 00:12:02,650 machine learning, little systems, really basic systems with those functions. 140 00:12:02,660 --> 00:12:07,730 So you have really the basics and introduction to be able to work with those basic systems. 141 00:12:08,240 --> 00:12:11,750 So that's a first class guys and see all in our next class.