okay let's start class the first lesson is to briefly introduce machine learning and the basic concept of deep learning i will talk about a story totally unrelated to pokemon i'll tell you the basic concepts of machine learning and deep learning so what is machine learning i think that everyone must have heard the phrase machine learning in newspapers or magazines then you must also know that machine learning is somewhat related to ai which is very popular today what is machine learning as the name implies it seems to say that the machine has the ability to learn those articles often describe machine learning is a mysterious technique such that we will get artificial intelligence after machines have learned then machines will rule all mankind so what exactly is machine learning in fact machine learning can be generally described in one sentence what is machine learning machine learning is to make the machine have the ability to find a function after the machine has the ability to find functions what can it do it can do a lot of things for example suppose you ask the machine to do speech recognition the machine listens to a clip of audio then generates the corresponding text then all you need is a function the input of this function is an audio signal and the output is the content of this audio signal then you can imagine that the function that can turn the sound signal into text is obviously very complicated it is impossible that humans can write down the function by hand this function is really complicated humans have absolutely no ability to write it down so we expect to rely on the power of the machine to find the function automatically this is machine learning the example i just gave is a speech recognition task and there are many other tasks the thing in common is to find a complicated function for example suppose now we have an image recognition task what kind of function do we need the input of this function is an image what is the output the output is the content in the image take the well-known alphago as an example in fact it can also be viewed as a function in order to make the machine play go all we need is a function the input of the function is the position of black and white on the go board the output is the next position the machine should play assume that you can find a function the input of the function is the position of black and white on the go board the output is where the next step should be placed then we can make the machine play go automatically then we made an alphago as the output of the function differs machine learning has different categories here we introduce some technical terms the first term is regression regression means the function we are looking for outputs a number this kind of machine learning task with scalar output is called regression here is an example of regression suppose what we want the machine to do is to predict the value of pm 2. 5 at a certain time in the future what the machine needs to do is to find a function denoted as f the output of this function is the value of pm 2. 5 at noon tomorrow the input may be various values related to predicting pm 2.
5 it might include the value of pm 2. 5 today average temperature today and average ozone concentration today etc this function can take these values as input and output the pm 2. 5 value at noon tomorrow the task of finding this function is called regression are there any other tasks there are other tasks besides regression another task that everyone is familiar with is called classification the classification task is we would like the machine to do multiple choice questions some options are created by humans in advanced also called categories the output of the function we are looking for is among the options we created choose one as the output of the question this task is called classification for example everyone has a gmail account there is a gmail account function that can help the user to detect whether an email is spam or not the input of this function is an email what is the output you must first prepare the options you want the machine to choose in the problem of detecting spam there are two possible options which are spam or not spam yes or no the machine must choose an answer either yes or no this is the classification problem classification problems aren't limited to having only two options there can also be multiple choices for example what alphago does is also a classification task but its task is different in the sense that alphago has more options to choose from if you want to train a machine to play go or if you want to train an alphago yourself how many options should you give it just think about how many positions there are on the board we know there are 19 times 19 available positions on the board so the task of training a go-playing machine is actually a multiple choice question with 19 times 19 options what you want the machine to do is to find a function the function takes all black and white stone's positions as its input and outputs the correct choice within the 19 times 19 choices that is within the 19 times 19 choices it outputs the most winning next step so this problem is also a classification problem actually in many textbooks about machine learning when they talk about all kinds of tasks machine learning does they say machine learning's tasks can be separated into two categories regression and classification only those two but if you thought that machine learning is simply two different kinds of tasks regression and classification it's just like you think there are only five continents in this world you know that the world is not only the five continents right there is still a land of darkness before demon slayer was serialized we had already set off to the land of darkness and until now we still haven't arrived yet from this we can see that how far away the land of darkness is so in the field of machine learning what is the so-called land of darkness outside of regression and classification there is a problem that people are often afraid of structured learning that is the machine not only needs to do multiple choice questions are output a number but also needs to produce a structured object for example draw a picture or write an essay this kind of problem where the machine needs to output structured objects is called structured learning speaking more anthropomorphically in a fashion way you can say that the machine learns how to create so far we have talked about the three tasks of machine learning regression classification and structured learning next we'll talk about how machines find the function after all machine learning is finding a function so how do they do that i'm going to use an example here to explain how the machine finds a function what is the example here before telling you the example i would like to share with you that this course has a youtube channel i upload recordings of classes onto this youtube channel thanks to the students who took this course in the past actually quite an amount of people have subscribed so i am actually a third-rate youtuber my videos don't have that many views though but i have more than 70 000 subscribers so why did i suddenly mention my youtube channel because our example has something to do with youtube do you know what a youtuber cares about most a youtuber cares about the traffic of his channel right suppose a youtuber makes a living by youtube he will care about his channel's traffic which earns him profit so i want to ask if it is possible for us to find a function the input of this function is youtube's background information and the output is the total amount of clicks in the next day if you have a youtube channel yourself you may know that in the background of youtube you can find a lot of related information for example how many people pressed like on each day how many people subscribed each day or how many views each day can we utilize all the past information to predict how many times it is likely to be viewed tomorrow is it possible that we find a function the input of this function is youtube's background information of my channel and the output is the total number of views that this channel will have on the next day some of you may ask why i want to do this if i earn money on youtube i can predict how much i will make in the future but i don't earn money on youtube so i actually don't know why i need to do this it is not even useful for me i just wanted to give an example okay now we want to know how we can find this function this function f that we're trying to find takes the data from youtube's management interface as the input and outputs the total view this channel will get on the next day the process of finding this function using machine learning can be divided into three steps we will take the task of predicting the number of views on this channel as an example two explain how these three steps actually work the first step is to write out a function with unknown parameters in short we start by guessing what function f looks like what does its formula look like for example let's make a very rough guess of what f might look like what kind of relationship would the input and the output have we assume it looks something like this y equals w times x1 plus b what does each variable represent respectively the y variable represents the total views we will get today but since today isn't over yet we do not know the total number of views today this is something that is unknown to us why is the prediction we're trying to make the total number of views we will get today then what about x1 x1 is the number of views that we got on this channel yesterday this means that both y and x1 are numerical values y is the prediction we're trying to make and x1 is the information given what about b and w b and w are unknown parameters that we're trying to find with the help of the data we don't know what w and b should be we could only make a rough guess but how do we even come up with a guess the guess often comes from your understanding of the nature of the problem which is domain knowledge that's why people always say to use machine learning you need some domain knowledge and when is domain knowledge needed domain knowledge is needed when we have a function with unknown parameters so how do we know that this function f predicts the number of future views by multiplying the number of views from the previous day by w and then adding b we don't know that it's just a guess we're guessing that the number of clicks we get today is always somewhat related to the views we got on the previous day so we take the number of views from the previous day and multiply it by a value but the prediction is always not exactly accurate so we add b to correct it and take the result as our prediction this is a guess and it's not necessarily correct we will come back later to correct this prediction anyway we now guess that y equals w times x1 plus b and both b and w are unknown now we have a function that has several unknown parameters these kinds of functions with unknown parameters are called models in machine learning that's why we often hear the word model in the field of machine learning when we talk about machine learning a model is some function that has unknown parameters okay so the x1 here is something we know in this function it is something that we already know in our case it is the data from youtube's management interface so we already know how many views we got on the previous day this is called a feature as for w and b they are unknown parameters here we also give w and b different names this unknown parameter w is multiplied by the feature we call it the weight this unknown parameter b is added directly without being multiplied by the feature we call it the bias these are just the definitions of some nouns as we continue these technical terms will help us clarify things in the model and make explaining more convenient so this is the first step what about the second step the second step is to define something called the loss what is a loss it is also a function the inputs of this function are the parameters of our model i have written out our model right our model is called y is equal to b plus x1 multiplied by w where b and w are unknown that is what we are going to find out as for l also known as loss it is a function what are the inputs of this function the inputs of this function are b and w so l is a function its inputs are parameters it's the parameters of the model then of this loss of this function what do the output values stand for the output values from this function stand for that if we set these unknown parameters to certain values how well it performs it might be a little bit abstract for you to understand so i am giving you a concrete example suppose that we set the unknown parameters b the bias which is equal to 0.
5 k and w which is equal to 1. how do we calculate this loss if we set b to 0. 5 k and w to 1 then the function we are going to use to predict the numbers of viewers in the future becomes y is equal to 0.
5 k plus x 1 multiplied by 1 then this kind of function 0. 5 k and 1 the function they stand for how much is it this thing is so called loss then in this problem how do we calculate this loss we have to calculate it from the training data in this problem what is our training data our training data is the number of viewers on this channel in the past for example the number of viewers from 2017 to 2020 is known on this channel every day here are all fake numbers i made them up okay so we know that from january 1 2017 to december 31 2020 what the number of viewers is next we can calculate the loss how do we calculate it we put the number of viewers on january 1 2017. into this function we have said that we want to know when b is set to 0.
5 k and w is set to 1. how well this function will perform when b is set to 0. 5 k and w is set to 1.
the function we used to predict is y is equal to 0. 5 k plus x1 multiplied by 1. then we will replace the x1 by 4.
8 k and see what the predicted result is so based on this function b is set to 0. 5 k and w is set to 1. if on january 1st the number of viewers is 4.
8 k the number of viewers the next day should be 4. 8 k multiplied by 1 plus 0. 5 k which is 5.
3 k as for the number of viewers the next day do we know it on january 2nd in fact we know it from the back end so we could compare them to know between the predicted result and real result of this function how big the difference is the predicted result of this function is 5. 3 k what is the real result the real result is 4. 9 k it is overestimated it overestimates the number of possible viewers on this channel then we can calculate the difference we calculate the difference between predicted value and real value the predicted value here is represented by y the real value here is represented by y head you can calculate the difference between y and y head to get an e prime which represents the difference between the estimated value and the real value there is more than one way to calculate the difference actually here we subtract y from y head and take the absolute value directly the calculated value is 0.
4 k ok the data we have now is not only of january 1st and of january 2nd but of from january 1 2017 to december 31 2020 three years of data in total the real value is called label so i often hear people saying that machine learning needs labels labels refer to the real value this is called label also not only can we use the value of january first to predict that of january 2nd but we can use the value of january 2nd to predict that of january 3rd suppose our current function is y is equal to 0. 5 k plus 1 x1 as for january 2nd according to the views on january 2nd what is the value of predicted views in january 3rd it's 5. 4 k replace x1 with 4.
9 k multiply it by 1 and add 0. 5 k we get 5. 4 k next calculate the gap between 5.
4 k and the real answer also known as the label the label is 7. 5 k here so it seems to be an underestimation we underestimated the views of this channel on january 3rd so we calculate e2 this e2 is y minus it's the gap between y and y hat which is 2. 1 k hence with the same method you can obtain the prediction error of each day during the past three years now suppose our function is y equal to 0.
5 k plus 1x1 the error of each day in the past three years can be calculated entirely the error of each day gives us a small e okay then we will sum up all the errors of each day and get the average from the summation this big n represents our number of training data points the number of them is the number of those training data for three years so it's 365 times 3 365 days a year 3 years so it's 365 times 3. then we get an l we calculate the big l this big l is the result of summing up these e's which are the errors of all training data making up our loss the bigger the big l is implying the worse this set of parameters is the smaller the big l is implying the better this set of parameters is as for this e which is the difference between the estimated value and the actual value can be calculated by different methods actually in our example just now we calculated the gap between y and y hat in absolute value with this method of calculating the gap this big l obtained the loss obtained is called mean absolute error whose abbreviation is mae in homework 1 instead we calculate the square of y minus y-hat if your e is calculated by the square of subtracting ys today it is called mean square error also known as mse in fact there are very subtle differences between mse and mae usually you have to choose which is your method to measure distances that depends on your needs and your understanding of this task we won't go into detail here anyway we choose mae as the way we calculate this error adding up all the errors you get the loss it's your freedom to choose mse and we will use mse in homework 1. also there are some tasks in which y and y-hat are both probabilities both probability distributions at this moment you may choose cross-entropy we'll talk about this later too anyway we choose mae here this is the second step of machine learning those numbers i just mentioned didn't come from a real example but in this course when i give a lecture i am here to show you a real example therefore the following numbers did come from a real example it's the calculated result from the real background data of this channel we can adjust different w we can adjust different b seek all different w's and all different b's exhaustively and combine them we can try different combinations of w and b and calculate their losses finally you can draw the contour map below on this contour map the redder it is the greater the loss calculated is implying the worse this set of w and b is the bluer it is indicating the smaller the loss is implying it's a better combination of w and b take this combination of w and b put it into our function into our model and then we will predict it more accurately so you know that suppose w is minus 0.
25 and b is minus 500 it means that this w is minus 0. 25 and b is minus 500 which means that there are fewer and fewer people watching this channel every day and the loss is so big which doesn't match the real situation if we substitute w with 0. 75 and substitute b with 500 the correct rate or the estimation will be more accurate the most accurate estimation seems to be here if you substitute w with a value very close to 1 and substitute b with a small value such as around 100 at this time the estimation is the most accurate this may be closer to everyone's expectation that you take the total number of clicks in the previous day too predict the total number of clicks on the next day maybe the total number of clicks on the previous day and the number on the next day are almost the same so we substitute w with 1 and substitute b with a smaller value maybe your estimation will be quite accurate a contour map like this is that you tried different parameters and then calculated its loss and then drawn the contour map which is called error surface this is the second step of machine learning next we move on to the third step of machine learning what we do in the third step is to solve an optimization problem it doesn't matter if you don't know the optimization problem what we are going to do today is to find a w and b find a value of unknown parameters to see that which value can make our big l can make our lost value be the smallest that is the w and b we are looking for the w and b which can make the law smallest are called w star and b star which means that they are the best set of w and b too minimize the value of the loss so how to do this the only one optimization method that we will use in this course is called gradient descent how to use gradient descent how to use this method it is done like the following to simplify let's assume that there is only one unknown parameter w let's assume that there is no unknown parameter b only the unknown parameter w when we substitute w with different values we will get different losses and this curve is the error surface in the previous example the error surface we saw is two-dimensional it's 2d there is only one parameter here so the error surface we see is 1d then how to find 8 minimize the value of this loss first you have to randomly select an initial point the initial point is called w0 the initial point is often randomly selected just pick one randomly really random later in this course we will know that there may be some methods that can give us a better value of w0 here we don't talk about it we just treat it as random randomly roll a dice to decide the value of w0 let's assume that the result of our random decision is at this place then you have to calculate the derivative of loss with respect to w when w is equal to w0 i assume you know what differential is this is not a problem for you calculate the derivative of loss with respect to w if you don't know what differential is that's okay what we are doing is to calculate the slope of this error surface at this point at the point of w0 which is this blue dotted line what if the slope of this dotted line is negative what does that mean it means that the left side is higher and the right side is lower around this point the left side is higher and the right side is lower if the left side is higher and the right side is lower what are we going to do if the left is higher and the right is lower then we increase the value of w2 make the loss smaller if the calculated slope is positive it means that the left side is lower and the right side is higher it looks like this the left side is lower and the right side is higher if the left is lower and the right is higher it means we need to make w smaller if you can reduce the loss value by moving w to the left you should make w smaller even if you have no idea what slope is it doesn't matter just imagine that there is somebody standing at this point looking around this means taking the derivative the derivative helps us know whether the function will have a lower value at the right or the left to the point where we are then we take a step towards the point with a lower function value how big is this step the size of this step depends on two things the first is how big the slope at this point is the greater the slope the bigger the step is if the slope is small our stride will be small in addition to the slope namely the derivative which we just talked about in addition to the derivative there is another thing that affects the step size we denote it with eta this eta is called the learning rate the rate at which the model learns where does it come from it depends on you you can decide the value of a to yourself if ada is set larger the amount of parameter update will be larger and the model will be able to learn faster if ada is set smaller the rate of the update will be slower and the parameters will have slight changes at each iteration things that need to be set manually when practicing machine learning are called hyperparameters the first step of machine learning is to define a function with unknown parameters and these parameters the unknowns will be found by the machine itself oh there's a question please speak up okay this is actually a good question let me repeat it someone asked why a loss function can have negative values the loss is a user-defined function so from the definition we just made the loss here is the absolute value of the difference between the gown truth value and the prediction according to the definition now it cannot be negative but the loss function is up to you say if the loss function today is the above mentioned absolute value minus 100 then it may have negative values i have to remind you about the curve here it is not of any real loss functions it's a random curve from the internet as an example the reason is that i want to give a more general example it is not an error surface from any real tasks so this loss curve this error surface can have any shapes there is no presumption regarding the shape of a loss curve but from the from the definition of the loss here it cannot be negative since it outputs absolute values but the loss because this function is up to you it may be negative since someone raised a question here we should pause for now see if you have any questions in the future the tas will help me watch the live stream on youtube please read out the questions during the live stream for me if there are any help me read those questions we will first move on with the session until the session comes to an end we will answer those questions i'll ask again does any of you have questions here great if not please let me continue ok where were we we just talked about hyperparameters they should be set manually so in machine learning those you have to set manually are called hyper parameters we say we are gonna move w0 one step to the right then this new position is called w1 the step size is eta multiplied by the differential to express it in a mathematical formula it is w0 minus eta times the derivative which is w1 then you just repeat the operation done before calculate the differential of w0 and then decide how far to move w0 then move it to w2 then you continue to do the same operation over and over again keep moving the position of w in the end you will stop when will it stop there are often two situations the first situation is that you lost patience in the beginning you will set up a limit when you are adjusting your parameters calculating differentials i only calculate limited times you might set the upper limit to 1 million times hence after updating the parameters 1 million times i won't update them anymore as for how many times i should update this is also a hyperparameter this is up to you if the deadline is tomorrow you may update fewer times you may set it up a little more if the deadline is next week there is another ideal stopping situation when we keep adjusting the parameters we arrive at some places where its differential which is this term exactly equals zero if this term is exactly zero zero times the learning rate eta remains zero so your parameters will not move their position anymore suppose we are in this ideal situation we update w0 to w1 and then update it to w2 in the end we update it to wt with a bit stuck we stuck at wt that is the differential is zero the position of the parameter will not be updated anymore on this point you might find out that gradient descent has a huge problem this huge problem in this example is obvious that is we do not find the real best solution we don't find the w which can minimize the loss in this example by setting w to this place you can minimize the loss however if gradient descent starts from this place as a random initial position the training is likely to stop when you arrive here you can't move the position of w anymore this position this is really the place where loss is the smallest it is called global minima this place is called local minima the loss of its left and right sides are a bit higher than itself but it is not the lowest point on the entire error surface this thing is called local minima so you may often hear someone saying that gradient descent isn't a good method this method has the problem of local minima there is no guarantee to find the real global minima but textbooks often say this content farms often say this but this is actually just an illusion in fact if you have done something related to deep learning or you have trained your own network or you have done gradient descent by yourself local minima is actually a non-issue when we were doing gradient descent the real problem we confronted is not local minima then what is it we will talk about it later temporarily you just believe what most people say gradient descent has a problem with local minima in this example it is obvious that there is a local minima problem but later i will tell you what gradient to sense real pain points exactly r the things mentioned above is an example with only one parameter actually our model has two parameters w and b how to use gradient descent under the situation of two parameters in fact it is no different from the situation of a single parameter if you have no problem with one parameter you can quickly generalize to two parameters we have two parameters now then we give it two parameters we give them random initial values w0 and b0 then what's next you have to calculate the differential of loss with respect to w you have to calculate the differential of loss with respect to b calculate at the position where w is equal to w0 where b is equal to b0 where w is equal to w0 where b is equal to b0 you have to calculate the differential of l with respect to w calculate the derivative of l with respect to b after calculating according to the method that we have just used with one parameter we update w and b subtract the learning rate from w0 multiply the result of the differentiation to get w1 subtract the learning rate from b0 multiply the result of the differentiation to get b1 some students might want to know how to calculate this differentiation if you can't calculate the differentiation don't be worried why don't you be worried about it in the framework of deep learning or in our homework 1 with the package pi torch that will be used the calculations of differentiation are automatically calculated you can write only a line of code and the results of the differentiation would be calculated automatically even if you don't know what you are doing you can still get the results of the differentiation here even if you don't know what differentiation is don't worry this step can be done in one line when doing homework 1 you can try it by yourself repeat the same procedures keep updating w and b and expect that at the end you can find the best w w star and the best b b star here is an example we would show everyone that suppose on this question how we do it suppose that you choose a random initial point here first you calculate the partial derivative of l with respect to w and calculate the partial derivative of l with respect to b then you update w and b the direction of the update is the partial derivative of l with respect to w multiplied by eta and added a negative sign and the partial derivative of l with respect to b multiplied by eta and added by a negative sign after calculating the derivatives you can decide the direction of the update you can decide how to update w how to update w combining the update directions of w and b we can get a vector which is this red arrow we move from this position to this position then calculating the derivatives again you can decide which direction to update after multiplying the values of partial derivatives by the learning rate and adding a negative sign you can know where the red arrow will point you can know how to move the positions of w and b keep moving and moving expect that you can find a good pair of w and b in the end after using gradient descent and doing some calculations we get the actual result the best w calculated by us is 0.
97 the best b is 100. it's very close to our guess because the value of x may be very close to y this w is set to a value close to 1. and b is set to a relatively small value how big is the loss the calculated loss is 480.
that is on the data from 2017 to 2020. if you use this function setting b to be 100 and w to be 970. the average error is 480.
this means that the error of the predicted number of views is about 500 times until now we have talked about the three steps of machine learning first write a function there are unknown parameters in this function second define a function called loss third solve an optimization problem find a pair of w and b to minimize the loss the values of w and b found just now can make the loss as small as 480. but is it a satisfying or commendable result maybe not why because the procedure of these three steps is called training we are now using the data with known answers to calculate the loss data from 2017 to 2020 are those we have already known the answers to we have already known that from 2017 to 2020 how many views per day so in fact we are just getting hyper by ourselves just pretending we don't know the number of views on the next day we use this function to make predictions finding that the error is 480. but is the number of views that are already known what we really care about no what we really care about are the things we don't know which is the number of views in the future so what are we going to do next we will take this function and use it to predict the number of views in the future here we only have data from 2017 to 2020.
on the last day of 2020 new year's eve we found this function starting from the first day of 2021. we apply this function to predict the number of views on the next day we use the number of views on december 31 2022 predict the number of views on new year's day in 2021 we use the number of views on new year's day two predict the views on the day after new year's day which is january 2nd use the number of views on january 2nd to predict the views on january 3rd we do this every day until february 14. until valentine's day then we get the value for the average error what is the average error this is the result of real-world data on 2021's data which has not been seen before this error we denote it as l prime is 0.
58 so on data that have been seen on training data the error is relatively small on data that have not been seen on 2021's data it seems that the error is larger so our average error per day is about 580 people around 600 people can we do better before we do anything let's analyze the results first how do you interpret this graph the horizontal axis of this graph represents time so the leftmost point at 0 represents january 1 2021. the rightmost point represents february 14 2021 the vertical axis is the number of views in thousands what does the red line represent the red line is the actual number of views the blue line is the number of views predicted by the machine using this function you can see very clearly that there is nothing magical about this blue line it's almost the same as shifting the red line to the right by one day it didn't really make any powerful predictions it simply shifted the red line to the right by one day this is reasonable because we think the relationship between x1 the number of views on the previous day and the views on the next day how did we use the number of views on the previous day to predict the number of views on the next day we multiplied the number of views the day before by 0. 97 then plus 0.
1 k 100 and obtain the number of views on the next day so you will find out that the machine almost just took the views from the previous day to predict the views on the next day but if you look closely at this graph you will see there's some special phenomenon in this real-world data it is periodic it has an interesting periodicity do you know what the pattern is the views become very low for two days every seven days two days when the views are very low what days are those two days i found out that those two days are fixed they're fridays and saturdays i can understand on friday and saturday everyone will go out because it's the weekend who needs to learn machine learning who wants to learn machine learning on saturday but i don't know why everybody goes to learn machine learning on sunday i haven't understood why this happened maybe it's because of youtube's magical algorithm for instance youtube will recommend videos maybe when youtube is recommending videos on the channel it chooses not to recommend them on fridays and saturdays but only on sundays through thursdays but why on sundays through thursdays i haven't understood that either but anyway when we look at the results it's like this a cycle every seven days every friday and saturday there are very few people watching since we already know that every seven days is a cycle this formula this model obviously sucks because it can only see the day before if the cycles occur every seven days we should look at seven days at once right suppose we have a model it refers to the data from the previous seven days it copies the data from the previous seven days as the predicted result maybe the prediction will be more accurate so we have to modify our model usually the modification of the model often comes from your understanding of this problem which is domain knowledge so in the beginning when we don't understand the problem at all we just write one randomly y is equal to b plus wx1 which doesn't perform very well next after observing the real data we conclude that there is a cycle every seven days so we should take views in the first seven days into consideration thus we wrote a new model what does this model look like this model is that y is equal to b plus xj what does xj stand for this subscript j represents how many days ago this j is equal to from one to seven that is from one day ago two days ago continue to seven days ago for all the data in these seven days we multiply them by different weights that is we multiply them by different wj then we add them up and plus bias to get the predicted result if this is our model what is the result we got our loss on the training data is 0. 38 k that's because here we only consider one day here we consider seven days so on the training data you will get a lower loss here we consider more information so you should get better on the training data that is you have a lower loss here the loss is 0. 38 k but on the unseen data can the model do well on the unseen data it is better the loss is 0.
49 k so if only consider one day the loss is 0. 58 k while considering 7 days the loss is 0. 49 k for every w and b here we all use gradient descent to calculate its optimal value what does its optimal value look like we show it here we show you what its best value looks like of course i can't fully understand the logic of the machine i thought it would select data from seven days ago copy the number of viewers seven days ago directly i don't think it selects like this its logic is that the previous day has a lot to do with the value of the next day you want to predict so w 1 star is 0.
79 i don't know why it's still considered the previous three days the w for the previous three days is 0. 12 the w for the previous 6 days is 0. 3 the w for the previous 7 days is 0.
18 but it knows if it is the previous two four or five days its value will be inversely proportional to what we have to predict in the future so for w2w4 and w5 their optimal values which let loss on the training data be 0. 38 k is negative while w1w3w6 and w7 are positive we consider the value of the previous seven days then you might ask whether it's possible to consider more days yes it's possible we can make an easy change to consider more days originally we considered the first seven days then what happens when considering 28 days 28 days are equal to a month we use the number of people watched each day in the previous month to predict the number of viewers the next day what is the predicted result the loss on the training data is 0. 33 k on the 2021's data the loss is 0.
46 k on the unseen data the performance looks better in 28 days okay then what will happen when considering 56 days the performance is slightly better on the training data the loss is 0. 32 k the loss is still 0.