{"id":3377,"date":"2019-12-24T22:57:45","date_gmt":"2019-12-24T13:57:45","guid":{"rendered":"https:\/\/now0930.pe.kr\/wordpress\/?p=3377"},"modified":"2019-12-25T01:34:15","modified_gmt":"2019-12-24T16:34:15","slug":"linear-approxmation","status":"publish","type":"post","link":"https:\/\/now0930.pe.kr\/wordpress\/linear-approxmation\/","title":{"rendered":"linear approxmation"},"content":{"rendered":"\n<p>python\uc73c\ub85c \ub370\uc774\ud130\ub97c <a href=\"https:\/\/stackoverflow.com\/questions\/26109749\/how-to-perform-a-linear-approximation-and-get-linear-equation-from-an-array-of-data-in-python\">\uadfc\uc0ac \ud568\uc218\ub85c \ubc14\uafb8\ub294 \uba85\ub839<\/a>\uc774 \uc788\ub2e4. polyfit. \ub300\ubc15\uc774\ub2e4!<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Python 3.5.2 (default, Jul 10 2019, 11:58:48) \n[GCC 5.4.0 20160609] on linux\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n>>> import numpy as np\n>>> x=np.arange(0,4)\n>>> y=np.array([0,1,1.9,3.1])\n>>> np.polyfit(x,y,1)\narray([ 1.02, -0.03])\n>>> np.polyfit(x,y,2)\narray([0.05, 0.87, 0.02])<\/pre>\n\n\n\n<p>\uc778\ud130\ub137\uc5d0\uc11c \uad6c\ud55c sine \ub370\uc774\ud130\ub85c \uadfc\uc0ac \ud568\uc218\ub97c \uad6c\ud574\ubd10\uc57c \uaca0\ub2e4.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#_*_ coding: utf-8 _*_\nimport matplotlib\nmatplotlib.use('Agg')\n\nimport numpy as np\nfrom sklearn.preprocessing import PolynomialFeatures\n\nimport csv \nimport tensorflow as tf\nimport matplotlib.pyplot as plt \nimport pandas as pd\n\nfrom keras.models import Sequential\nfrom keras.layers import Dense\nfrom keras.layers import Dropout\nfrom keras.callbacks import ModelCheckpoint\n\nprint (\"Package Loaded\")\nprint (\"\ub370\uc774\ud130\ub85c \ud568\uc218 \uadfc\uc0ac\ud558\uae30\")\n\nipd = pd.read_csv(\".\/sine.csv\")\nprint (ipd.head())\nprint (ipd.shape)\n\n#column \uc120\ud0dd.\ntime=ipd.iloc[:,0].array\nsineValue=ipd.iloc[:,1].array\n#print(type(time))\n#print(time)\n#print(time)\n#print(sineValue)\napproxFunc = np.polyfit(time,sineValue,6, full=False)\nprint(approxFunc)\n<\/pre>\n\n\n\n<p>\ucc98\uc74c\uc5d0 5,000\uac1c\ub97c \ubaa8\ub450 \uc2dc\ud0a4\ub2c8 \uc560\uac00 \uc774\uc0c1\ud55c \uc9d3\uc744 \ud55c\ub2e4. \uc0ac\uc778 \uc6e8\uc774\ube0c \ud06c\uae30\uac00 1\uc774\uace0 0.001 \ub2e8\uc704\ub85c \ucabc\uac30\ub2e4. \ud30c\ub791\uc0c9 \uc120\uc774 \ub0b4\uac00 \uc608\uc0c1\ud55c \uadf8\ub9bc\uc778\ub370 \uc560\uac00 \uc791\uace0 \ub108\ubb34 \ud2f0 \uc548\ub098\uac8c \uadf8\ub838\ub2e4. \uc624\ucc28\ub97c \uc904\uc774\ub824 \ub178\ub825\ud558\ub2e4 \ubcf4\ub2c8 \uc544\ubb34\uac83\ub3c4 \uc544\ub2cc <a href=\"https:\/\/www.desmos.com\/calculator\">\uadf8\ub798\ud504<\/a>\ub97c \uadf8\ub838\ub2e4.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1918\" height=\"908\" src=\"https:\/\/i1.wp.com\/now0930.pe.kr\/wordpress\/wp-content\/uploads\/2019\/12\/graph1.png?fit=525%2C249&amp;ssl=1\" alt=\"\" class=\"wp-image-3382\" srcset=\"https:\/\/now0930.pe.kr\/wordpress\/wp-content\/uploads\/2019\/12\/graph1.png 1918w, https:\/\/now0930.pe.kr\/wordpress\/wp-content\/uploads\/2019\/12\/graph1-300x142.png 300w, https:\/\/now0930.pe.kr\/wordpress\/wp-content\/uploads\/2019\/12\/graph1-1024x485.png 1024w, https:\/\/now0930.pe.kr\/wordpress\/wp-content\/uploads\/2019\/12\/graph1-768x364.png 768w, https:\/\/now0930.pe.kr\/wordpress\/wp-content\/uploads\/2019\/12\/graph1-1536x727.png 1536w\" sizes=\"auto, (max-width: 1918px) 100vw, 1918px\" \/><\/figure>\n\n\n\n<p>\uc774\ubc88\uc5d0\ub294 \uc55e\uc5d0 \uba87 \uac1c \uc798\ub790\ub2e4.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">tf-docker \/home\/tensorflow\/tutorial\/ItnSensor > cat sine.csv\n0,0.841470985\n0.001,0.873736397\n0.002,0.90255357\n0.003,0.927808777\n0.004,0.949402346\n0.005,0.967249058\n0.006,0.98127848\n0.007,0.991435244\n0.008,0.997679266\n0.009,0.999985904\n0.01,0.998346054\n0.011,0.992766189\n0.012,0.983268329\n0.013,0.969889958\n0.014,0.952683874\n0.015,0.931717983\n0.016,0.907075026\n0.017,0.878852258\n0.018,0.847161063\n0.019,0.812126509\n0.02,0.773886863\n0.021,0.73259304\n0.022,0.688408006\n0.023,0.64150614\n0.024,0.592072543\n0.025,0.540302306\n0.026,0.486399742\n0.027,0.430577581\n0.028,0.373056127\n0.029,0.314062391\n0.03,0.253829194\n0.031,0.192594249\n0.032,0.130599223<\/pre>\n\n\n\n<p>\uc774\ub807\uac8c \ud558\uba74 \uc880 \ube44\uc2b7\ud558\uac8c \uadf8\ub9b0\ub2e4. \uc785\ub825\uc73c\ub85c \uc900 \uc218\uce58\uac00 (0.032, 0.1305..)\uc5d0\uc11c \ub04a\uc5b4\uc838 \uc560\ub294 \ub05d\uae4c\uc9c0 \uc544\ub798\ub85c \uac04\ub2e4\uace0 \uc0dd\uac01\ud558\ub098 \ubcf4\ub2e4.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"842\" src=\"https:\/\/now0930.pe.kr\/wordpress\/wp-content\/uploads\/2019\/12\/graph2.png\" alt=\"\" class=\"wp-image-3383\" srcset=\"https:\/\/now0930.pe.kr\/wordpress\/wp-content\/uploads\/2019\/12\/graph2.png 600w, https:\/\/now0930.pe.kr\/wordpress\/wp-content\/uploads\/2019\/12\/graph2-214x300.png 214w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/figure>\n\n\n\n<p>\ud2b9\uc815 \ubd80\ubd84\uc744 \ubcf4\uace0 \ud2b9\uc9d5\uc744 \ubf51\uc544\ub0b4\uc57c \ud558\ub294\ub370, \uadf8\ub0e5 \uc778\uacf5\uc9c0\ub2a5 \ud558\ub098 \ub9cc\ub4e4\uc5b4\uc11c \ud558\ub294\uac8c \ub0ab\ub2e4. \uc5d0\ub7ec, \uc815\ud655\ub3c4\uac00 \uc5bc\ub9c8\uc778\uc9c0\ub3c4 \ubaa8\ub974\uaca0\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>python\uc73c\ub85c \ub370\uc774\ud130\ub97c \uadfc\uc0ac \ud568\uc218\ub85c \ubc14\uafb8\ub294 \uba85\ub839\uc774 \uc788\ub2e4. polyfit. \ub300\ubc15\uc774\ub2e4! \uc778\ud130\ub137\uc5d0\uc11c \uad6c\ud55c sine \ub370\uc774\ud130\ub85c \uadfc\uc0ac \ud568\uc218\ub97c \uad6c\ud574\ubd10\uc57c \uaca0\ub2e4. \ucc98\uc74c\uc5d0 5,000\uac1c\ub97c \ubaa8\ub450 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[12],"tags":[709,110,710],"class_list":["post-3377","post","type-post","status-publish","format-standard","hentry","category-12","tag-linear-approximation","tag-python","tag-710"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/posts\/3377","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/comments?post=3377"}],"version-history":[{"count":5,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/posts\/3377\/revisions"}],"predecessor-version":[{"id":3385,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/posts\/3377\/revisions\/3385"}],"wp:attachment":[{"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/media?parent=3377"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/categories?post=3377"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/tags?post=3377"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}