choosing the right model and learning algorithm now that we have first impression of the datawe return to the initial questionhow long will our server handle the incoming web trafficto answer this we have tofind the real model behind the noisy data points use the model to extrapolate into the future to find the point in time where our infrastructure has to be extended before building our first model when we talk about modelsyou can think of them as simplified theoretical approximations of the complex reality as such there is always some inferiority involvedalso called the approximation error this error will guide us in choosing the right model among the myriad of choices we have this error will be calculated as the squared distance of the model' prediction to the real data that isfor learned model functionfthe error is calculated as followsdef error(fxy)return sp sum(( ( )- )** the vectors and contain the web stats data that we have extracted before it is the beauty of scipy' vectorized functions that we exploit here with (xthe trained model is assumed to take vector and return the results again as vector of the same size so that we can use it to calculate the difference to starting with simple straight line let us assume for second that the underlying model is straight line the challenge then is how to best put that line into the chart so that it results in the smallest approximation error scipy' polyfit(function does exactly that given data and and the desired order of the polynomial (straight line has order )it finds the model function that minimizes the error function defined earlier fp residualsranksvrcond sp polyfit(xy full=truethe polyfit(function returns the parameters of the fitted model functionfp and by setting full to truewe also get additional background information on the fitting process of itonly residuals are of interestwhich is exactly the error of the approximation print("model parameters%sfp model parameters