{"id":455,"date":"2020-04-04T18:29:39","date_gmt":"2020-04-04T09:29:39","guid":{"rendered":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=455"},"modified":"2020-04-04T18:29:39","modified_gmt":"2020-04-04T09:29:39","slug":"%eb%8b%a4%ec%a4%91-%ec%84%a0%ed%98%95-%ed%9a%8c%ea%b7%80multiple-linear-regression","status":"publish","type":"post","link":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=455","title":{"rendered":"\ub2e4\uc911 \uc120\ud615 \ud68c\uadc0(multiple linear regression)"},"content":{"rendered":"<h1>\ub2e4\uc911 \uc120\ud615 \ud68c\uadc0(multiple linear regression)<\/h1>\n<p>\uc544\ud30c\ud2b8\uc758 \ud3c9\uc218\ub97c \uc774\uc6a9\ud574 \uc544\ud30c\ud2b8\uc758 \ub9e4\ub9e4\uac00\ub97c \uc608\uce21\ud574 \ubcf4\uc558\ub294\ub370\uc694. \uc544\ud30c\ud2b8\ub294 \ub2e8\uc21c\ud788 \ud3c9\uc218\ub9cc\uc73c\ub85c \uac00\uaca9\uc774 \uc0b0\uc815\ub418\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4. \uc9c0\ud558\ucca0\uacfc\uc758 \uac70\ub9ac, \uc778\uadfc \ud559\uad70 \ub4f1, \uc5ec\ub7ec <code>\ud2b9\uc131(feature)<\/code> \uc744 \uace0\ub824\ud574\uc57c\ub9cc \uc801\uc815\ud55c \uc9d1\uac12\uc744 \uc0b0\uc815\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<p>\uc5ec\ub7ec \uac1c\uc758 \ud2b9\uc131(feature) \uc744 \uc785\ub825\ubc1b\uc544 \uacc4\uc0b0\ud558\uac8c \ub418\uba74 \uc218\uc2dd\uc740 \uc544\ub798\uc640 \uac19\uc774 \uc5ec\ub7ec\uac1c\uc758 <code>\uac00\uc911\uce58(weight)<\/code> \ub3c4 \uc788\uc5b4\uc57c \ud569\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-katex\">H(x_1, x_2, x_3, ..., x_n) = W_1x_1 + W_2x_2 + W_3x_3 + ... + W_nx_n + b<\/code><\/pre>\n<p>\uc544\ub798\uc5d0\uc11c, \ub9e8\ud558\ud134\uc758 \uc9d1\uc815\ubcf4 \ub370\uc774\ud0c0\ub97c \uc774\uc6a9\ud574 \uc784\ub300\ub8cc\ub97c \uc0b0\uc815\ud558\ub294 \ubc29\ubc95\uc744 \uc54c\uc544\ubd05\ub2c8\ub2e4.<\/p>\n<h2>\ub370\uc774\ud0c0\uc14b \uad6c\ud558\uae30<\/h2>\n<p>\ub370\uc774\ud0c0\uc14b\uc740 <a href=\"https:\/\/github.com\/Codecademy\/datasets\">\uc5ec\uae30<\/a> \uc5d0\uc11c \uad6c\ud569\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">git clone https:\/\/github.com\/Codecademy\/datasets.git\nhead \/home\/ubuntu\/workspace\/datasets\/streeteasy\/manhattan.csv<\/code><\/pre>\n<p>\ub370\uc774\ud0c0\ub294 \uc544\ub798\uc640 \uac19\uc774 \uad6c\uc131\ub418\uc5b4 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<table>\n<thead>\n<tr>\n<th>\ud5e4\ub354<\/th>\n<th>\uc124\uba85<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>rental_id<\/code><\/td>\n<td>rental ID<\/td>\n<\/tr>\n<tr>\n<td><code>rent<\/code><\/td>\n<td>\uc784\ub300\ub8cc ($)<\/td>\n<\/tr>\n<tr>\n<td><code>bedrooms<\/code><\/td>\n<td>\uce68\uc2e4\uc218<\/td>\n<\/tr>\n<tr>\n<td><code>bathrooms<\/code><\/td>\n<td>\ud654\uc7a5\uc2e4\uc218<\/td>\n<\/tr>\n<tr>\n<td><code>size_sqft<\/code><\/td>\n<td>\ud3c9\uc218(feet)<\/td>\n<\/tr>\n<tr>\n<td><code>min_to_subway<\/code><\/td>\n<td>\uc9c0\ud558\ucca0\uacfc\uc758 \uac70\ub9ac (minutes)<\/td>\n<\/tr>\n<tr>\n<td><code>floor<\/code><\/td>\n<td>\uce35\uc218<\/td>\n<\/tr>\n<tr>\n<td><code>building_age_yrs<\/code><\/td>\n<td>\uac74\ubb3c \uc5f0\ub839<\/td>\n<\/tr>\n<tr>\n<td><code>no_fee<\/code><\/td>\n<td>\uc911\uacc4\uc218\uc218\ub8cc (0 for fee, 1 for no fee)<\/td>\n<\/tr>\n<tr>\n<td><code>has_roofdeck<\/code><\/td>\n<td>\uc625\uc0c1 (o for no, 1 for yes)<\/td>\n<\/tr>\n<tr>\n<td><code>has_washer_dryer<\/code><\/td>\n<td>\uc138\ud0c1\uae30\/\uac74\uc870\uae30 (0\/1)<\/td>\n<\/tr>\n<tr>\n<td><code>has_doorman<\/code><\/td>\n<td>\ub3c4\uc5b4\ub9e8 (0\/1)<\/td>\n<\/tr>\n<tr>\n<td><code>has_elevator<\/code><\/td>\n<td>\uc5d8\ub9ac\ubca0\uc774\ud130 (0\/1)<\/td>\n<\/tr>\n<tr>\n<td><code>has_dishwasher<\/code><\/td>\n<td>\uc2dd\uae30\uc138\ucc99\uae30 (0\/1)<\/td>\n<\/tr>\n<tr>\n<td><code>has_patio<\/code><\/td>\n<td>\uc548\ub9c8\ub2f9(patio) (0\/1)<\/td>\n<\/tr>\n<tr>\n<td><code>has_gym<\/code><\/td>\n<td>\ud5ec\uc2a4\uc7a5(gym)  (0\/1)<\/td>\n<\/tr>\n<tr>\n<td><code>neighborhood<\/code><\/td>\n<td>\uc774\uc6c3 (ex: \ud55c\uc778\ud0c0\uc6b4)<\/td>\n<\/tr>\n<tr>\n<td><code>submarket<\/code><\/td>\n<td>submarket (ex: North Brooklyn)<\/td>\n<\/tr>\n<tr>\n<td><code>borough<\/code><\/td>\n<td>borough (ex: Brooklyn)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\ud30c\uc774\uc36c\uc73c\ub85c \uad6c\ud604\ud558\uae30<\/h2>\n<p><code>sklearn<\/code> \ub77c\uc774\ube0c\ub7ec\ub9ac\ub97c \uc774\uc6a9\ud574 \uad6c\ud604\ud574 \ubd05\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-python\">from sklearn.linear_model import LinearRegression\nimport pandas as pd\nfrom sklearn.model_selection import train_test_split\n\ndf = pd.read_csv(&quot;\/home\/ubuntu\/workspace\/datasets\/streeteasy\/manhattan.csv&quot;)\n# df.head()\n\nX = df[[&#039;bedrooms&#039;,\n        &#039;bathrooms&#039;,\n        &#039;size_sqft&#039;,\n        &#039;min_to_subway&#039;,\n        &#039;floor&#039;,\n        &#039;building_age_yrs&#039;,\n        &#039;no_fee&#039;,\n        &#039;has_roofdeck&#039;,\n        &#039;has_washer_dryer&#039;,\n        &#039;has_doorman&#039;,\n        &#039;has_elevator&#039;,\n        &#039;has_dishwasher&#039;,\n        &#039;has_patio&#039;,\n        &#039;has_gym&#039;]]\ny = df[[&#039;rent&#039;]]\n\nX_train, X_test, y_train, y_test = train_test_split(X, y, train_size=0.8, test_size=0.2)\n\nmlr = LinearRegression()\nmlr.fit(X_train, y_train)\n\nmy_apartment = [[1, 1, 620, 16, 1, 98, 1, 0, 1, 0, 0, 1, 1, 0]]\nmlr.predict(my_apartment)\n# array([[2400.66691039]])\n\nmlr.score(X_test, y_test)\n# 0.7799479629374102<\/code><\/pre>\n<p><code>train_test_split<\/code> \uc744 \uc774\uc6a9\ud574 \ud559\uc2b5\uc14b(80%)\uacfc \ud14c\uc2a4\ud2b8\uc14b(20%)\uc744 \ubd84\ub9ac\ud569\ub2c8\ub2e4.<\/p>\n<p><code>predict<\/code> \ub97c \uc774\uc6a9\ud574 \uc0c8\ub85c\uc6b4 \ub370\uc774\ud0c0\ub97c \uc608\uce21\ud574 \ubcfc \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<p><code>score<\/code> \ub97c \uc774\uc6a9\ud574 \uc704 \ubaa8\ub378\uc758 \uc815\ud655\ub3c4\ub97c \uce21\uc815\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uc704\uc5d0\uc11c\ub294 78%\uc758 \uc815\ud655\ub3c4\ub97c \uac00\uc9d1\ub2c8\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\ub2e4\uc911 \uc120\ud615 \ud68c\uadc0(multiple linear regression) \uc544\ud30c\ud2b8\uc758 \ud3c9\uc218\ub97c \uc774\uc6a9\ud574 \uc544\ud30c\ud2b8\uc758 \ub9e4\ub9e4\uac00\ub97c \uc608\uce21\ud574 \ubcf4\uc558\ub294\ub370\uc694. \uc544\ud30c\ud2b8\ub294 \ub2e8\uc21c\ud788 \ud3c9\uc218\ub9cc\uc73c\ub85c \uac00\uaca9\uc774 \uc0b0\uc815\ub418\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4. \uc9c0\ud558\ucca0\uacfc\uc758 \uac70\ub9ac, \uc778\uadfc \ud559\uad70 \ub4f1, \uc5ec\ub7ec \ud2b9\uc131(feature) \uc744 \uace0\ub824\ud574\uc57c\ub9cc \uc801\uc815\ud55c \uc9d1\uac12\uc744 \uc0b0\uc815\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uc5ec\ub7ec \uac1c\uc758 \ud2b9\uc131(feature) \uc744 \uc785\ub825\ubc1b\uc544 \uacc4\uc0b0\ud558\uac8c \ub418\uba74 \uc218\uc2dd\uc740 \uc544\ub798\uc640 \uac19\uc774 \uc5ec\ub7ec\uac1c\uc758 \uac00\uc911\uce58(weight) \ub3c4 \uc788\uc5b4\uc57c \ud569\ub2c8\ub2e4. H(x_1, x_2, x_3, &#8230;, x_n) = W_1x_1 +\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=455\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[],"class_list":["post-455","post","type-post","status-publish","format-standard","hentry","category-ml"],"_links":{"self":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/455","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=455"}],"version-history":[{"count":1,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/455\/revisions"}],"predecessor-version":[{"id":456,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/455\/revisions\/456"}],"wp:attachment":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=455"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=455"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=455"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}