{"id":2915,"date":"2021-09-06T10:06:43","date_gmt":"2021-09-06T13:06:43","guid":{"rendered":"https:\/\/waisdata.com\/?post_type=blog-wais&#038;p=2915"},"modified":"2021-10-19T15:42:21","modified_gmt":"2021-10-19T18:42:21","slug":"modelos-de-regresion-desde-cero","status":"publish","type":"blog-wais","link":"https:\/\/waisdata.com\/en\/blog-wais\/modelos-de-regresion-desde-cero\/","title":{"rendered":"Regression models from scratch"},"content":{"rendered":"<div data-elementor-type=\"wp-post\" data-elementor-id=\"2915\" class=\"elementor elementor-2915\" data-elementor-settings=\"[]\">\n\t\t\t\t\t\t<div class=\"elementor-inner\">\n\t\t\t\t\t\t\t<div class=\"elementor-section-wrap\">\n\t\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-39eeab4 elementor-section-full_width elementor-section-height-default elementor-section-height-default\" data-id=\"39eeab4\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t\t\t<div class=\"elementor-row\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-b6e7a0a\" data-id=\"b6e7a0a\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-column-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-d07058b elementor-widget elementor-widget-heading\" data-id=\"d07058b\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Regression models from scratch<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-324c44a elementor-widget elementor-widget-heading\" data-id=\"324c44a\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">2021-09-06<\/h3>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-c89b15c elementor-section-full_width elementor-section-height-default elementor-section-height-default\" data-id=\"c89b15c\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t\t\t<div class=\"elementor-row\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-9386cc9\" data-id=\"9386cc9\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-column-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-110f8e9 elementor-widget elementor-widget-text-editor\" data-id=\"110f8e9\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"elementor-text-editor elementor-clearfix\"><h3>Motivation<\/h3><\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-934fc29 elementor-section-full_width elementor-section-height-default elementor-section-height-default\" data-id=\"934fc29\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t\t\t<div class=\"elementor-row\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-840f5ed\" data-id=\"840f5ed\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-column-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-0b99e23 elementor-widget elementor-widget-text-editor\" data-id=\"0b99e23\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"elementor-text-editor elementor-clearfix\">In the previous publication we explained the concept of Machine Learning and talked about Supervised Learning, among others.  The latter, in turn, can be divided into Regression or Classification problems depending on the nature of the problem. In this new document we will approach Regression problems from scratch starting with the simplest models and telling about the units of measurement used to evaluate these models.\n\nTranslated with www.DeepL.com\/Translator (free version)<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-07fadd5 elementor-section-full_width elementor-section-height-default elementor-section-height-default\" data-id=\"07fadd5\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t\t\t<div class=\"elementor-row\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-6943d42\" data-id=\"6943d42\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-column-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-60cdce1 elementor-widget elementor-widget-text-editor\" data-id=\"60cdce1\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"elementor-text-editor elementor-clearfix\"><h3>How to identify a Regression problem?<\/h3><\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-4712f80 elementor-section-full_width elementor-section-height-default elementor-section-height-default\" data-id=\"4712f80\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t\t\t<div class=\"elementor-row\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-aedbde6\" data-id=\"aedbde6\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-column-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-d23af87 elementor-widget elementor-widget-text-editor\" data-id=\"d23af87\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"elementor-text-editor elementor-clearfix\"><p>Regression is one of the key methods regularly used in data science to model relationships between variables, where the target variable (i.e. the value to be estimated) is a continuous number. Examples of Regression problems are:<\/p><ul><li>Forecast sales in the next period.<\/li><li>Predicting a student's grade in an exam.<\/li><li>Predicting the price of a property.<\/li><\/ul><\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-4e4bddc elementor-section-full_width elementor-section-height-default elementor-section-height-default\" data-id=\"4e4bddc\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t\t\t<div class=\"elementor-row\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-70cab28\" data-id=\"70cab28\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-column-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-6f8bd8a elementor-widget elementor-widget-text-editor\" data-id=\"6f8bd8a\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"elementor-text-editor elementor-clearfix\"><h3>Simple Linear Regression<\/h3><\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-97d35bb elementor-section-full_width elementor-section-height-default elementor-section-height-default\" data-id=\"97d35bb\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t\t\t<div class=\"elementor-row\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-f7fab54\" data-id=\"f7fab54\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-column-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-f67cd92 elementor-widget elementor-widget-text-editor\" data-id=\"f67cd92\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"elementor-text-editor elementor-clearfix\"><p>Regression analysis consists of finding a function (F(X)), under a given set of assumptions, that best describes the relationship between the dependent variable (Y) and the independent variable (X).<\/p><p>When the number of independent variables is only one and the relationship between the dependent and independent variable is assumed to be a straight line, the type of regression analysis is called simple linear regression. The straight line relationship is called a regression line or line of best fit.<\/p><p>How can the regression line be determined for a given data set? A common method used to determine the regression line is called the least squares method.<\/p><p>The simple linear regression equation is as follows:<\/p><p><em>Equation 1.0<\/em><\/p><p style=\"text-align: center;\"><em>y \u2248 B0 + B1*X<\/em><\/p><p><span style=\"font-weight: 400;\">where B0 and B1 are unknown constants, representing the intercept and slope of the regression line, respectively.<\/span><\/p><p><span style=\"font-weight: 400;\">The intercept is the value of the dependent variable (Y) when the independent variable (X) has a value of zero (0), or in other words, the value of the prediction in the absence of variables. The slope is a measure of how much the prediction value changes with a one-unit change in the independent variable, i.e. it measures the impact of the independent variable on the prediction. The unknown constants are called coefficients or parameters of the model.<\/span><\/p><p><span style=\"font-weight: 400;\">Calculating the difference between the actual value of the dependent variable and the predicted value of the dependent variable gives an error commonly referred to as the residual (Ei).<\/span><\/p><p><span style=\"font-weight: 400;\">By repeating this calculation for each data point in the sample, the residual (Ei) for each data point can be squared, to remove algebraic signs, and summed to obtain the sum of squares of the error (SSE). The least squares method seeks to minimise the SSE.<\/span><\/p><p><span style=\"font-weight: 400;\">Figure 1.1 explains graphically what is described above:<\/span><\/p><\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-0d4132d elementor-section-full_width elementor-section-height-default elementor-section-height-default\" data-id=\"0d4132d\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t\t\t<div class=\"elementor-row\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-b841983\" data-id=\"b841983\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-column-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-8ab8fe7 elementor-widget elementor-widget-text-editor\" data-id=\"8ab8fe7\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"elementor-text-editor elementor-clearfix\"><p><a href=\"https:\/\/waisdata.com\/wp-content\/uploads\/2021\/09\/simple_linear_regression_svg.svg\"><img class=\"size-full wp-image-2932 aligncenter\" src=\"https:\/\/waisdata.com\/wp-content\/uploads\/2021\/09\/simple_linear_regression_svg.svg\" alt=\"\" \/><\/a><\/p><\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-f635a45 elementor-section-full_width elementor-section-height-default elementor-section-height-default\" data-id=\"f635a45\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t\t\t<div class=\"elementor-row\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-229cdfd\" data-id=\"229cdfd\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-column-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-c9aed43 elementor-widget elementor-widget-text-editor\" data-id=\"c9aed43\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"elementor-text-editor elementor-clearfix\"><h3>Multiple Linear Regression\n<\/h3><\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-b9fbae9 elementor-section-full_width elementor-section-height-default elementor-section-height-default\" data-id=\"b9fbae9\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t\t\t<div class=\"elementor-row\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-630a89a\" data-id=\"630a89a\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-column-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-7353ef5 elementor-widget elementor-widget-text-editor\" data-id=\"7353ef5\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"elementor-text-editor elementor-clearfix\"><p>In the simple linear regression discussed above, we have only one independent variable. If we include multiple independent variables in our analysis, we obtain a multiple linear regression model. Multiple linear regression is represented in a similar way to simple linear regression.<\/p><p>Consideremos un caso en el que queremos ajustar un modelo de regresi\u00f3n lineal que tiene tres variables independientes, X1, X2 y X3. La f\u00f3rmula de la ecuaci\u00f3n de regresi\u00f3n lineal m\u00faltiple tendr\u00e1 el siguiente aspecto:<\/p><p>Equation 1.1<\/p><p style=\"text-align: center;\">y \u2248 B0 + B1*X1 + B2*X2 + B3*X3\u00a0<\/p><p>Each independent variable will have its own coefficient or parameter (i.e. B1 B2 or B3). The coefficient Bs tells us how a change in its respective independent variable influences the dependent variable if all other independent variables remain unchanged.<\/p><p>Multiple regression coefficients are estimated using the same least squares method as in simple linear regression. To satisfy the least squares method, the chosen coefficients must minimise the sum of the squared residuals.<\/p><\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-39c5b97 elementor-section-full_width elementor-section-height-default elementor-section-height-default\" data-id=\"39c5b97\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t\t\t<div class=\"elementor-row\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-7224517\" data-id=\"7224517\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-column-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-d639a73 elementor-widget elementor-widget-text-editor\" data-id=\"d639a73\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"elementor-text-editor elementor-clearfix\"><h3>Linear Regression Assumptions\n<\/h3><\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-2a94333 elementor-section-full_width elementor-section-height-default elementor-section-height-default\" data-id=\"2a94333\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t\t\t<div class=\"elementor-row\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-519579b\" data-id=\"519579b\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-column-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-33f1769 elementor-widget elementor-widget-text-editor\" data-id=\"33f1769\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"elementor-text-editor elementor-clearfix\"><p>We must bear in mind that in order to model reality using Linear Regression, there are certain assumptions that must be fulfilled for the estimation to obtain good results. In order not to make this publication too long, we will mention them without elaborating on them. These assumptions are:<\/p><ul><li>The relationship between the dependent and independent variables must be linear and additive.<\/li><li>The residual terms (Ei) must have a normal distribution.<\/li><li>The residual terms (Ei) must have constant variance (homoscedasticity).<\/li><li>The residual terms (Ei) must be uncorrelated.<\/li><li>There should be no correlation between the independent variables<\/li><\/ul><\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-06faec8 elementor-section-full_width elementor-section-height-default elementor-section-height-default\" data-id=\"06faec8\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t\t\t<div class=\"elementor-row\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-86f2faf\" data-id=\"86f2faf\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-column-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-1109252 elementor-widget elementor-widget-text-editor\" data-id=\"1109252\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"elementor-text-editor elementor-clearfix\"><h3>Evaluation metrics for regression problems\n<\/h3><\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-2a5a271 elementor-section-full_width elementor-section-height-default elementor-section-height-default\" data-id=\"2a5a271\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t\t\t<div class=\"elementor-row\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-f231b4a\" data-id=\"f231b4a\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-column-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-9251329 elementor-widget elementor-widget-text-editor\" data-id=\"9251329\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"elementor-text-editor elementor-clearfix\"><p>The main objective of regression analysis is to find a model that explains the observed variability in a dependent variable of interest. Therefore, it is very important to have a quantity that measures how well a regression model explains this variability. A statistic or metric that does this is called R-squared (R2). While there are other commonly used metrics, such as the RMSE, we will discuss the R2, as it is perhaps the most familiar to those with a basic knowledge of statistics. The formula for R2 is as follows:<\/p><p>Equation 1.2<\/p><p style=\"text-align: center;\">R2 = 1 \u2013 SSE\/SST\u00a0<\/p><ul><li>SSE = sum((real value - pred value)**2) = sum((Yi - Yi pred)**2<\/li><li>SST = sum((real value - mean value)**2) = sum((Yi - Y prom)**2)<\/li><li>SSR = sum((pred value - mean value)**2) = sum((Yi pred - Y mean)**2)<\/li><\/ul><p>The R-squared is the portion of variability explained by the model. In other words, it is the ratio of how good my model is compared to a model that always predicts the mean of the actual values. Therefore:<\/p><p>Equation 1.3<\/p><p style=\"text-align: center;\">R2 = 1 - (my model)\/(a model that always predicts the mean)<\/p><p>The R2 can take values less than or equal to 1 (R2 =&lt;1). This means that the closer the R-squared is to 1, the better the model will be (=1 is perfect). On the other hand, if I predict the mean, the R-squared value would be 0, since the SSE and the SST would be the same value so the division would be equal to 1, and 1 - 1 = 0. And finally, if R-squared is negative, it means that my model is worse than predicting the mean.<\/p><\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-f0fb4de elementor-section-full_width elementor-section-height-default elementor-section-height-default\" data-id=\"f0fb4de\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t\t\t<div class=\"elementor-row\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-1618a97\" data-id=\"1618a97\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-column-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-f704c82 elementor-widget elementor-widget-text-editor\" data-id=\"f704c82\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"elementor-text-editor elementor-clearfix\"><p>Up to this point we have seen when Regression models are applied and discussed Simple and Multiple Linear Regression along with an evaluation metric for these models. In future publications we will include more advanced models that are more widely used. <\/p><\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-835a94a elementor-section-full_width elementor-section-height-default elementor-section-height-default\" data-id=\"835a94a\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t\t\t<div class=\"elementor-row\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-ed4fa8c\" data-id=\"ed4fa8c\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-column-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-47aba25 elementor-widget elementor-widget-heading\" data-id=\"47aba25\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Published by<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-037712d elementor-widget elementor-widget-heading\" data-id=\"037712d\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">Wais<\/h3>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>","protected":false},"excerpt":{"rendered":"<p>Regression is one of the key methods regularly used in data science to model relationships between variables, where the variable to be estimated is a continuous number.<\/p>","protected":false},"author":13,"featured_media":2920,"comment_status":"open","ping_status":"closed","template":"","meta":{"site-sidebar-layout":"no-sidebar","site-content-layout":"page-builder","ast-global-header-display":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"disabled","ast-breadcrumbs-content":"","ast-featured-img":"disabled","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":""},"categories":[12],"tags":[],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v19.13 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>#WaisBlog: Modelos de Regresi\u00f3n desde cero | Ciencia de datos<\/title>\n<meta name=\"description\" content=\"La Regresi\u00f3n es uno de los m\u00e9todos clave que se utilizan regularmente en la ciencia de los datos, con el fin de modelar las relaciones entre las variables, donde la variable objetivo es un n\u00famero continuo\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/waisdata.com\/en\/blog-wais\/modelos-de-regresion-desde-cero\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"#WaisBlog: Modelos de Regresi\u00f3n desde cero | Ciencia de datos\" \/>\n<meta property=\"og:description\" content=\"La Regresi\u00f3n es uno de los m\u00e9todos clave que se utilizan regularmente en la ciencia de los datos, con el fin de modelar las relaciones entre las variables, donde la variable objetivo es un n\u00famero continuo\" \/>\n<meta property=\"og:url\" content=\"https:\/\/waisdata.com\/en\/blog-wais\/modelos-de-regresion-desde-cero\/\" \/>\n<meta property=\"og:site_name\" content=\"Wais\" \/>\n<meta property=\"article:modified_time\" content=\"2021-10-19T18:42:21+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/waisdata.com\/wp-content\/uploads\/2021\/09\/Modelos-de-regresion-desde-cero.svg\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/waisdata.com\/blog-wais\/modelos-de-regresion-desde-cero\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/waisdata.com\/blog-wais\/modelos-de-regresion-desde-cero\/\"},\"author\":{\"name\":\"Wais\",\"@id\":\"https:\/\/waisdata.com\/#\/schema\/person\/238aa97a70c2cb314a793d302e121db5\"},\"headline\":\"Modelos de Regresi\u00f3n desde cero\",\"datePublished\":\"2021-09-06T13:06:43+00:00\",\"dateModified\":\"2021-10-19T18:42:21+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/waisdata.com\/blog-wais\/modelos-de-regresion-desde-cero\/\"},\"wordCount\":1174,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/waisdata.com\/#organization\"},\"articleSection\":[\"Inteligencia artificial\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/waisdata.com\/blog-wais\/modelos-de-regresion-desde-cero\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/waisdata.com\/blog-wais\/modelos-de-regresion-desde-cero\/\",\"url\":\"https:\/\/waisdata.com\/blog-wais\/modelos-de-regresion-desde-cero\/\",\"name\":\"#WaisBlog: Modelos de Regresi\u00f3n desde cero | Ciencia de datos\",\"isPartOf\":{\"@id\":\"https:\/\/waisdata.com\/#website\"},\"datePublished\":\"2021-09-06T13:06:43+00:00\",\"dateModified\":\"2021-10-19T18:42:21+00:00\",\"description\":\"La Regresi\u00f3n es uno de los m\u00e9todos clave que se utilizan regularmente en la ciencia de los datos, con el fin de modelar las relaciones entre las variables, donde la variable objetivo es un n\u00famero continuo\",\"breadcrumb\":{\"@id\":\"https:\/\/waisdata.com\/blog-wais\/modelos-de-regresion-desde-cero\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/waisdata.com\/blog-wais\/modelos-de-regresion-desde-cero\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/waisdata.com\/blog-wais\/modelos-de-regresion-desde-cero\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Portada\",\"item\":\"https:\/\/waisdata.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Modelos de Regresi\u00f3n desde cero\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/waisdata.com\/#website\",\"url\":\"https:\/\/waisdata.com\/\",\"name\":\"Wais\",\"description\":\"Data driven solutions\",\"publisher\":{\"@id\":\"https:\/\/waisdata.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/waisdata.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/waisdata.com\/#organization\",\"name\":\"Wais Data Science\",\"url\":\"https:\/\/waisdata.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/waisdata.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/waisdata.com\/wp-content\/uploads\/2020\/10\/logo-wais600x600.svg\",\"contentUrl\":\"https:\/\/waisdata.com\/wp-content\/uploads\/2020\/10\/logo-wais600x600.svg\",\"caption\":\"Wais Data Science\"},\"image\":{\"@id\":\"https:\/\/waisdata.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/ar.linkedin.com\/company\/wais-data\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/waisdata.com\/#\/schema\/person\/238aa97a70c2cb314a793d302e121db5\",\"name\":\"Wais\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/waisdata.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/5cd57b55c506fa8638830ad7206866c8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/5cd57b55c506fa8638830ad7206866c8?s=96&d=mm&r=g\",\"caption\":\"Wais\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"#WaisBlog: Modelos de Regresi\u00f3n desde cero | Ciencia de datos","description":"La Regresi\u00f3n es uno de los m\u00e9todos clave que se utilizan regularmente en la ciencia de los datos, con el fin de modelar las relaciones entre las variables, donde la variable objetivo es un n\u00famero continuo","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/waisdata.com\/en\/blog-wais\/modelos-de-regresion-desde-cero\/","og_locale":"en_US","og_type":"article","og_title":"#WaisBlog: Modelos de Regresi\u00f3n desde cero | Ciencia de datos","og_description":"La Regresi\u00f3n es uno de los m\u00e9todos clave que se utilizan regularmente en la ciencia de los datos, con el fin de modelar las relaciones entre las variables, donde la variable objetivo es un n\u00famero continuo","og_url":"https:\/\/waisdata.com\/en\/blog-wais\/modelos-de-regresion-desde-cero\/","og_site_name":"Wais","article_modified_time":"2021-10-19T18:42:21+00:00","twitter_card":"summary_large_image","twitter_image":"https:\/\/waisdata.com\/wp-content\/uploads\/2021\/09\/Modelos-de-regresion-desde-cero.svg","twitter_misc":{"Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/waisdata.com\/blog-wais\/modelos-de-regresion-desde-cero\/#article","isPartOf":{"@id":"https:\/\/waisdata.com\/blog-wais\/modelos-de-regresion-desde-cero\/"},"author":{"name":"Wais","@id":"https:\/\/waisdata.com\/#\/schema\/person\/238aa97a70c2cb314a793d302e121db5"},"headline":"Modelos de Regresi\u00f3n desde cero","datePublished":"2021-09-06T13:06:43+00:00","dateModified":"2021-10-19T18:42:21+00:00","mainEntityOfPage":{"@id":"https:\/\/waisdata.com\/blog-wais\/modelos-de-regresion-desde-cero\/"},"wordCount":1174,"commentCount":1,"publisher":{"@id":"https:\/\/waisdata.com\/#organization"},"articleSection":["Inteligencia artificial"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/waisdata.com\/blog-wais\/modelos-de-regresion-desde-cero\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/waisdata.com\/blog-wais\/modelos-de-regresion-desde-cero\/","url":"https:\/\/waisdata.com\/blog-wais\/modelos-de-regresion-desde-cero\/","name":"#WaisBlog: Modelos de Regresi\u00f3n desde cero | Ciencia de datos","isPartOf":{"@id":"https:\/\/waisdata.com\/#website"},"datePublished":"2021-09-06T13:06:43+00:00","dateModified":"2021-10-19T18:42:21+00:00","description":"La Regresi\u00f3n es uno de los m\u00e9todos clave que se utilizan regularmente en la ciencia de los datos, con el fin de modelar las relaciones entre las variables, donde la variable objetivo es un n\u00famero continuo","breadcrumb":{"@id":"https:\/\/waisdata.com\/blog-wais\/modelos-de-regresion-desde-cero\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/waisdata.com\/blog-wais\/modelos-de-regresion-desde-cero\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/waisdata.com\/blog-wais\/modelos-de-regresion-desde-cero\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Portada","item":"https:\/\/waisdata.com\/"},{"@type":"ListItem","position":2,"name":"Modelos de Regresi\u00f3n desde cero"}]},{"@type":"WebSite","@id":"https:\/\/waisdata.com\/#website","url":"https:\/\/waisdata.com\/","name":"Wais","description":"Data driven solutions","publisher":{"@id":"https:\/\/waisdata.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/waisdata.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/waisdata.com\/#organization","name":"Wais Data Science","url":"https:\/\/waisdata.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/waisdata.com\/#\/schema\/logo\/image\/","url":"https:\/\/waisdata.com\/wp-content\/uploads\/2020\/10\/logo-wais600x600.svg","contentUrl":"https:\/\/waisdata.com\/wp-content\/uploads\/2020\/10\/logo-wais600x600.svg","caption":"Wais Data Science"},"image":{"@id":"https:\/\/waisdata.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/ar.linkedin.com\/company\/wais-data"]},{"@type":"Person","@id":"https:\/\/waisdata.com\/#\/schema\/person\/238aa97a70c2cb314a793d302e121db5","name":"Wais","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/waisdata.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/5cd57b55c506fa8638830ad7206866c8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5cd57b55c506fa8638830ad7206866c8?s=96&d=mm&r=g","caption":"Wais"}}]}},"_links":{"self":[{"href":"https:\/\/waisdata.com\/en\/wp-json\/wp\/v2\/blog-wais\/2915"}],"collection":[{"href":"https:\/\/waisdata.com\/en\/wp-json\/wp\/v2\/blog-wais"}],"about":[{"href":"https:\/\/waisdata.com\/en\/wp-json\/wp\/v2\/types\/blog-wais"}],"author":[{"embeddable":true,"href":"https:\/\/waisdata.com\/en\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/waisdata.com\/en\/wp-json\/wp\/v2\/comments?post=2915"}],"version-history":[{"count":15,"href":"https:\/\/waisdata.com\/en\/wp-json\/wp\/v2\/blog-wais\/2915\/revisions"}],"predecessor-version":[{"id":2939,"href":"https:\/\/waisdata.com\/en\/wp-json\/wp\/v2\/blog-wais\/2915\/revisions\/2939"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/waisdata.com\/en\/wp-json\/wp\/v2\/media\/2920"}],"wp:attachment":[{"href":"https:\/\/waisdata.com\/en\/wp-json\/wp\/v2\/media?parent=2915"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/waisdata.com\/en\/wp-json\/wp\/v2\/categories?post=2915"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/waisdata.com\/en\/wp-json\/wp\/v2\/tags?post=2915"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}