{"id":3426,"date":"2024-09-01T13:56:47","date_gmt":"2024-09-01T13:56:47","guid":{"rendered":"https:\/\/workhouse.sweetdishy.com\/?p=3426"},"modified":"2024-09-01T13:56:47","modified_gmt":"2024-09-01T13:56:47","slug":"linear-regression-supervised-learning-regression","status":"publish","type":"post","link":"https:\/\/workhouse.sweetdishy.com\/index.php\/2024\/09\/01\/linear-regression-supervised-learning-regression\/","title":{"rendered":"Linear Regression\u00a0(Supervised Learning\/Regression)"},"content":{"rendered":"\n<p id=\"Par164\">Linear&nbsp;regression&nbsp;shows the relationship between certain variables. The equation\u2014assuming there is enough quality data\u2014can help predict outcomes based on&nbsp;inputs.<\/p>\n\n\n\n<p>Example: Suppose we have data on the number of hours spent studying for an exam and the grade. See Table\u00a03-6.<\/p>\n\n\n\n<p><strong><em>Table 3-6.<\/em><\/strong><\/p>\n\n\n\n<p>Chart for hours of study and grades<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Hours of Study<\/th><th>Grade Percentage<\/th><\/tr><\/thead><tbody><tr><td>1<\/td><td>0.75<\/td><\/tr><tr><td>1<\/td><td>0.69<\/td><\/tr><tr><td>1<\/td><td>0.71<\/td><\/tr><tr><td>3<\/td><td>0.82<\/td><\/tr><tr><td>3<\/td><td>0.83<\/td><\/tr><tr><td>4<\/td><td>0.86<\/td><\/tr><tr><td>5<\/td><td>0.85<\/td><\/tr><tr><td>5<\/td><td>0.89<\/td><\/tr><tr><td>5<\/td><td>0.84<\/td><\/tr><tr><td>6<\/td><td>0.91<\/td><\/tr><tr><td>6<\/td><td>0.92<\/td><\/tr><tr><td>7<\/td><td>0.95<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>As you can see, the general\u00a0relationship\u00a0is positive (this describes the tendency where a higher\u00a0grade\u00a0is correlated with more hours of study). With the regression algorithm, we can plot a line that has the best fit (this is done by using a calculation called \u201cleast squares,\u201d which minimizes the errors). See Figure\u00a03-4.<\/p>\n\n\n\n<figure class=\"wp-block-image\" id=\"Fig4\"><img decoding=\"async\" src=\"https:\/\/learning.oreilly.com\/api\/v2\/epubs\/urn:orm:book:9781484250280\/files\/images\/480660_1_En_3_Chapter\/480660_1_En_3_Fig4_HTML.jpg\" alt=\"..\/images\/480660_1_En_3_Chapter\/480660_1_En_3_Fig4_HTML.jpg\"\/><figcaption class=\"wp-element-caption\"><strong><em>Figure 3-4.<\/em><\/strong>This is a plot of a&nbsp;linear regression&nbsp;model that is based on hours of study<\/figcaption><\/figure>\n\n\n\n<p id=\"Par167\">From this, we get the following equation:<\/p>\n\n\n\n<p id=\"Par168\">Grade = Number of hours of study \u00d7 0.03731 + 0.6889<\/p>\n\n\n\n<p id=\"Par169\">Then, let\u2019s suppose you study 4 hours for the&nbsp;exam&nbsp;. What will be your estimated grade? The equation tells us how:<\/p>\n\n\n\n<p id=\"Par170\">0.838 = 4 \u00d7 0.03731 + 0.6889<\/p>\n\n\n\n<p id=\"Par171\">How accurate is this? To help answer this question, we can use a calculation called R-squared. In our&nbsp;case, it is 0.9180 (this ranges from 0 to 1). The closer the value is to 1, the better the fit. So 0.9180 is quite high. It means that the hours of study explains 91.8% of the grade on the exam.<\/p>\n\n\n\n<p id=\"Par172\">Now it\u2019s true that this model is simplistic. To better reflect reality, you can add more variables to explain the grade on the exam\u2014say the student\u2019s attendance. When doing this, you will use something called multivariate&nbsp;regression&nbsp;.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Note<\/h3>\n\n\n\n<p id=\"Par173\">If the coefficient for a variable is quite small, then it might be a good idea to not include it in the model.<\/p>\n\n\n\n<p id=\"Par174\">Sometimes data may not be in a straight line either, in which case the regression algorithm will not&nbsp;work&nbsp;. But you can use a more complex version, called polynomial regression.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Linear&nbsp;regression&nbsp;shows the relationship between certain variables. The equation\u2014assuming there is enough quality data\u2014can help predict outcomes based on&nbsp;inputs. Example: Suppose we have data on the number of hours spent studying for an exam and the grade. See Table\u00a03-6. Table 3-6. Chart for hours of study and grades Hours of Study Grade Percentage 1 0.75 1 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3326,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[441],"tags":[],"class_list":["post-3426","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-3-machine-learning"],"jetpack_featured_media_url":"https:\/\/workhouse.sweetdishy.com\/wp-content\/uploads\/2024\/08\/images-41-1.jpeg","_links":{"self":[{"href":"https:\/\/workhouse.sweetdishy.com\/index.php\/wp-json\/wp\/v2\/posts\/3426","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/workhouse.sweetdishy.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/workhouse.sweetdishy.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/workhouse.sweetdishy.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/workhouse.sweetdishy.com\/index.php\/wp-json\/wp\/v2\/comments?post=3426"}],"version-history":[{"count":1,"href":"https:\/\/workhouse.sweetdishy.com\/index.php\/wp-json\/wp\/v2\/posts\/3426\/revisions"}],"predecessor-version":[{"id":3427,"href":"https:\/\/workhouse.sweetdishy.com\/index.php\/wp-json\/wp\/v2\/posts\/3426\/revisions\/3427"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/workhouse.sweetdishy.com\/index.php\/wp-json\/wp\/v2\/media\/3326"}],"wp:attachment":[{"href":"https:\/\/workhouse.sweetdishy.com\/index.php\/wp-json\/wp\/v2\/media?parent=3426"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/workhouse.sweetdishy.com\/index.php\/wp-json\/wp\/v2\/categories?post=3426"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/workhouse.sweetdishy.com\/index.php\/wp-json\/wp\/v2\/tags?post=3426"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}