{"id":18075,"date":"2022-10-31T08:12:15","date_gmt":"2022-10-31T08:12:15","guid":{"rendered":"https:\/\/club.informatix.co.jp\/?p=18075"},"modified":"2024-11-01T09:14:01","modified_gmt":"2024-11-01T09:14:01","slug":"numpy%e3%81%a7%e8%a1%8c%e5%88%97%e3%80%80%e5%9b%9e%e5%b8%b0%e5%88%86%e6%9e%90-%e3%81%9d%e3%81%ae5%ef%bd%9cpython%e3%81%a7%e6%95%b0%e5%ad%a6%e3%82%92%e5%ad%a6%e3%81%bc%e3%81%86%ef%bc%81%e3%80%80","status":"publish","type":"post","link":"https:\/\/club.informatix.co.jp\/?p=18075","title":{"rendered":"NumPy\u3067\u884c\u5217\u3000\u56de\u5e30\u5206\u6790 \u305d\u306e5\uff5cPython\u3067\u6570\u5b66\u3092\u5b66\u307c\u3046\uff01 \u7b2c26\u56de"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">\u76ee\u6b21<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69f21d4a70ec3\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69f21d4a70ec3\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/club.informatix.co.jp\/?p=18075\/#%E5%9B%9E%E5%B8%B0%E7%9B%B4%E7%B7%9A%E3%82%921%E8%A1%8C%E3%81%AE%E3%82%B3%E3%83%BC%E3%83%89%E3%81%A7%E6%8F%8F%E3%81%8F\" >\u56de\u5e30\u76f4\u7dda\u30921\u884c\u306e\u30b3\u30fc\u30c9\u3067\u63cf\u304f<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/club.informatix.co.jp\/?p=18075\/#%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0%E3%80%8Ckaiki1-1py%E3%80%8D%E5%9B%9E%E5%B8%B0%E5%88%86%E6%9E%90%EF%BC%881%E6%AC%A1%E5%BC%8F%EF%BC%89%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0\" >\u30d7\u30ed\u30b0\u30e9\u30e0\u300ckaiki1-1py\u300d\u56de\u5e30\u5206\u6790\uff081\u6b21\u5f0f\uff09\u30d7\u30ed\u30b0\u30e9\u30e0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/club.informatix.co.jp\/?p=18075\/#%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0%E5%AE%9F%E8%A1%8C%E7%B5%90%E6%9E%9C\" >\u30d7\u30ed\u30b0\u30e9\u30e0\u5b9f\u884c\u7d50\u679c<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/club.informatix.co.jp\/?p=18075\/#%E9%87%8D%E5%9B%9E%E5%B8%B0%E5%88%86%E6%9E%90\" >\u91cd\u56de\u5e30\u5206\u6790<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/club.informatix.co.jp\/?p=18075\/#%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0%E3%80%8Cjukaiki1py%E3%80%8D%E9%87%8D%E5%9B%9E%E5%B8%B0%E5%88%86%E6%9E%90%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0\" >\u30d7\u30ed\u30b0\u30e9\u30e0\u300cjukaiki1.py\u300d\u91cd\u56de\u5e30\u5206\u6790\u30d7\u30ed\u30b0\u30e9\u30e0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/club.informatix.co.jp\/?p=18075\/#%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0%E5%AE%9F%E8%A1%8C%E7%B5%90%E6%9E%9C-2\" >\u30d7\u30ed\u30b0\u30e9\u30e0\u5b9f\u884c\u7d50\u679c<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n\n<h2><span class=\"ez-toc-section\" id=\"%E5%9B%9E%E5%B8%B0%E7%9B%B4%E7%B7%9A%E3%82%921%E8%A1%8C%E3%81%AE%E3%82%B3%E3%83%BC%E3%83%89%E3%81%A7%E6%8F%8F%E3%81%8F\"><\/span>\u56de\u5e30\u76f4\u7dda\u30921\u884c\u306e\u30b3\u30fc\u30c9\u3067\u63cf\u304f<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><a href=\"https:\/\/club.informatix.co.jp\/?p=17974\" target=\"_blank\" rel=\"noopener\">\u524d\u56de<\/a>\u3001\u56de\u5e30\u76f4\u7dda\u3092\u5f97\u308b\u306e\u306bnumpy.profit\u95a2\u6570\u3092\u7528\u3044\u308b\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>&gt;&gt;&gt;\u00a0 a, b = np.polyfit(x1_data, y_data, 1)<\/p>\n<p>\u3068\u3057\u3066\u3001\u56de\u5e30\u76f4\u7dda\u306e\u4fc2\u6570\uff08\u56de\u5e30\u4fc2\u6570\uff09\u3092\u53d6\u308a\u51fa\u3057\u305f\u5f8c\u306b<\/p>\n<p>&gt;&gt;&gt;\u00a0 X1 = np.arange(x_min, x_max, 1)<br \/>\n&gt;&gt;&gt;\u00a0 Y = a * X1 + b<br \/>\n&gt;&gt;&gt;\u00a0 plt.plot(X1, Y, c=&#8217;Red&#8217;)<\/p>\n<p>\u3068\u3057\u3066\u56de\u5e30\u76f4\u7dda\u3092\u63cf\u304f\u3068\u3044\u3046\u65b9\u6cd5\u3067\u3059\u3002\u4eca\u56de\u306f\u3053\u308c\u30921\u884c\u3067\u6e08\u307e\u305b\u308b\u65b9\u6cd5\u304b\u3089\u7d39\u4ecb\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>&gt;&gt;&gt;\u00a0 plt.plot(x, np.poly1d(np.polyfit(x, y, 1))(x), label=&#8217;d=1&#8242;,c=&#8217;Red&#8217;)<\/p>\n<p>\u3053\u308c\u3067\u4e0a\u8a184\u884c\u306e\u30b3\u30fc\u30c9\u3068\u540c\u3058\u3088\u3046\u306b\u56de\u5e30\u76f4\u7dda\u3092\u63cf\u304f\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3057\u305f\u304c\u3063\u3066\u3001\u3059\u3079\u3066\u306e\u30b3\u30fc\u30c9\u306f\u3055\u3089\u306b\u7c21\u6f54\u306b\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/club.informatix.co.jp\/?p=17974\" target=\"_blank\" rel=\"noopener\">\u524d\u56de<\/a>\u3068\u540c\u3058\u30c7\u30fc\u30bf\u3092\u7528\u3044\u3066\u56de\u5e30\u5206\u6790\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-17977\" src=\"https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2022\/09\/20220930-3.jpg\" alt=\"\" width=\"581\" height=\"134\" srcset=\"https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2022\/09\/20220930-3.jpg 581w, https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2022\/09\/20220930-3-300x69.jpg 300w\" sizes=\"(max-width: 581px) 100vw, 581px\" \/><\/p>\n<p style=\"text-align: center;\">\u88681\uff1a\u8eab\u9577\u3068\u4f53\u91cd\u306e\u30c7\u30fc\u30bf<\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0%E3%80%8Ckaiki1-1py%E3%80%8D%E5%9B%9E%E5%B8%B0%E5%88%86%E6%9E%90%EF%BC%881%E6%AC%A1%E5%BC%8F%EF%BC%89%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0\"><\/span>\u30d7\u30ed\u30b0\u30e9\u30e0\u300ckaiki1-1py\u300d\u56de\u5e30\u5206\u6790\uff081\u6b21\u5f0f\uff09\u30d7\u30ed\u30b0\u30e9\u30e0<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>&gt;&gt;&gt;\u00a0 import numpy as np<br \/>\n&gt;&gt;&gt;\u00a0 import matplotlib.pyplot as plt<br \/>\n&gt;&gt;&gt;<br \/>\n&gt;&gt;&gt;\u00a0 # STEP1. \u30c7\u30fc\u30bf\u30921\u6b21\u5143\u914d\u5217\u3068\u3057\u3066\u683c\u7d0d\u3059\u308b<br \/>\n&gt;&gt;&gt;\u00a0 x = np.array([165, 170, 172, 175, 170, 172, 183, 187, 180, 185])<br \/>\n&gt;&gt;&gt;\u00a0 y = np.array([ 53, 59, 64, 75, 72, 74, 83, 87, 84, 90])<br \/>\n&gt;&gt;&gt;<br \/>\n&gt;&gt;&gt;<br \/>\n&gt;&gt;&gt;\u00a0 # plt.figure(dpi=200)<br \/>\n&gt;&gt;&gt;\u00a0 # plt.scatter(x, y, c=&#8217;Blue&#8217;) # \u88681\u306e\u30c7\u30fc\u30bf\u3092\u30d7\u30ed\u30c3\u30c8<br \/>\n&gt;&gt;&gt;\u00a0 plt.plot(x, np.poly1d(np.polyfit(x, y, 1))(x), label=&#8217;d=1&#8242;,c=&#8217;Red&#8217;) # \u56de\u5e30\u76f4\u7dda\u3092\u63cf\u753b<br \/>\n&gt;&gt;&gt;\u00a0 # plt.xlabel(&#8216;x : Height (cm)&#8217;)<br \/>\n&gt;&gt;&gt;\u00a0 # plt.ylabel(&#8216;y : Weight (kg)&#8217;)<br \/>\n&gt;&gt;&gt;\u00a0 plt.show()<\/p>\n<p>\u3053\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u30d5\u30a1\u30a4\u30eb\u306f\u6b21\u304b\u3089\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3067\u304d\u307e\u3059\u3002<br \/>\n<a href=\"https:\/\/drive.google.com\/file\/d\/1WOduM-_33JycPdbSQTz6HwiG0LQi_JX3\/view?usp=sharing\" target=\"_blank\" rel=\"noopener\">https:\/\/drive.google.com\/file\/d\/1WOduM-_33JycPdbSQTz6HwiG0LQi_JX3\/view?usp=sharing<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0%E5%AE%9F%E8%A1%8C%E7%B5%90%E6%9E%9C\"><\/span>\u30d7\u30ed\u30b0\u30e9\u30e0\u5b9f\u884c\u7d50\u679c<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>kaiki1-1.py\u3092\u5b9f\u884c\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002\u6b21\u306e\u30b0\u30e9\u30d5\u304c\u51fa\u529b\u3055\u308c\u307e\u3059\u3002<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" class=\"aligncenter wp-image-18080 size-full\" src=\"https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2022\/10\/20221031-1-e1667197439936.jpg\" alt=\"\" width=\"640\" height=\"419\" srcset=\"https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2022\/10\/20221031-1-e1667197439936.jpg 640w, https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2022\/10\/20221031-1-e1667197439936-300x196.jpg 300w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/>\u56f31\uff1a\u300ckaiki1-1.py\u300d\u306e\u5b9f\u884c\u7d50\u679c<\/p>\n<p>\u3053\u308c\u306a\u3089\u30e9\u30af\u3067\u3059\u3002matplotlib\u3092\u7528\u3044\u305f\u30b0\u30e9\u30d5\u63cf\u753b\u306f\u9ad8\u6a5f\u80fd\u306e\u5206\u3001\u624b\u9593\u304c\u304b\u304b\u308a\u307e\u3059\u3002\u7279\u306b\u3001<\/p>\n<p>&gt;&gt;&gt;\u00a0 X1 = np.arange(x_min, x_max, 1)<\/p>\n<p>\u306e\u3088\u3046\u306bx\u306e\u5024\u3092\u3064\u304f\u3063\u3066\u3042\u3052\u308b\u3068\u3053\u308d\u304c\u5104\u52ab\u3067\u3059\u3002\u305d\u3046\u3057\u306a\u304f\u3066\u3082\u3044\u3044\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>\u5b9f\u969b\u3053\u308c\u3067\u306f\u56de\u5e30\u5206\u6790\u3089\u3057\u304f\u306a\u3044\u306e\u3067\u3001\u8868\u306e\u30c7\u30fc\u30bf\u30d7\u30ed\u30c3\u30c8\u3068\u8ef8\u306b\u30e9\u30d9\u30eb\u3092\u3064\u3051\u3066\u307f\u307e\u3059\u3002kaiki1-1.py\u306e\u5f8c\u534a\u306b\u3042\u308b4\u3064\u306e\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u3092\u9664\u304d\u307e\u3059\u3002\u6b21\u304c\u305d\u306e\u7d50\u679c\u3067\u3059\u3002<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-18081 size-full\" src=\"https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2022\/10\/20221031-2-e1667197548580.jpg\" alt=\"\" width=\"640\" height=\"438\" srcset=\"https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2022\/10\/20221031-2-e1667197548580.jpg 640w, https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2022\/10\/20221031-2-e1667197548580-300x205.jpg 300w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/p>\n<p style=\"text-align: center;\">\u56f32\uff1a\u300ckaiki1-1.py\u300d\uff08\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u9664\u53bb\uff09\u306e\u5b9f\u884c\u7d50\u679c<\/p>\n<h2><span class=\"ez-toc-section\" id=\"%E9%87%8D%E5%9B%9E%E5%B8%B0%E5%88%86%E6%9E%90\"><\/span>\u91cd\u56de\u5e30\u5206\u6790<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u3044\u3088\u3044\u3088\u672c\u4e38\u306e\u91cd\u56de\u5e30\u5206\u6790\u306b\u9032\u3093\u3067\u3044\u304d\u307e\u3059\u3002\u8aac\u660e\u5909\u6570\u304c2\u500b\u4ee5\u4e0a\u306e\u30c7\u30fc\u30bf\u306b\u5bfe\u3057\u3066\u56de\u5e30\u5f0f\u3092\u6c42\u3081\u307e\u3059\u3002\u3053\u308c\u307e\u3067\u56de\u5e30\u5206\u6790\u306b\u7528\u3044\u305f\u8eab\u9577\u3001\u4f53\u91cd\u306b\u8db3\u306e\u9577\u3055\u3092\u8aac\u660e\u5909\u6570\u306b\u52a0\u3048\u307e\u3059\u3002<\/p>\n<p>\u3059\u308b\u3068\u8eab\u9577x1\u3068\u8db3\u306e\u9577\u3055x2\u306e\u8aac\u660e\u5909\u6570\u3068\u76ee\u7684\u5909\u6570\uff08\u4f53\u91cdy\uff09\u306e\u9593\u306b1\u6b21\u5f0f\uff08\u7dda\u5f62\uff09\u306e\u95a2\u4fc2\u304c\u3042\u308b\u3068\u4eee\u5b9a\u3057\u3066\u3001\u56de\u5e30\u5f0f\u3092\u6c42\u3081\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u56de\u5e30\u5f0f\u3092\u56f3\u793a\u3059\u308b\u3068\u5e73\u9762\u3068\u306a\u308a\u307e\u3059\u3002\u56de\u5e30\u5e73\u9762\u3068\u547c\u3070\u308c\u307e\u3059\u3002<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-18082\" src=\"https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2022\/10\/20221031-3.jpg\" alt=\"\" width=\"800\" height=\"500\" srcset=\"https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2022\/10\/20221031-3.jpg 800w, https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2022\/10\/20221031-3-300x188.jpg 300w, https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2022\/10\/20221031-3-768x480.jpg 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/>\u56f33\uff1a\u91cd\u56de\u5e30\u5206\u6790<\/p>\n<p>Python\u3067\u91cd\u56de\u5e30\u5206\u6790\u3092\u884c\u3046\u65b9\u6cd5\u306f\u3044\u304f\u3064\u3082\u3042\u308a\u307e\u3059\u304c\u3001\u56de\u5e30\u5206\u6790\uff08\u5358\u56de\u5e30\u5206\u6790\uff09\u306e\u3088\u3046\u306b\u7c21\u5358\u306a\u30b3\u30fc\u30c9\u3092\u66f8\u304f\u3053\u3068\u306f\u96e3\u3057\u3044\u3067\u3059\u3002<\/p>\n<p>\u3057\u304b\u3057\u6b21\u306b\u7d39\u4ecb\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u306f\u30b0\u30e9\u30d5\u4ee5\u5916\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u306f\u3001NumPy\u3060\u3051\u30673\u884c\u306e\u30b3\u30fc\u30c9\u3067\u56de\u5e30\u4fc2\u6570\u3092\u6c42\u3081\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3082\u306e\u3067\u3059\u3002<\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0%E3%80%8Cjukaiki1py%E3%80%8D%E9%87%8D%E5%9B%9E%E5%B8%B0%E5%88%86%E6%9E%90%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0\"><\/span>\u30d7\u30ed\u30b0\u30e9\u30e0\u300cjukaiki1.py\u300d\u91cd\u56de\u5e30\u5206\u6790\u30d7\u30ed\u30b0\u30e9\u30e0<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>&gt;&gt;&gt;\u00a0 import numpy as np<br \/>\n&gt;&gt;&gt;\u00a0 import matplotlib.pyplot as plt<br \/>\n&gt;&gt;&gt;\u00a0 from mpl_toolkits.mplot3d import Axes3D #3Dplot<br \/>\n&gt;&gt;&gt;\u00a0 import japanize_matplotlib<br \/>\n&gt;&gt;&gt;<br \/>\n&gt;&gt;&gt;\u00a0 # \u30c7\u30fc\u30bf\u5b9a\u7fa9<br \/>\n&gt;&gt;&gt;\u00a0 x1 = np.array([165, 170, 172, 175, 170, 172, 183, 187, 180, 185]) # \u8aac\u660e\u5909\u6570 \u8eab\u9577<br \/>\n&gt;&gt;&gt;\u00a0 x2 = np.array([23, 24, 25, 27, 25, 24, 28, 29, 28, 29]) # \u8aac\u660e\u5909\u6570 \u8db3\u306e\u9577\u3055<br \/>\n&gt;&gt;&gt;\u00a0 y = np.array([52, 60, 63, 65, 78, 70, 72, 85, 90, 94]) # \u76ee\u7684\u5909\u6570 \u4f53\u91cd<br \/>\n&gt;&gt;&gt;<br \/>\n&gt;&gt;&gt;\u00a0 # \u56de\u5e30\u4fc2\u6570\u30d9\u30af\u30c8\u30eb\u306e\u8a08\u7b97<br \/>\n&gt;&gt;&gt;\u00a0 ones = np.ones(len(x1))<br \/>\n&gt;&gt;&gt;\u00a0 X = np.array([ones, x1, x2]).T # \u8aac\u660e\u5909\u6570\u884c\u5217<br \/>\n&gt;&gt;&gt;\u00a0 # print(f&#8217;\u8aac\u660e\u5909\u6570\u884c\u5217X=\\n{X}&#8217;)<br \/>\n&gt;&gt;&gt;\u00a0 theta = np.linalg.inv(X.T @ X) @ X.T @ y<br \/>\n&gt;&gt;&gt;<br \/>\n&gt;&gt;&gt;\u00a0 print(f&#8217;\u56de\u5e30\u4fc2\u6570 \u03b8_0 = {theta[0]}&#8217;)<br \/>\n&gt;&gt;&gt;\u00a0 print(f&#8217;\u56de\u5e30\u4fc2\u6570 \u03b8_1 = {theta[1]}&#8217;)<br \/>\n&gt;&gt;&gt;\u00a0 print(f&#8217;\u56de\u5e30\u4fc2\u6570 \u03b8_2 = {theta[2]}&#8217;)<br \/>\n&gt;&gt;&gt;\u00a0 print(f&#8217;\u56de\u5e30\u5e73\u9762 y = {theta[0]} + {theta[1]}*x1 + {theta[2]}*x2&#8242;)<br \/>\n&gt;&gt;&gt;<br \/>\n&gt;&gt;&gt;<br \/>\n&gt;&gt;&gt;\u00a0 # \u30c7\u30fc\u30bf\u3068\u56de\u5e30\u5e73\u9762 \u30b0\u30e9\u30d5\u63cf\u753b<br \/>\n&gt;&gt;&gt;\u00a0 fig = plt.figure(dpi=200)<br \/>\n&gt;&gt;&gt;\u00a0 ax = fig.add_subplot(111, projection=&#8217;3d&#8217;)<br \/>\n&gt;&gt;&gt;<br \/>\n&gt;&gt;&gt;\u00a0 ax.scatter3D(x1, x2, y, color=&#8217;Blue&#8217;) # \u30c7\u30fc\u30bf\u3092\u9752\u4e38\u3067\u30d7\u30ed\u30c3\u30c8<br \/>\n&gt;&gt;&gt;\u00a0 ax.set_xlabel(&#8220;x1:\u8eab\u9577\uff08cm\uff09&#8221;)<br \/>\n&gt;&gt;&gt;\u00a0 ax.set_ylabel(&#8220;x2:\u8db3\u306e\u9577\u3055\uff08cm\uff09&#8221;)<br \/>\n&gt;&gt;&gt;\u00a0 ax.set_zlabel(&#8220;y:\u4f53\u91cd\uff08kg\uff09&#8221;)<br \/>\n&gt;&gt;&gt;<br \/>\n&gt;&gt;&gt;\u00a0 # x1\u3068x2\u306e\u7bc4\u56f2<br \/>\n&gt;&gt;&gt;\u00a0 mesh_size = 1<br \/>\n&gt;&gt;&gt;\u00a0 margin = 0.01<br \/>\n&gt;&gt;&gt;\u00a0 x1_min, x1_max = x1.min()-margin, x1.max()+margin<br \/>\n&gt;&gt;&gt;\u00a0 x2_min, x2_max = x2.min()-margin, x2.max()+margin<br \/>\n&gt;&gt;&gt;\u00a0 x1_range = np.arange(x1_min, x1_max, mesh_size)<br \/>\n&gt;&gt;&gt;\u00a0 x2_range = np.arange(x2_min, x2_max, mesh_size)<br \/>\n&gt;&gt;&gt;\u00a0 xx1, xx2 = np.meshgrid(x1_range, x2_range)<br \/>\n&gt;&gt;&gt;<br \/>\n&gt;&gt;&gt;\u00a0 yy = (theta[0] + theta[1] * xx1 + theta[2] * xx2) # \u56de\u5e30\u5e73\u9762<br \/>\n&gt;&gt;&gt;<br \/>\n&gt;&gt;&gt;\u00a0 ax.plot_surface(xx1, xx2, yy, color=&#8217;red&#8217;, alpha=0.5) # alpha\u306f\u900f\u904e\u5ea6<br \/>\n&gt;&gt;&gt;\u00a0 plt.show()<\/p>\n<p>\u3053\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u30d5\u30a1\u30a4\u30eb\u306f\u6b21\u304b\u3089\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3067\u304d\u307e\u3059\u3002<br \/>\n<a href=\"https:\/\/drive.google.com\/file\/d\/1xclNcNzlbMrQ7ExzFSkxtSqGGr8ioYY9\/view?usp=sharing\" target=\"_blank\" rel=\"noopener\">https:\/\/drive.google.com\/file\/d\/1xclNcNzlbMrQ7ExzFSkxtSqGGr8ioYY9\/view?usp=sharing<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0%E5%AE%9F%E8%A1%8C%E7%B5%90%E6%9E%9C-2\"><\/span>\u30d7\u30ed\u30b0\u30e9\u30e0\u5b9f\u884c\u7d50\u679c<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>jukaiki1.py\u3092\u5b9f\u884c\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002\u6b21\u306e3D\u30b0\u30e9\u30d5\u304c\u51fa\u529b\u3055\u308c\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-18085 size-full\" src=\"https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2022\/10\/20221031-5.jpg\" alt=\"\" width=\"800\" height=\"526\" srcset=\"https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2022\/10\/20221031-5.jpg 800w, https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2022\/10\/20221031-5-300x197.jpg 300w, https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2022\/10\/20221031-5-768x505.jpg 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>\u56de\u5e30\u4fc2\u6570\u3092\u6c42\u3081\u308b\u305f\u3081\u306e\u30b3\u30fc\u30c9\u306f\u6b21\u306e3\u884c\u3067\u3059\u3002<br \/>\n&gt;&gt;&gt;\u00a0 ones = np.ones(len(x1))<br \/>\n&gt;&gt;&gt;\u00a0 X = np.array([ones, x1, x2]).T # \u8aac\u660e\u5909\u6570\u884c\u5217<br \/>\n&gt;&gt;&gt;\u00a0 theta = np.linalg.inv(X.T @ X) @ X.T @ y<\/p>\n<p>\u56de\u5e30\u4fc2\u6570\u306f\u30d9\u30af\u30c8\u30eb\u30c7\u30fc\u30bftheta\u3068\u3057\u3066\u5f97\u3089\u308c\u307e\u3059\u3002\u3053\u306e3\u884c\u306e\u30b3\u30fc\u30c9\u306e\u4e2d\u306b\u542b\u307e\u308c\u308b\u306e\u304c\u6700\u5c0f2\u4e57\u6cd5\u3068\u7dda\u5f62\u4ee3\u6570\u5b66\u3067\u3059\u3002<\/p>\n<p>\u6b21\u56de\u306f\u3044\u3088\u3044\u3088\u56de\u5e30\u5206\u6790\u306e\u6838\u5fc3\u3078\u3068\u8feb\u3063\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u56de\u5e30\u76f4\u7dda\u30921\u884c\u306e\u30b3\u30fc\u30c9\u3067\u63cf\u304f \u524d\u56de\u3001\u56de\u5e30\u76f4\u7dda\u3092\u5f97\u308b\u306e\u306bnumpy.profit\u95a2\u6570\u3092\u7528\u3044\u308b\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002 &gt;&gt;&gt;\u00a0 a, b = np.polyfit(x1_data, y_d &#8230; <\/p>\n","protected":false},"author":4,"featured_media":18085,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,464,526],"tags":[65,750],"class_list":["post-18075","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-4","category-hito-star-mathmatics","category-526","tag-python","tag-750"],"jetpack_featured_media_url":"https:\/\/club.informatix.co.jp\/wp-content\/uploads\/2022\/10\/20221031-5.jpg","_links":{"self":[{"href":"https:\/\/club.informatix.co.jp\/index.php?rest_route=\/wp\/v2\/posts\/18075","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/club.informatix.co.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/club.informatix.co.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/club.informatix.co.jp\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/club.informatix.co.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=18075"}],"version-history":[{"count":7,"href":"https:\/\/club.informatix.co.jp\/index.php?rest_route=\/wp\/v2\/posts\/18075\/revisions"}],"predecessor-version":[{"id":20762,"href":"https:\/\/club.informatix.co.jp\/index.php?rest_route=\/wp\/v2\/posts\/18075\/revisions\/20762"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/club.informatix.co.jp\/index.php?rest_route=\/wp\/v2\/media\/18085"}],"wp:attachment":[{"href":"https:\/\/club.informatix.co.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=18075"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/club.informatix.co.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=18075"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/club.informatix.co.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=18075"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}