{"id":9953,"date":"2020-07-10T10:25:25","date_gmt":"2020-07-10T01:25:25","guid":{"rendered":"http:\/\/www.gisdeveloper.co.kr\/?p=9953"},"modified":"2020-07-14T08:49:51","modified_gmt":"2020-07-13T23:49:51","slug":"%eb%8b%a8%ec%88%9c-%ec%84%a0%ed%98%95-%ed%9a%8c%ea%b7%80%ec%97%90-%eb%8c%80%ed%95%9c-2%ea%b0%80%ec%a7%80-%ec%a0%91%ea%b7%bc","status":"publish","type":"post","link":"http:\/\/www.gisdeveloper.co.kr\/?p=9953","title":{"rendered":"\ub2e8\uc21c \uc120\ud615 \ud68c\uadc0\uc5d0 \ub300\ud55c 2\uac00\uc9c0 \uc811\uadfc"},"content":{"rendered":"<p>\uc7a1\uc74c\uc774 \uc11e\uc778 \uc0d8\ud50c \ub370\uc774\ud130\uac00 \uc120\ud615\uc774\ub77c\uace0 \uac00\uc815\ud560\ub54c, \uc774 \uc120\ud615 \ubaa8\ub378\uc740 \uae30\uc6b8\uae30\uc640 \uc808\ud3b8\uc774\ub77c\ub294 \uac12\uc73c\ub85c \uc815\uc758\ub429\ub2c8\ub2e4. \uc774 \uae30\uc6b8\uae30\uc640 \uc808\ud380\uc5d0 \ub300\ud55c \uac12\uc744 \uad6c\ud558\ub294 \ubc29\ubc95\uc740 \ub2e4\uc591\ud55c\ub370, \uc774 \uae00\uc5d0\uc11c\ub294 2\uac00\uc9c0 \uc811\uadfc \ubc29\ubc95\uc744 \uc5b8\uae09\ud569\ub2c8\ub2e4. \uba3c\uc800 \uc7a1\uc74c\uc774 \uc11e\uc778 \uc0d8\ud50c \ub370\uc774\ud130\ub294 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\n\r\nX = 10 * np.random.rand(100,1)\r\ny = 3.7 - 2.5 * X + np.random.randn(100,1)\r\nplt.scatter(X, y)\r\nplt.show()\r\n<\/pre>\n<p>\uc704\uc758 \ucf54\ub4dc\ub294 \uc0d8\ud50c \ub370\uc774\ud130\uc5d0 \ub300\ud55c \uc2dc\uac01\ud654 \ucf54\ub4dc\ub3c4 \ud3ec\ud568\ud558\uace0 \uc788\ub294\ub370, \uadf8 \uacb0\uacfc\ub294 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gisdeveloper.co.kr\/wp-content\/uploads\/2020\/07\/simple_linear_reg_1.png\" alt=\"\" width=\"1190\" height=\"888\" class=\"aligncenter size-full wp-image-9954\" \/><\/p>\n<p>\uc774\uc81c \uc704\uc758 \uc0d8\ud50c \ub370\uc774\ud130\uc5d0 \ub300\ud55c \uc120\ud615\ud68c\uadc0 \ubc29\ubc95 \uc911 \ud558\ub098\uc778 \uc815\uaddc\ubc29\uc815\uc2dd(Normal Equation)\uc5d0 \ub300\ud55c \ucf54\ub4dc\ub294 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">\r\nX_b = np.c_[np.ones((100,1)), X]\r\nw = np.linalg.inv(X_b.T.dot(X_b)).dot(X_b.T).dot(y)\r\nprint(w)\r\n\r\nplt.scatter(X, y)\r\ndrawLine(w[1], w[0])\r\nplt.show()\r\n<\/pre>\n<p>\ubd84\uc11d\ub41c \uc808\ud3b8\uacfc \uae30\uc6b8\uae30\uc5d0 \ub300\ud55c \ucd9c\ub825 \ubc0f \uacb0\uacfc \ubaa8\ub378\uc758 \uc120\ud615\uc740 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<pre class='code'>\r\n[[ 3.76686801]\r\n [-2.50677558]]\r\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gisdeveloper.co.kr\/wp-content\/uploads\/2020\/07\/simple_linear_reg_ne.png\" alt=\"\" width=\"1178\" height=\"897\" class=\"aligncenter size-full wp-image-9957\" \/><\/p>\n<p>\uc544\uc6b8\ub7ec \uc815\uaddc\ubc29\uc815\uc2dd\uc740 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<p><center><\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 26px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gisdeveloper.co.kr\/wp-content\/ql-cache\/quicklatex.com-6fca36ac9d1690600e7ca732b1067752_l3.png\" height=\"26\" width=\"130\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#36;&#36;&#40;&#88;&#94;&#123;&#84;&#125;&#88;&#41;&#94;&#123;&#45;&#49;&#125;&#88;&#94;&#123;&#84;&#125;&#121;&#36;&#36;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p><\/center><\/p>\n<p>\ub2e4\uc74c\uc740 \uc0ac\uc774\ud0b7\ub7f0\uc5d0\uc11c \uc81c\uacf5\ud558\ub294 LinearRegression \ud074\ub798\uc2a4\ub97c \uc774\uc6a9\ud55c \ubc29\ubc95\uc785\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">\r\nfrom sklearn.linear_model import LinearRegression\r\nmodel = LinearRegression()\r\nmodel.fit(X, y)\r\nw = [model.intercept_[0], model.coef_[0][0]]\r\nprint(w)\r\n\r\nplt.scatter(X, y)\r\ndrawLine(w[1], w[0])\r\nplt.show()\r\n<\/pre>\n<p>\ubd84\uc11d\ub41c \uc808\ud3b8\uacfc \uae30\uc6b8\uae30\uc5d0 \ub300\ud55c \ucd9c\ub825 \ubc0f \uacb0\uacfc \ubaa8\ub378\uc758 \uc120\ud615\uc740 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<pre class='code'>\r\n[[ 3.69686801]\r\n [-2.50677558]]\r\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gisdeveloper.co.kr\/wp-content\/uploads\/2020\/07\/simple_linear_reg_sk.png\" alt=\"\" width=\"1165\" height=\"896\" class=\"aligncenter size-full wp-image-9958\" \/><\/p>\n<p>\uc704\uc758 \ucf54\ub4dc\uc5d0\uc11c \uc808\ud3b8\uacfc \uae30\uc6b8\uae30\ub97c \ud1b5\ud574 \uadf8\ub798\ud504\ub97c \uadf8\ub9ac\ub294 \ud568\uc218\uc778 drawLine\uc740 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">\r\ndef drawLine(m, b):\r\n    X = np.arange(0, 11)\r\n    y = [m * x + b for x in X]\r\n    plt.plot(X, y)\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\uc7a1\uc74c\uc774 \uc11e\uc778 \uc0d8\ud50c \ub370\uc774\ud130\uac00 \uc120\ud615\uc774\ub77c\uace0 \uac00\uc815\ud560\ub54c, \uc774 \uc120\ud615 \ubaa8\ub378\uc740 \uae30\uc6b8\uae30\uc640 \uc808\ud3b8\uc774\ub77c\ub294 \uac12\uc73c\ub85c \uc815\uc758\ub429\ub2c8\ub2e4. \uc774 \uae30\uc6b8\uae30\uc640 \uc808\ud380\uc5d0 \ub300\ud55c \uac12\uc744 \uad6c\ud558\ub294 \ubc29\ubc95\uc740 \ub2e4\uc591\ud55c\ub370, \uc774 \uae00\uc5d0\uc11c\ub294 2\uac00\uc9c0 \uc811\uadfc \ubc29\ubc95\uc744 \uc5b8\uae09\ud569\ub2c8\ub2e4. \uba3c\uc800 \uc7a1\uc74c\uc774 \uc11e\uc778 \uc0d8\ud50c \ub370\uc774\ud130\ub294 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4. import numpy as np import matplotlib.pyplot as plt X = 10 * np.random.rand(100,1) y = 3.7 &#8211; 2.5 * X + &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.gisdeveloper.co.kr\/?p=9953\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;\ub2e8\uc21c \uc120\ud615 \ud68c\uadc0\uc5d0 \ub300\ud55c 2\uac00\uc9c0 \uc811\uadfc&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[131,132],"tags":[],"class_list":["post-9953","post","type-post","status-publish","format-standard","hentry","category-python","category-deep-machine-learning"],"_links":{"self":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/9953","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9953"}],"version-history":[{"count":10,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/9953\/revisions"}],"predecessor-version":[{"id":9980,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/9953\/revisions\/9980"}],"wp:attachment":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9953"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9953"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9953"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}