{"id":236,"date":"2020-01-24T15:28:21","date_gmt":"2020-01-24T06:28:21","guid":{"rendered":"http:\/\/aiacademy.jp\/media\/?p=236"},"modified":"2024-08-08T16:31:03","modified_gmt":"2024-08-08T07:31:03","slug":"%e5%9b%9e%e5%b8%b0%e5%88%86%e6%9e%90%e3%81%a8%e3%81%af-%e5%8d%98%e5%9b%9e%e5%b8%b0%e3%81%a8%e9%87%8d%e5%9b%9e%e5%b8%b0%e3%81%ab%e9%96%a2%e3%81%97%e3%81%a6%e8%a7%a3%e8%aa%ac%ef%bc%81","status":"publish","type":"post","link":"https:\/\/aiacademy.jp\/media\/?p=236","title":{"rendered":"\u56de\u5e30\u5206\u6790\u3068\u306f\uff1f\u5358\u56de\u5e30\u3068\u91cd\u56de\u5e30\u306b\u95a2\u3057\u3066\u89e3\u8aac\uff01"},"content":{"rendered":"<div id=\"sgb-css-id-1\">\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button has-custom-font-size is-style-fill has-medium-font-size\"><a class=\"wp-block-button__link has-vivid-green-cyan-background-color has-background wp-element-button\" href=\"https:\/\/lin.ee\/3E4GzWk\" rel=\"nofollow noopener\" target=\"_blank\">LINE\u53cb\u3060\u3061\u767b\u9332 \u25b6 \u6a5f\u68b0\u5b66\u7fd2\u30b3\u30fc\u30b9 \u25b6 \u53d7\u8b1b\u5272\u5f15\u30af\u30fc\u30dd\u30f3 \u7121\u6599\u52d5\u753b<\/a><\/div>\n<\/div>\n<\/div>\n\n\n<p><\/p>\n\n\n<div class=\"toc\">    <div id=\"toc_container\" class=\"sgb-toc--no-bullets js-smooth-scroll\" data-dialog-title=\"Table of Contents\">\n      <p class=\"toc_title\">\u76ee\u6b21 <\/p>\n      <ul class=\"toc_list\">  <li class=\"first\">    <a href=\"#i-0\">\u306f\u3058\u3081\u306b<\/a>  <\/li>  <li>    <a href=\"#i-1\">\u56de\u5e30\u5206\u6790\u3068\u306f<\/a>  <\/li>  <li>    <a href=\"#i-2\">\u5358\u56de\u5e30\u3068\u91cd\u56de\u5e30\u306e\u9055\u3044<\/a>  <\/li>  <li>    <a href=\"#i-3\">\u5358\u56de\u5e30<\/a>  <\/li>  <li>    <a href=\"#i-4\">\u5358\u56de\u5e30\u306e\u5b9f\u88c5\u4f8b<\/a>  <\/li>  <li>    <a href=\"#i-5\">\u8a55\u4fa1\u65b9\u6cd5 \u6c7a\u5b9a\u4fc2\u6570(\u5bc4\u4e0e\u7387)<\/a>  <\/li>  <li>    <a href=\"#i-6\">\u91cd\u56de\u5e30<\/a>  <\/li>  <li>    <a href=\"#i-7\">\u91cd\u56de\u5e30\u306e\u5b9f\u88c5\u4f8b<\/a>  <\/li>  <li>    <a href=\"#i-8\">\u4f5c\u6210\u3057\u305f\u30d7\u30ed\u30b0\u30e9\u30e0<\/a>  <\/li>  <li>    <a href=\"#i-9\">\u307e\u3068\u3081<\/a>  <\/li>  <li class=\"last\">    <a href=\"#i-10\">\u308f\u304b\u3089\u306a\u3044\u3053\u3068\u3092\u6c17\u8efd\u306b\u8cea\u554f\u3067\u304d\u308b\u74b0\u5883\u3067\u5b66\u307c\u3046\uff01<\/a>  <\/li><\/ul>\n      \n    <\/div><\/div><div class=\"toc\"><p><\/p>\n<\/div><h2 id=\"i-0\">\u306f\u3058\u3081\u306b<\/h2>\n<p>\u3053\u306e\u7ae0\u3067\u306f\u3001Jupyter Notebook\u3067\u5b9f\u884c\u3059\u308b\u306e\u3092\u30aa\u30b9\u30b9\u30e1\u81f4\u3057\u307e\u3059\u3002<br>\nJupyter Notebook\u306e\u4f7f\u3044\u65b9\u306f<a href=\"https:\/\/aiacademy.jp\/texts\/show\/?id=80\">\u3053\u3061\u3089<\/a>\u3092\u3054\u78ba\u8a8d\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u307e\u305f\u3001\u3053\u306e\u7ae0\u3067\u306fscikit-learn 1.9\u7cfb\u3092\u5229\u7528\u3057\u307e\u3059\u3002<br>\nscikit-learn\u306e\u6700\u65b0\u30d0\u30fc\u30b8\u30e7\u30f3\u304c2\u7cfb\u306e\u5834\u5408\u52d5\u4f5c\u3057\u306a\u3044\u30b3\u30fc\u30c9\u304c\u3042\u308a\u307e\u3059\u306e\u3067\u3001<br>\n\u30a8\u30e9\u30fc\u304c\u8d77\u304d\u308b\u5834\u5408\u306f\u3001\u30d0\u30fc\u30b8\u30e7\u30f3\u30921.9(v0.19.1\u3084v0.19.2)\u306b\u4e0b\u3052\u3066\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2 id=\"i-1\">\u56de\u5e30\u5206\u6790\u3068\u306f<\/h2>\n<p>\u56de\u5e30\u5206\u6790\u3068\u306f\u3001\u30c7\u30fc\u30bf\u9593\u306e\u95a2\u4fc2\u6027\u3092\u4e00\u5b9a\u306e\u6570\u5f0f\u30fb\u516c\u5f0f\u3067\u3069\u308c\u304f\u3089\u3044\u8aac\u660e\u3067\u304d\u308b\u304b\u3092\u8abf\u3079\u308b\u5206\u6790\u624b\u6cd5\u3067\u3059\u3002<br>\n\u3053\u3053\u3067\u3001\u51fa\u3066\u304f\u308b\u7528\u8a9e\u3068\u3057\u3066\u3001\u76ee\u7684\u5909\u6570\u3068\u8aac\u660e\u5909\u6570\u304c\u3042\u308a\u307e\u3059\u3002<br>\n<strong>\u76ee\u7684\u5909\u6570\u306f\u30b4\u30fc\u30eb\u3068\u306a\u308b\u4e88\u6e2c\u3057\u305f\u3044\u30c7\u30fc\u30bf\u306e\u3053\u3068\u3067\u3059\u3002<\/strong><br>\n<strong>\u8aac\u660e\u5909\u6570\u306f\u4e88\u6e2c\u3057\u305f\u3044\u30c7\u30fc\u30bf\u306e\u8981\u56e0\u3068\u306a\u308b\u30c7\u30fc\u30bf\u306e\u3053\u3068\u3067\u3059\u3002<\/strong><br>\n\u5b9f\u969b\u306b\u8a08\u7b97\u5f0f\u3068\u3057\u3066\u306f\u3001\u5358\u56de\u5e30\u5f0f\u3092y=ax+b\u306e\u3088\u3046\u306b\u8868\u3059\u3053\u3068\u304c\u51fa\u6765\u3066\u3001y\u304c\u76ee\u7684\u5909\u6570\u3001x\u304c\u8aac\u660e\u5909\u6570\u3068\u306a\u308a\u307e\u3059\u3002<br>\n\u3061\u306a\u307f\u306b\u3001a\u306f\u56de\u5e30\u4fc2\u6570\u3068\u547c\u3070\u308c\u308b\u3082\u306e\u3067\u3059\u3002<\/p>\n<h2 id=\"i-2\">\u5358\u56de\u5e30\u3068\u91cd\u56de\u5e30\u306e\u9055\u3044<\/h2>\n<p><strong>\u5358\u56de\u5e30\u5206\u6790(\u7dda\u5f62)\u306f\u30011\u3064\u306e\u6570\u5024\u304b\u3089\u30b4\u30fc\u30eb\u3068\u306a\u308b1\u3064\u306e\u6570\u5024\u3092\u8aac\u660e\u3059\u308b\u5206\u6790\u3067\u3059\u3002<\/strong><br>\n\u4f8b\u3048\u3070\u3001\u30c6\u30ec\u30d3CM\u304b\u3089\u7372\u5f97\u5951\u7d04\u4ef6\u306a\u3069\u30011\u3064\u306e\u6570\u5024\u304b\u3089\u30b4\u30fc\u30eb\u3068\u306a\u308b1\u3064\u306e\u6570\u5024\u3092\u8aac\u660e\u3059\u308b\u306e\u304c\u3001\u5358\u56de\u5e30\u5206\u6790\u3067\u3059\u3002<br>\n\u305d\u3057\u3066\u3001<strong>\u91cd\u56de\u5e30\u5206\u6790\u306f\u3001\u30c6\u30ec\u30d3CM\u3084\u8ca9\u4fc3\u7269\u3001\u96d1\u8a8c\u306a\u3069\u8907\u6570\u306e\u6570\u5024\u304b\u3089\u30b4\u30fc\u30eb\u3068\u306a\u308b1\u3064\u306e\u6570\u5024(\u7372\u5f97\u5951\u7d04\u4ef6)\u3092\u8aac\u660e\u3059\u308b\u306e\u304c\u91cd\u56de\u5e30\u5206\u6790\u306b\u306a\u308a\u307e\u3059\u3002<\/strong><br>\n\u91cd\u56de\u5e30\u5206\u6790\u306f\u69d8\u3005\u306a\u30c7\u30fc\u30bf\u5206\u6790\u3067\u4f7f\u3046\u3053\u3068\u304c\u51fa\u6765\u307e\u3059\u3002<\/p>\n<h2 id=\"i-3\">\u5358\u56de\u5e30<\/h2>\n<p>\u5358\u56de\u5e30\u3068\u306f\u3001<strong><em>\u6559\u5e2b\u3042\u308a\u5b66\u7fd2\u306e\u4e00\u7a2e\u3067<\/em><\/strong>\u3001<strong><em>\u76ee\u7684\u5909\u6570\u304c\u5b9f\u6570\u5024<\/em><\/strong>\u306e\u624b\u6cd5\u3067\u3059\u3002<br>\n\u30d4\u30b6\u306e\u4f8b\u3067\u8003\u3048\u3066\u307f\u307e\u3057\u3087\u3046\u3002<br>\n\u3082\u3057\u3001\u3042\u306a\u305f\u304c\u300c\u30d4\u30b6\u306e\u76f4\u5f84\u300d\u304b\u3089\u300c\u30d4\u30b6\u306e\u5024\u6bb5\u300d\u3092\u4e88\u6e2c\u3057\u305f\u3044\u3068\u304d\u3001<strong>\u4e88\u6e2c\u306b\u4f7f\u3046\u3082\u306e\uff08\u30d4\u30b6\u306e\u76f4\u5f84\uff09\u3092\u8aac\u660e\u5909\u6570<\/strong>\u3001<strong>\u4e88\u6e2c\u3059\u308b\u3082\u306e\uff08\u30d4\u30b6\u306e\u5024\u6bb5\uff09\u3092\u76ee\u7684\u5909\u6570\u3068\u3044\u3044\u307e\u3059\u3002<\/strong><br>\n\u7528\u8a9e\u306e\u5fa9\u7fd2\u3067\u3059\u304c\u3001\u76ee\u7684\u5909\u6570\u306f\u30b4\u30fc\u30eb\u3068\u306a\u308b\u4e88\u6e2c\u3057\u305f\u3044\u30c7\u30fc\u30bf\u306e\u3053\u3068\u3067\u3001\u8aac\u660e\u5909\u6570\u306f\u4e88\u6e2c\u3057\u305f\u3044\u30c7\u30fc\u30bf\u306e\u8981\u56e0\u3068\u306a\u308b\u30c7\u30fc\u30bf\u306e\u3053\u3068\u3067\u3057\u305f\u3002<br>\n\u30d4\u30b6\u306e\u5024\u6bb5\u306e\u3088\u3046\u306b\u4e88\u6e2c\u3057\u305f\u3044\u3082\u306e\u3001\u3059\u306a\u308f\u3061\u76ee\u7684\u5909\u6570\u304c100,200\u306a\u3069\u306e\u5b9f\u6570\u5024\u306e\u5b66\u7fd2\u3092\u56de\u5e30\u3068\u547c\u3073\u307e\u3059\u3002<\/p>\n<p><code><a href=\"https:\/\/aiacademy.jp\/bootcamp\"><img decoding=\"async\" src=\"https:\/\/aiacademy.jp\/media\/wp-content\/uploads\/2021\/12\/bootcamp_banner2.png\"><\/a><\/code><\/p>\n<h2 id=\"i-4\">\u5358\u56de\u5e30\u306e\u5b9f\u88c5\u4f8b<\/h2>\n<p>\u7c21\u5358\u306a\u56de\u5e30\u3092\u30d4\u30b6\u306e\u4f8b\u3092\u4f7f\u3063\u3066\u5b9f\u88c5\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<br>\n\u30d4\u30b6\u306e\u76f4\u5f84\u3068\u4fa1\u683c\u306e\u30c7\u30fc\u30bf\u304c\u4e0b\u306e\u8868\u306e\u3088\u3046\u306b5\u500b\u3042\u308b\u3068\u3057\u307e\u3059\u3002<\/p>\n<table>\n<thead>\n<tr>\n<th>No.<\/th>\n<th>\u76f4\u5f84\uff08cm\uff09<\/th>\n<th>\u5024\u6bb5\uff08\u5186\uff09<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>12<\/td>\n<td>700<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>16<\/td>\n<td>900<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>20<\/td>\n<td>1300<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td>28<\/td>\n<td>1750<\/td>\n<\/tr>\n<tr>\n<td>5<\/td>\n<td>36<\/td>\n<td>1800<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4eca\u56de\u306f\u30d4\u30b6\u306e\u76f4\u5f84\u3092\u4f7f\u3063\u3066\u3001\u5024\u6bb5\u3092\u4e88\u6e2c\u3057\u307e\u3059\u3002<br>\n\u3067\u306f\u3001\u59cb\u3081\u306b\u30c7\u30fc\u30bf\u3092\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n<pre><code>x = [[12],[16],[20],[28],[36]]\ny = [[700],[900],[1300],[1750],[1800]]\n<\/code><\/pre>\n<p>\u6b21\u306b\u3053\u306e\u30c7\u30fc\u30bf\u304c\u3069\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u306e\u304b\u3001\u56de\u5e30\u3092\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u304b\u306a\u3069matplotlib\u3092\u3064\u304b\u3063\u3066\u53ef\u8996\u5316\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre><code class=\"python:\">import matplotlib.pyplot as plt\n\n # \u30c6\u30ad\u30b9\u30c8\u30a8\u30c7\u30a3\u30bf\u3067\u5b9f\u884c\u3059\u308b\u5834\u5408\u306f\u3053\u306e\u884c\u3092\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8(\u30b3\u30e1\u30f3\u30c8\u5316)\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n%matplotlib inline\n\nplt.figure()\nplt.title('Relation between diameter and price') #\u30bf\u30a4\u30c8\u30eb\nplt.xlabel('diameter') #\u8ef8\u30e9\u30d9\u30eb\nplt.ylabel('price') #\u8ef8\u30e9\u30d9\u30eb\nplt.scatter(x,y) #\u6563\u5e03\u56f3\u306e\u4f5c\u6210\nplt.axis([0, 50, 0, 2500]) #\u8868\u306e\u6700\u5c0f\u5024\u3001\u6700\u5927\u5024\nplt.grid(True) #grid\u7dda\nplt.show()\n<\/code><\/pre>\n<p>\u4e0a\u8a18\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u5b9f\u884c\u3059\u308b\u3068\u56f3\u304c\u51fa\u529b\u3055\u308c\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/camo.qiitausercontent.com\/8b54610138597501c84e6eda9e9846aff1af73b9\/68747470733a2f2f71696974612d696d6167652d73746f72652e73332e616d617a6f6e6177732e636f6d2f302f3130353838372f38353531616435662d326665372d333435622d396636382d3565363163376137643636642e706e67\" alt=\"\"><\/p>\n<p>\u3053\u306e\u56f3\u3092\u307f\u308b\u3068\u76f4\u5f84\u3068\u5024\u6bb5\u306b\u306f\u6b63\u306e\u76f8\u95a2\u304c\u3042\u308b\u3088\u3046\u306b\u307f\u3048\u307e\u3059\u3002<br>\n\u3053\u306e\u3088\u3046\u306b\u3001\u30c7\u30fc\u30bf\u3092plot\u3059\u308b\u3053\u3068\u3067\u56de\u5e30\u3092\u884c\u3046\u5fc5\u8981\u304c\u3042\u308b\u304b\u5206\u304b\u308a\u307e\u3059\u3002<br>\n\u3067\u306f\u3001\u6b21\u306bscikit-learn\u3092\u4f7f\u3063\u3066\u56de\u5e30\u3092\u884c\u306a\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002<br>\n\u307e\u305a\u3001\u306f\u3058\u3081\u306b\u30e2\u30c7\u30eb\u3092\u69cb\u7bc9\u3057\u307e\u3059\u3002<\/p>\n<pre><code>from sklearn.linear_model import LinearRegression\nmodel = LinearRegression()\nmodel.fit(x,y)\n<\/code><\/pre>\n<p>1\u884c\u76ee\u3067\u4eca\u56de\u4f7f\u3046\u56de\u5e30\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3092import\u3057\u307e\u3059\u3002<br>\n2\u884c\u76ee\u3067\u306f\u3001\u4f7f\u3046\u30e2\u30c7\u30eb\uff08\u56de\u5e30\uff09\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<br>\n3\u884c\u76ee\u3067x\u3068y\u306e\u30c7\u30fc\u30bf\u3092\u4f7f\u3063\u3066\u5b66\u7fd2\u3055\u305b\u307e\u3059\u3002<br>\n\u3053\u308c\u3067\u3001\u56de\u5e30\u306e\u30e2\u30c7\u30eb\u306e\u5b8c\u6210\u3067\u3059\u3002<br>\n\u3067\u306f\u3001\u5927\u304d\u3055\u304c25cm\u306e\u30d4\u30b6\u306e\u5024\u6bb5\u306f\u3044\u304f\u3089\u306b\u306a\u308b\u3067\u3057\u3087\u3046\u3002<br>\n\u3053\u306e\u30e2\u30c7\u30eb\u3092\u3064\u304b\u3063\u3066\u4e88\u6e2c\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre><code class=\"python:\">import numpy as np\nprice = model.predict(np.array([25]).reshape(-1, 1)) # Google Colab\u306a\u3069\u3067skleran.0.20\u7cfb\u3054\u5229\u7528\u306e\u65b9\n# price = model.predict(25) # scikit-learn\u30d0\u30fc\u30b8\u30e7\u30f30.1.9\u7cfb\n# \u3082\u3057\u304f\u306f\u4e0b\u8a18\u306e\u5f62\u5f0f\u3067\u3059\u3002\n# price = model.predict([[25]])\nprint('25 cm pizza should cost: $%s'%price[0][0])\n<\/code><\/pre>\n<p>predict\u3092\u4f7f\u3046\u3053\u3068\u306b\u3088\u3063\u3066\u5024\u6bb5\u3092\u4e88\u6e2c\u3067\u304d\u307e\u3059\u3002<br>\n\u4e0a\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u5b9f\u884c\u3059\u308b\u3068<br>\n25 cm pizza should cost: 1416.91810345\u5186<br>\n\u3068\u8868\u793a\u3055\u308c\u4e88\u6e2c\u3067\u304d\u3066\u3044\u308b\u3053\u3068\u304c\u5206\u304b\u308a\u307e\u3059\u3002<\/p>\n<p>\u3053\u3053\u307e\u3067\u306e<a href=\"https:\/\/aiacademy.jp\/dataset\/AI_Academy\u5358\u56de\u5e30.ipynb\">\u30d7\u30ed\u30b0\u30e9\u30e0(Jupyter Notebook\u30d5\u30a1\u30a4\u30eb)<\/a>\u3067\u3059\u3002<\/p>\n<p>\u3053\u306e\u3088\u3046\u306b\u6a5f\u68b0\u5b66\u7fd2\u3067\u4e88\u6e2c\u3092\u3059\u308b\u306b\u306f\u6b21\u306e3\u3064\u306e\u624b\u9806\u306b\u3088\u3063\u3066\u884c\u3048\u307e\u3059\u3002<\/p>\n<pre><code class=\"shell\">1) \u30e2\u30c7\u30eb\u306e\u6307\u5b9a\nmodel = LinearRegression()\n2) \u5b66\u7fd2\nmodel.fit(x,y)\n3) \u4e88\u6e2c\nprice = model.predict(25)\n<\/code><\/pre>\n<p>\u3053\u306e\u624b\u9806\u306f\u56de\u5e30\u4ee5\u5916\u306e\u3069\u306e\u6a5f\u68b0\u5b66\u7fd2\u624b\u6cd5\u3067\u3082\u5909\u308f\u308a\u307e\u305b\u3093\u3002<\/p>\n<h2 id=\"i-5\">\u8a55\u4fa1\u65b9\u6cd5 \u6c7a\u5b9a\u4fc2\u6570(\u5bc4\u4e0e\u7387)<\/h2>\n<p>\u3067\u306f\u3001\u3053\u308c\u306f\u826f\u3044\u5b66\u7fd2\u304c\u3067\u304d\u3066\u3044\u308b\u306e\u3067\u3057\u3087\u3046\u304b\uff1f<br>\n\u826f\u3044\u5b66\u7fd2\u304c\u3067\u304d\u3066\u3044\u308b\u304b\u78ba\u8a8d\u3059\u308b\u305f\u3081\u306b\u306f\u3001\u8a55\u4fa1\u304c\u5fc5\u8981\u3067\u3059\u3002<br>\n\u56de\u5e30\u306e\u8a55\u4fa1\u65b9\u6cd5\u3068\u3057\u3066\u6c7a\u5b9a\u4fc2\u6570(\u307e\u305f\u306f\u5bc4\u4e0e\u7387\u3068\u3082\u547c\u3073\u307e\u3059\/r-squared)\u3068\u3044\u3046\u3082\u306e\u304c\u3042\u308a\u307e\u3059\u3002<br>\n\u6c7a\u5b9a\u4fc2\u6570(\u5bc4\u4e0e\u7387)\u3068\u306f\u3001\u8aac\u660e\u5909\u6570\u304c\u76ee\u7684\u5909\u6570\u3092\u3069\u306e\u304f\u3089\u3044\u8aac\u660e\u3067\u304d\u308b\u304b\u3092\u8868\u3059\u5024\u3067\u9ad8\u3051\u308c\u3070\u9ad8\u3044\u307b\u3069\u826f\u3044\u3068\u3055\u308c\u307e\u3059\u3002<br>\n\u6c7a\u5b9a\u4fc2\u6570(\u5bc4\u4e0e\u7387)\u306fscore\u306b\u3088\u3063\u3066\u51fa\u529b\u3055\u308c\u307e\u3059\u3002<br>\n\u65b0\u305f\u306b\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u3092\u4f5c\u6210\u3057\u3066\u3001\u5bc4\u4e0e\u7387\u3092\u8a08\u7b97\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre><code># \u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u3092\u4f5c\u6210\nx_test = [[16],[18],[22],[32],[24]]\ny_test = [[1100],[850],[1500],[1800],[1100]]\n\nscore = model.score(x_test, y_test)\nprint(\"r-squared:\",score)\n<\/code><\/pre>\n<p>model.score\u306b\u3088\u3063\u3066\u305d\u306e\u30e2\u30c7\u30eb\u306e\u5bc4\u4e0e\u7387\u3092\u8a08\u7b97\u3067\u304d\u307e\u3059\u3002<br>\n\u4e0a\u8a18\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001<br>\nr-squared: 0.662005292942<br>\n\u3068\u51fa\u529b\u3055\u308c\u3066\u3044\u307e\u3059\u3002<br>\n\u5bc4\u4e0e\u7387\u304c0.66\u3068\u9ad8\u304f\u306f\u306a\u3044\u3067\u3059\u304c\u3001\u3042\u308b\u7a0b\u5ea6\u306e\u30e2\u30c7\u30eb\u304c\u4f5c\u308c\u3066\u3044\u308b\u3068\u3044\u3048\u307e\u3059\u3002<br>\n\u8a55\u4fa1\u6307\u6a19\u306b\u3064\u3044\u3066\u77e5\u308a\u305f\u3044\u65b9\u306f<a href=\"https:\/\/aiacademy.jp\/texts\/show\/?id=298&amp;context=subject-metrics\">\u300c\u8a55\u4fa1\u6307\u6a19\u300d\u306e\u30c6\u30ad\u30b9\u30c8<\/a>\u3092\u53c2\u8003\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2 id=\"i-6\">\u91cd\u56de\u5e30<\/h2>\n<p>\u5148\u7a0b\u306e\u5358\u56de\u5e30\u3088\u308a\u3001\u826f\u3044\u30e2\u30c7\u30eb\u3092\u4f5c\u308b\u306b\u306f\u3069\u3046\u3057\u305f\u3089\u826f\u3044\u3067\u3057\u3087\u3046\u304b\uff1f<br>\n\u30d4\u30b6\u306e\u4f8b\u3067\u8003\u3048\u308b\u3068\u3001<br>\n\u30d4\u30b6\u306e\u5024\u6bb5\u3092\u6c7a\u3081\u3066\u3044\u308b\u306e\u306f\u5927\u304d\u3055\u3060\u3051\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002<br>\n\u30c8\u30c3\u30d4\u30f3\u30b0\u306e\u6570\u3001\u30d1\u30f3\u306e\u751f\u5730\u3001\u7a2e\u985e\u306a\u3069\u69d8\u3005\u306a\u8981\u56e0\u304c\u5024\u6bb5\u3092\u6c7a\u3081\u3066\u3044\u307e\u3059\u3002<br>\n\u306a\u306e\u3067\u3001\u5024\u6bb5\u306b\u95a2\u308f\u308b\u8981\u56e0\u3092\u8aac\u660e\u5909\u6570\u3068\u5897\u3084\u305b\u3070\u5897\u3084\u3059\u307b\u3069\u3001\u5024\u6bb5\u3092\u6b63\u78ba\u306b\u4e88\u6e2c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br>\n<strong>\u3053\u306e\u3088\u3046\u306b\u3001\u8aac\u660e\u5909\u6570\u30922\u3064\u4ee5\u4e0a\u3067\u884c\u3046\u56de\u5e30\u306e\u3053\u3068\u3092\u91cd\u56de\u5e30\u3068\u3044\u3044\u307e\u3059\u3002<\/strong><br>\n\uff08\u5148\u7a0b\u306f\u8aac\u660e\u5909\u6570\u304c1\u3064\u3060\u3063\u305f\u306e\u3067\u5358\u56de\u5e30\u3068\u3044\u3044\u307e\u3059\u3002\uff09<br>\n\u5b9f\u969b\u306b\u8a08\u7b97\u3068\u3057\u3066\u306f\u3001<br>\n\u91cd\u56de\u5e30\u5f0f\u3092Y=b1X1+b2X2+b3X3+b4X4+b5X5+\u2025\u2025+b0<br>\n\u306e\u3088\u3046\u306b\u8868\u3059\u3053\u3068\u304c\u3067\u304d\u3001b1,b2,\u2025\u3092\u504f\u56de\u5e30\u4fc2\u6570\u3068\u3044\u3044\u307e\u3059\u3002<\/p>\n<h2 id=\"i-7\">\u91cd\u56de\u5e30\u306e\u5b9f\u88c5\u4f8b<\/h2>\n<p>\u3067\u306f\u3001\u91cd\u56de\u5e30\u3092\u5b9f\u88c5\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<br>\n\u5148\u7a0b\u306e\u30c7\u30fc\u30bf\u306b\u30c8\u30c3\u30d4\u30f3\u30b0\u306e\u6570\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<table>\n<thead>\n<tr>\n<th>No.<\/th>\n<th>\u76f4\u5f84\uff08cm\uff09<\/th>\n<th>\u30c8\u30c3\u30d4\u30f3\u30b0\u306e\u6570<\/th>\n<th>\u5024\u6bb5\uff08\u5186\uff09<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>12<\/td>\n<td>2<\/td>\n<td>700<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>16<\/td>\n<td>1<\/td>\n<td>900<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>20<\/td>\n<td>0<\/td>\n<td>1300<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td>28<\/td>\n<td>2<\/td>\n<td>1750<\/td>\n<\/tr>\n<tr>\n<td>5<\/td>\n<td>36<\/td>\n<td>0<\/td>\n<td>1800<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u306e\u65b9\u306b\u3082\u8ffd\u52a0\u3057\u3001\u5b66\u7fd2\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre><code class=\"python:\">from sklearn.linear_model import LinearRegression\nx = [[12,2],[16,1],[20,0],[28,2],[36,0]]\ny = [[700],[900],[1300],[1750],[1800]]\n\nmodel = LinearRegression()\nmodel.fit(x,y)\n\nx_test = [[16,2],[18,0],[22,2],[32,2],[24,0]]\ny_test = [[1100],[850],[1500],[1800],[1100]]\n\n# prices = model.predict([[16, 2], [18, 0], [22, 2], [32, 2], [24, 0]])\nprices = model.predict(x_test) # \u4e0a\u306e\u30b3\u30e1\u30f3\u30c8\u3068\u540c\u3058\n\nfor i, price in enumerate(prices):\n    print('Predicted:%s, Target:%s'%(price,y_test[i]))\n\nscore = model.score(x_test,y_test)\nprint(\"r-squared:\",score)\n<\/code><\/pre>\n<p>\u5b66\u7fd2\u306e\u3084\u308a\u65b9\u306f\u5148\u7a0b\u3068\u307e\u3063\u305f\u304f\u540c\u69d8\u3067\u3059\u3002<\/p>\n<pre><code>prices = model.predict(x_test)\n<\/code><\/pre>\n<p>\u3067\u4e00\u6c17\u306b5\u3064\u306e\u30c7\u30fc\u30bf\u306e\u4e88\u6e2c\u3092\u884c\u306a\u3063\u3066\u3044\u307e\u3059\u3002<br>\n\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u7d50\u679c\u304c\u51fa\u529b\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre><code class=\"shell\">Predicted:[ 1006.25], Target:[1100]\nPredicted:[ 1028.125], Target:[850]\nPredicted:[ 1309.375], Target:[1500]\nPredicted:[ 1814.58333333], Target:[1800]\nPredicted:[ 1331.25], Target:[1100]\nr-squared: 0.770167773132\n<\/code><\/pre>\n<p>\u4e88\u6e2c\u3057\u305f\u5024\u3068\u5b9f\u969b\u306e\u5024\u3092\u6bd4\u3079\u308b\u3068\u3001\u8fd1\u3044\u6570\u5024\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<br>\n\u307e\u305f\u3001\u5bc4\u4e0e\u7387\u306f0.77\u3068\u4e0a\u304c\u308a\u5358\u56de\u5e30\u3088\u308a\u826f\u3044\u30e2\u30c7\u30eb\u3092\u4f5c\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<h2 id=\"i-8\">\u4f5c\u6210\u3057\u305f\u30d7\u30ed\u30b0\u30e9\u30e0<\/h2>\n<pre><code class=\"python:\"># \u5b66\u7fd2\u30c7\u30fc\u30bf\nx = [[12],[16],[20],[28],[36]]\ny = [[700],[900],[1300],[1750],[1800]]\n\n\nimport matplotlib.pyplot as plt\nplt.figure()\nplt.title('Relation between diameter and price') #\u30bf\u30a4\u30c8\u30eb\nplt.xlabel('diameter') #\u8ef8\u30e9\u30d9\u30eb\nplt.ylabel('price') #\u8ef8\u30e9\u30d9\u30eb\nplt.scatter(x,y) #\u6563\u5e03\u56f3\u306e\u4f5c\u6210\nplt.axis([0, 50, 0, 2500]) #\u8868\u306e\u6700\u5c0f\u5024\u3001\u6700\u5927\u5024\nplt.grid(True) #grid\u7dda\nplt.show()\n\n\nfrom sklearn.linear_model import LinearRegression\nmodel = LinearRegression()\nmodel.fit(x,y)\n\nimport numpy as np\nprice = model.predict(np.array([25]).reshape(-1, 1)) # Google Colab\u306a\u3069\u3067skleran.0.20\u7cfb\u3054\u5229\u7528\u306e\u65b9\n# price = model.predict(25) # scikit-learn\u30d0\u30fc\u30b8\u30e7\u30f30.1.9\u7cfb\nprint('25 cm pizza should cost: $%s'%price[0][0])\n\n\nx_test = [[16],[18],[22],[32],[24]]\ny_test = [[1100],[850],[1500],[1800],[1100]]\n\nscore = model.score(x_test,y_test)\nprint(\"r-squared:\",score)\n\n\n\nfrom sklearn.linear_model import LinearRegression\nx = [[12,2],[16,1],[20,0],[28,2],[36,0]]\ny = [[700],[900],[1300],[1750],[1800]]\n\nmodel = LinearRegression()\nmodel.fit(x,y)\n\nx_test = [[16,2],[18,0],[22,2],[32,2],[24,0]]\ny_test = [[1100],[850],[1500],[1800],[1100]]\n\nprices = model.predict(x_test)\nfor i, price in enumerate(prices):\n    print('Predicted:%s, Target:%s'%(price,y_test[i]))\n\nscore = model.score(x_test,y_test)\nprint(\"r-squared:\",score)\n<\/code><\/pre>\n<h2 id=\"i-9\">\u307e\u3068\u3081<\/h2>\n<p>\u3053\u306e\u7ae0\u3067\u306f\u56de\u5e30\u306b\u3064\u3044\u3066\u5b66\u7fd2\u3057\u307e\u3057\u305f\u3002<br>\n\u8aac\u660e\u5909\u6570\u304c1\u3064\u306e\u3068\u304d\u306f\u5358\u56de\u5e30\u3001\u8907\u6570\u306e\u3068\u304d\u306f\u91cd\u56de\u5e30\u3068\u547c\u3070\u308c\u307e\u3059\u3002<br>\n\u307e\u305f\u3001\u8a55\u4fa1\u6307\u6a19\u3068\u3057\u3066\u5bc4\u4e0e\u7387\u3092\u8aac\u660e\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"i-10\">\u308f\u304b\u3089\u306a\u3044\u3053\u3068\u3092\u6c17\u8efd\u306b\u8cea\u554f\u3067\u304d\u308b\u74b0\u5883\u3067\u5b66\u307c\u3046\uff01<\/h2>\n\n\n\n<p>Python\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3084\u6a5f\u68b0\u5b66\u7fd2\u3001\u30c7\u30fc\u30bf\u5206\u6790\u3092\u4e00\u4eba\u3067\u5b66\u3093\u3067\u3044\u308b\u3068\u3001\u3069\u3053\u304b\u3067\u308f\u304b\u3089\u306a\u3044\u3053\u3068\u304c\u51fa\u3066\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u308f\u304b\u3089\u306a\u3044\u3053\u3068\u3092\uff11\u4eba\u3067\u89e3\u6c7a\u3057\u3088\u3046\u3068\u3057\u3066\u3082\u306a\u304b\u306a\u304b\u89e3\u6c7a\u3067\u304d\u305a\u3001\u6642\u9593\u3060\u3051\u304c\u904e\u304e\u3066\u3057\u307e\u3063\u305f\u3002\u3002\u3068\u3044\u3046\u7d4c\u9a13\u306f\u3042\u308a\u307e\u305b\u3093\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n\n\n\n<p>\u300cGoogle\u5148\u751f\u306b\u805e\u3051\u3070\uff08\u81ea\u5206\u3067Google\u3067\u8abf\u3079\u308c\u3070\uff09\u89e3\u6c7a\u3067\u304d\u308b\u306f\u305a\u3060\u300d\u300c\u3082\u3046\u5c11\u3057\u8003\u3048\u308c\u3070\u304d\u3063\u3068\u89e3\u6c7a\u3067\u304d\u308b\u306f\u305a\u3060\u300d\u3068\u3044\u3063\u305f\u5177\u5408\u306b\u3001\u7d42\u308f\u308a\u306e\u898b\u3048\u306a\u3044\u6ce5\u6cbc\u306b\u9665\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3053\u306e\u3088\u3046\u306a\u3068\u304d\u3053\u305d\u3001\u81ea\u5206\u3088\u308a\u30b9\u30ad\u30eb\u306e\u3042\u308b\u4eba\u306b\u8cea\u554f\u304c\u3067\u304d\u308c\u3070\u3001\u4f59\u8a08\u306a\u6642\u9593\u3092\u6d6a\u8cbb\u3057\u306a\u304f\u3066\u6e08\u3080\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/aiacademy.jp\/bootcamp\/\">AI Academy Bootcamp<\/a>\u306e\u300c<a href=\"https:\/\/aiacademy.jp\/bootcamp\/\">\u30aa\u30f3\u30c7\u30de\u30f3\u30c9\u52d5\u753b\uff0b\u30c1\u30e3\u30c3\u30c8\u30b5\u30dd\u30fc\u30c8\u30d7\u30e9\u30f3<\/a>\u300d\u306f\uff16\u30f6\u6708\u3001\u6a5f\u68b0\u5b66\u7fd2\u30a8\u30f3\u30b8\u30cb\u30a2\u3084\u30c7\u30fc\u30bf\u30b5\u30a4\u30a8\u30f3\u30c6\u30a3\u30b9\u30c8\u304b\u3089\u30c1\u30e3\u30c3\u30c8\u306b\u3066\u53d7\u8b1b\u671f\u9593\u4e2d\u3001\u8cea\u554f\u3057\u653e\u984c\u3067\u3059\u3002<\/p>\n\n\n\n<p>\uff16\u30f6\u6708\u9593\u8cea\u554f\u3057\u653e\u984c\u3067\u3001\u53d7\u8b1b\u6599\u308235,000\u5186\uff08\u7a0e\u8fbc\uff09\u3068\u304a\u624b\u8efd\u306b\u3054\u53d7\u8b1b\u9802\u3051\u307e\u3059\u3002<br>\uff081\u65e5\u306e\u53d7\u8b1b\u8cbb\u7528\u63db\u7b97\u3067\u3001\u306a\u3093\u3068194\u5186\u3067\u3054\u53d7\u8b1b\u9802\u3051\u307e\u3059\u3002\uff09<\/p>\n\n\n\n<p>\u662f\u975e\u3001\u3044\u3064\u3067\u3082\u8cea\u554f\u3057\u653e\u984c\u306e\u74b0\u5883\u3067\u52b9\u7387\u306e\u826f\u3044AI\u5b66\u7fd2\u3092\u59cb\u3081\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<p><strong><a href=\"https:\/\/aiacademy.jp\/bootcamp\/\">AI Academy&nbsp;Bootcamp<\/a><\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/aiacademy.jp\/bootcamp\/\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"341\" src=\"https:\/\/aiacademy.jp\/media\/wp-content\/uploads\/2021\/12\/bootcamp_ad_72ppi-1024x341.png\" alt=\"\" class=\"wp-image-691\" srcset=\"https:\/\/aiacademy.jp\/media\/wp-content\/uploads\/2021\/12\/bootcamp_ad_72ppi-1024x341.png 1024w, https:\/\/aiacademy.jp\/media\/wp-content\/uploads\/2021\/12\/bootcamp_ad_72ppi-300x100.png 300w, https:\/\/aiacademy.jp\/media\/wp-content\/uploads\/2021\/12\/bootcamp_ad_72ppi-768x256.png 768w, https:\/\/aiacademy.jp\/media\/wp-content\/uploads\/2021\/12\/bootcamp_ad_72ppi-940x313.png 940w, https:\/\/aiacademy.jp\/media\/wp-content\/uploads\/2021\/12\/bootcamp_ad_72ppi.png 1200w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><\/a><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u6b21 \u306f\u3058\u3081\u306b \u56de\u5e30\u5206\u6790\u3068\u306f \u5358\u56de\u5e30\u3068\u91cd\u56de\u5e30\u306e\u9055\u3044 \u5358\u56de\u5e30 \u5358\u56de\u5e30\u306e\u5b9f\u88c5\u4f8b \u8a55\u4fa1\u65b9\u6cd5 \u6c7a\u5b9a\u4fc2\u6570(\u5bc4\u4e0e\u7387) \u91cd\u56de\u5e30 \u91cd\u56de\u5e30\u306e\u5b9f\u88c5\u4f8b \u4f5c\u6210\u3057\u305f\u30d7\u30ed\u30b0\u30e9\u30e0 \u307e\u3068\u3081 \u308f\u304b\u3089\u306a\u3044\u3053\u3068\u3092\u6c17\u8efd\u306b\u8cea\u554f\u3067\u304d\u308b\u74b0\u5883\u3067\u5b66\u307c\u3046\uff01 \u306f\u3058\u3081\u306b \u3053\u306e &#8230; <\/p>\n","protected":false},"author":1,"featured_media":354,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[85,105,130],"tags":[],"class_list":{"0":"post-236","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-python","8":"category-105","9":"category-130"},"_links":{"self":[{"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=\/wp\/v2\/posts\/236","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=236"}],"version-history":[{"count":7,"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=\/wp\/v2\/posts\/236\/revisions"}],"predecessor-version":[{"id":4880,"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=\/wp\/v2\/posts\/236\/revisions\/4880"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=\/wp\/v2\/media\/354"}],"wp:attachment":[{"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=236"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=236"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=236"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}