{"id":109,"date":"2019-11-15T15:49:13","date_gmt":"2019-11-15T06:49:13","guid":{"rendered":"http:\/\/aiacademy.jp\/media\/?p=109"},"modified":"2024-08-06T16:27:51","modified_gmt":"2024-08-06T07:27:51","slug":"%e3%80%90%e5%88%9d%e5%bf%83%e8%80%85%e5%90%91%e3%81%91%e3%80%91python%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e6%a9%9f%e6%a2%b0%e5%ad%a6%e7%bf%92%e3%83%97%e3%83%ad%e3%82%b0%e3%83%a9%e3%83%9f%e3%83%b3","status":"publish","type":"post","link":"https:\/\/aiacademy.jp\/media\/?p=109","title":{"rendered":"\u3010\u521d\u5fc3\u8005\u5411\u3051\u3011Python\u3092\u4f7f\u3063\u3066\u6a5f\u68b0\u5b66\u7fd2\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u4f53\u9a13\u3057\u3066\u307f\u3088\u3046\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<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\">Google Colaboratory\u3067\u6a5f\u68b0\u5b66\u7fd2\u3092\u306f\u3058\u3081\u3088\u3046\uff01<\/a>  <\/li>  <li>    <a href=\"#i-2\">\u30ce\u30fc\u30c8\u30d6\u30c3\u30af\u306e\u4f5c\u6210<\/a>  <\/li>  <li>    <a href=\"#i-3\">GPU\u3092\u4f7f\u3063\u3066\u307f\u308b<\/a>  <\/li>  <li>    <a href=\"#i-4\">\u6559\u5e2b\u3042\u308a\u5b66\u7fd2<\/a>  <\/li>  <li>    <a href=\"#i-5\">\u6a5f\u68b0\u5b66\u7fd2\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u4f53\u9a13\uff08\u6982\u8981\uff09<\/a>  <\/li>  <li>    <a href=\"#i-6\">\u6a5f\u68b0\u5b66\u7fd2\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u4f53\u9a13\uff08\u5b9f\u88c5\uff09<\/a>  <\/li>  <li class=\"last\">    <a href=\"#i-7\">\u307e\u3068\u3081<\/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><strong>\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001\u624b\u3063\u53d6\u308a\u65e9\u304f\u6a5f\u68b0\u5b66\u7fd2\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3092\u4f53\u9a13\u3059\u308b\u3053\u3068\u3092\u76ee\u7684\u3068\u3057\u3066\u3044\u307e\u3059\u3002<\/strong><br>\u305d\u306e\u305f\u3081\u3001Python\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306e\u57fa\u672c\u6587\u6cd5\u53ca\u3073\u3001Scikit-learn(\u30b5\u30a4\u30ad\u30c3\u30c8\u30e9\u30fc\u30f3)\u3084NumPy(\u30ca\u30e0\u30d1\u30a4\/\u30ca\u30f3\u30d1\u30a4)\u3084Pandas(\u30d1\u30f3\u30c0\u30b9)\u3001Matplotlib(\u30de\u30c3\u30c8\u30d7\u30ed\u30c3\u30c8\u30ea\u30d6)\u3068\u3044\u3063\u305fPython\u3067\u30c7\u30fc\u30bf\u5206\u6790\u3092\u884c\u3046\u969b\u306b\u5fc5\u9808\u3068\u306a\u308b\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9\u3084\u8aac\u660e\u306f\u3053\u306e\u7ae0\u3067\u306f\u5272\u611b\u81f4\u3057\u307e\u3059\u306e\u3067\u3001\u3054\u4e86\u627f\u304f\u3060\u3055\u3044\u3002<br>\u4e0a\u8a18\u3092\u8a73\u3057\u304f\u5b66\u3073\u305f\u3044\u65b9\u306f\u305d\u308c\u305e\u308cAI Academy\u3067\u5b66\u3076\u3053\u3068\u304c\u51fa\u6765\u307e\u3059\u306e\u3067\u3001\u3053\u306e\u7ae0\u3092\u7d42\u3048\u3066\u304b\u3089\u662f\u975e\u30c1\u30e3\u30ec\u30f3\u30b8\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<br><a href=\"https:\/\/aiacademy.jp\/texts\/show\/?id=73\">Python\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0 \u57fa\u672c\u6587\u6cd5\u901f\u7fd2<\/a><br><a href=\"https:\/\/aiacademy.jp\/texts\/show\/?id=21\">NumPy\u5165\u9580<\/a><br><a href=\"https:\/\/aiacademy.jp\/texts\/show\/?id=23\">Pandas\u5165\u9580<\/a><br><a href=\"https:\/\/aiacademy.jp\/texts\/show\/?id=22\">Matplotlib\u5165\u9580<\/a><br><a href=\"https:\/\/aiacademy.jp\/texts\/#ml_tutorial\">\u6a5f\u68b0\u5b66\u7fd2\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u5165\u9580\u7de8<\/a><\/p>\n<p><strong><em>\u307e\u305f\u3001\u73fe\u5728\u306e\u30c6\u30ad\u30b9\u30c8\u306e\u30b3\u30fc\u30c9\u3067\u30ef\u30fc\u30cb\u30f3\u30b0\u304c\u51fa\u308b\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u3002<br>\u30ef\u30fc\u30cb\u30f3\u30b0\u306f\u81f4\u547d\u7684\u306a\u30a8\u30e9\u30fc\u3067\u306f\u306a\u3044\u306e\u3067\u3001\u52d5\u4f5c\u306b\u306f\u554f\u984c\u3042\u308a\u307e\u305b\u3093\u306e\u3067\u3001\u4e00\u65e6\u6c17\u306b\u305b\u305a\u9032\u3081\u3066\u304f\u3060\u3055\u3044\u3002<\/em><\/strong><\/p>\n<h2 id=\"i-1\">Google Colaboratory\u3067\u6a5f\u68b0\u5b66\u7fd2\u3092\u306f\u3058\u3081\u3088\u3046\uff01<\/h2>\n<p><strong>\u307e\u305a\u524d\u534a\u3067\u306f\u3001Google\u304c\u6a5f\u68b0\u5b66\u7fd2\u306e\u6559\u80b2\u53ca\u3073\u7814\u7a76\u7528\u306b\u63d0\u4f9b\u3057\u3066\u3044\u308bGoogle Colaboratory\uff08\u30b0\u30fc\u30b0\u30eb\u30fb\u30b3\u30e9\u30dc\u30ec\u30a4\u30c8\u30ea\u30fc\uff09\u306e\u4f7f\u3044\u65b9\u3092\u8aac\u660e\u3057\u3001\u5f8c\u534a\u3067Python\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3068\u6a5f\u68b0\u5b66\u7fd2\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3092\u884c\u3063\u3066\u3044\u304d\u307e\u3059\u3002<\/strong><br><strong><em>\u4eca\u56de\u4f7f\u3046Google\u306eColaboratory\u306f\u3001\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u4e0d\u8981\u304b\u3064\u3001Python\u3092\u7528\u3044\u305f\u6a5f\u68b0\u5b66\u7fd2\u74b0\u5883\u304c\u6574\u3048\u3089\u308c\u3066\u3044\u308b\u305f\u3081\u3001\u3059\u3050\u306bPython\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3092\u59cb\u3081\u308b\u3053\u3068\u304c\u53ef\u80fd\u306a\u7121\u6599\u306e\u30b5\u30fc\u30d3\u30b9\u3067\u3059\u3002<\/em><\/strong><br>\u8cbb\u7528\u306f\u7121\u6599\u3067CPU\u53ca\u3073<a href=\"?id=44&amp;section=CPU\u3068GPU\">GPU<\/a>(1\u56de12\u6642\u9593)\u306e\u74b0\u5883\u304c\u5229\u7528\u53ef\u80fd\u3067\u3001\u7528\u610f\u3059\u308b\u3082\u306e\u306f\u3001Google\u30a2\u30ab\u30a6\u30f3\u30c8\u3055\u3048\u3042\u308c\u3070\u5229\u7528\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/colab.research.google.com\/\" rel=\"nofollow noopener\" target=\"_blank\">Google Colaboratory\u306e\u30da\u30fc\u30b8\u3078<\/a><\/p>\n<h2 id=\"i-2\">\u30ce\u30fc\u30c8\u30d6\u30c3\u30af\u306e\u4f5c\u6210<\/h2>\n<p>\u300c\u6700\u8fd1\u306e\u30ce\u30fc\u30c8\u30d6\u30c3\u30af\u300d\u306e\u753b\u9762\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u306e\u3067\u3001\u753b\u9762\u306e\u5de6\u4e0b\u304b\u3089\u300cPYTHON3\u306e\u65b0\u3057\u3044\u30ce\u30fc\u30c8\u30d6\u30c3\u30af\u300d\u3092\u9078\u3073\u30af\u30ea\u30c3\u30af\u3057\u3066\u304f\u3060\u3055\u3044\u3002<br>\u307e\u305f\u306f\u3001\u5de6\u4e0a\u30e1\u30cb\u30e5\u30fc\u306e\u300ePython3 \u306e\u30ce\u30fc\u30c8\u30d6\u30c3\u30af\u3092\u65b0\u898f\u4f5c\u6210\u300f\u3067\u3082\u540c\u3058\u3088\u3046\u306b\u4f5c\u6210\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/qiita-image-store.s3.amazonaws.com\/0\/171715\/53225540-1e3d-0a31-e6b9-e1c7e20e78a8.png\" alt=\"\"><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/qiita-image-store.s3.amazonaws.com\/0\/171715\/c12c88b1-d17b-5b2b-418e-647d8dfdc79a.png\" alt=\"\"><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/qiita-image-store.s3.amazonaws.com\/0\/171715\/3e4ef4f9-9838-642d-4d5c-6f31a322dd08.png\" alt=\"\"><\/p>\n<p>\u30fb\u5de6\u4e0a\u30e1\u30cb\u30e5\u30fc\u306e\u300ePython3 \u306e\u30ce\u30fc\u30c8\u30d6\u30c3\u30af\u3092\u65b0\u898f\u4f5c\u6210\u300f\u306e\u5834\u5408<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/qiita-image-store.s3.amazonaws.com\/0\/171715\/a49ad7ce-990f-58fb-6873-7f81ee627a2b.png\" alt=\"\"><\/p>\n<p>Colaboratory\u306e\u753b\u9762\u304c\u8868\u793a\u3055\u308c\u307e\u3057\u305f\u3067\u3057\u3087\u3046\u304b\uff1f<br>\u3055\u3066\u3001\u9ed2\u4e38\u306e\u4e09\u89d2\u306e\u5b9f\u884c\u30dc\u30bf\u30f3\u306e\u53f3\u6a2a\u306b\u3042\u308b\u80cc\u666f\u304c\u8584\u3044\u9752\u8272\u306e\u30c6\u30ad\u30b9\u30c8\u30a8\u30c7\u30a3\u30bf\u304c\u3042\u308a\u307e\u3059\u306e\u3067\u3001\u305d\u3053\u306b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002<br>\uff08\u3053\u306e\u90e8\u5206\u3092\u30bb\u30eb\u3068\u547c\u3093\u3060\u308a\u3057\u307e\u3059\u3002\uff09<\/p>\n<pre><code>print(\"hello Python\")\n<\/code><\/pre>\n<p>\u59cb\u3081\u306f\u5c11\u3057\u6642\u9593\u304c\u304b\u304b\u308a\u307e\u3059\u304c\u3001\u5c11\u3057\u5f85\u3064\u3068\u7d50\u679c\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<br>\u3061\u306a\u307f\u306b\u4f5c\u6210\u3057\u305f\u30ce\u30fc\u30c8\u30d6\u30c3\u30af\u306f\u3001\u81ea\u52d5\u7684\u306bGoogle Drive\u306b\u4fdd\u5b58\u3055\u308c\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/qiita-image-store.s3.amazonaws.com\/0\/171715\/a4802774-a67c-5bfc-eb92-5f6831abcb2b.png\" alt=\"\"><\/p>\n<p>\u6b21\u306f\u3001Python\u306e\u30b0\u30e9\u30d5\u63cf\u753b\u30e2\u30b8\u30e5\u30fc\u30eb\u3067\u3042\u308bMatplotlib\u3092\u4f7f\u3044\u3001\u30b0\u30e9\u30d5\u3092\u63cf\u753b\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<pre><code>import numpy as np\nimport matplotlib.pyplot as plt\n\nx = np.arange(0, 10, 0.1)\nplt.plot(x)\nplt.show()\n<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/qiita-image-store.s3.amazonaws.com\/0\/171715\/bfe0141d-7460-66dc-9acd-a81a39c84a18.png\" alt=\"\"><\/p>\n<h2 id=\"i-3\">GPU\u3092\u4f7f\u3063\u3066\u307f\u308b<\/h2>\n<p>\u30ce\u30fc\u30c8\u30d6\u30c3\u30af\u4f5c\u6210\u6642\u306b\u306f\u3001GPU\u3067\u306f\u306a\u3044\u305f\u3081\u3001\u4e0b\u8a18\u64cd\u4f5c\u306b\u3066<a href=\"?id=44&amp;section=CPU\u3068GPU\">GPU<\/a>\u3092\u4f7f\u3048\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u4e0a\u90e8\u30e1\u30cb\u30e5\u30fc\u306e\u3000\u30e9\u30f3\u30bf\u30a4\u30e0 &gt; \u30e9\u30f3\u30bf\u30a4\u30e0\u306e\u30bf\u30a4\u30d7\u3092\u5909\u66f4\u3092\u9078\u629e\u3057\u3001\u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u30a2\u30af\u30bb\u30e9\u30ec\u30fc\u30bf\u3092None \u304b\u3089GPU\u306b\u5909\u66f4\u3057\u3066\u4fdd\u5b58\u3057\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/qiita-image-store.s3.amazonaws.com\/0\/171715\/3b808540-7d1f-1053-9914-dd6fede30777.png\" alt=\"\"><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/qiita-image-store.s3.amazonaws.com\/0\/171715\/dd14549b-fcb1-7489-db30-fda946a245c9.png\" alt=\"\"><\/p>\n<p>\u3055\u3066\u3001\u4e0b\u8a18\u3092\u5b9f\u884c\u3057<strong>\u2018\/device:GPU:0\u2019<\/strong>\u3068\u51fa\u529b\u3055\u308c\u3066\u3044\u308c\u3070GPU\u304c\u5229\u7528\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/qiita-image-store.s3.amazonaws.com\/0\/171715\/3def1337-3338-01e4-b2e6-0a324b7faac6.png\" alt=\"\"><\/p>\n<p>\u307e\u305f\u3001<\/p>\n<pre><code>!cat \/proc\/cpuinfo\n<\/code><\/pre>\n<p>\u53ca\u3073\u3001<\/p>\n<pre><code>!cat \/proc\/meminfo\n<\/code><\/pre>\n<p>\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001Colaboratory\u306e\u30de\u30b7\u30f3\u30b9\u30da\u30c3\u30af\u3092\u8abf\u3079\u308b\u3053\u3068\u304c\u51fa\u6765\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/qiita-image-store.s3.amazonaws.com\/0\/171715\/d9af58e9-dd89-022f-4b5b-93b660aea506.png\" alt=\"\"><\/p>\n<h2 id=\"i-4\">\u6559\u5e2b\u3042\u308a\u5b66\u7fd2<\/h2>\n<p>\u6a5f\u68b0\u5b66\u7fd2\u306b\u306f\u3001\u6559\u5e2b\u3042\u308a\u5b66\u7fd2\u3001\u6559\u5e2b\u306a\u3057\u5b66\u7fd2\u3001\u5f37\u5316\u5b66\u7fd2\u306e\uff13\u3064\u306b\u5206\u3051\u3089\u308c\u3001\u3053\u306e\u30c6\u30ad\u30b9\u30c8\u3067\u306f<strong>\u6559\u5e2b\u3042\u308a\u5b66\u7fd2<\/strong>\u3092\u7528\u3044\u307e\u3059\u3002<br><strong>\u6559\u5e2b\u3042\u308a\u5b66\u7fd2\u306f\u5165\u529b\u30c7\u30fc\u30bf\u3068\u6b63\u89e3\u306e\u30da\u30a2(\u6559\u5e2b\u30c7\u30fc\u30bf)\u3092\u4e0e\u3048\u3066\u3001\u305d\u308c\u3092\u3082\u3068\u306b\u5b66\u7fd2\u3059\u308b\u65b9\u6cd5\u3067\u3059\u3002<\/strong><\/p>\n<p><img decoding=\"async\" src=\"\/assets\/images_test\/162_16c36d4a55f.png\" alt=\"\"><\/p>\n<h2 id=\"i-5\">\u6a5f\u68b0\u5b66\u7fd2\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u4f53\u9a13\uff08\u6982\u8981\uff09<\/h2>\n<p>\u3053\u306e\u30c6\u30ad\u30b9\u30c8\u3067\u306f\u3001Iris\uff08\u30a2\u30e4\u30e1\uff09\u3068\u3044\u3046\u82b1\u306e\u54c1\u7a2e\u3092\u5224\u5b9a\u3067\u304d\u308b\u5206\u985e\u5668\u3092\u4f5c\u3063\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/camo.qiitausercontent.com\/cd7ccdda3d5538ab97b06ba986dabd9695f5c6d4\/68747470733a2f2f71696974612d696d6167652d73746f72652e73332e616d617a6f6e6177732e636f6d2f302f3137313731352f38653838636131322d396530652d363738392d393333312d6139623732383331633236652e706e67\" alt=\"\"><\/p>\n<p>\u4e0a\u8a18\u306e\u753b\u50cf\u3092\u898b\u3066\u5206\u304b\u308b\u901a\u308a\u30013\u7a2e\u985e\u3068\u3082\u3068\u3066\u3082\u3088\u304f\u4f3c\u3066\u304a\u308a\u307e\u3059\u3002<br>\u3053\u306e3\u7a2e\u985e\u306e\u82b1\u306e\u3046\u3061\u3001\u3069\u306e\u82b1\u306a\u306e\u304b\u3092\u5224\u5b9a\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u6a5f\u68b0\u5b66\u7fd2\u3092\u4f7f\u3063\u3066\u3001\u5b9f\u88c5\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001\u4eca\u56de\u306f\u6559\u5e2b\u3042\u308a\u5b66\u7fd2\u3092\u5229\u7528\u3057\u307e\u3059\u306e\u3067\u3001\u30c7\u30fc\u30bf\u306b\u306f\u305d\u308c\u305e\u308c\u3001Setosa(\u4e00\u756a\u53f3)\u306b\u306f0\u3001Versicolor(\u4e00\u756a\u5de6)\u306b\u306f1\u3001Versinica(\u4e2d\u592e)\u306b\u306f\u30012\u306e\u6b63\u89e3\u30e9\u30d9\u30eb\u304c\u4e0e\u3048\u3089\u308c\u3066\u3044\u307e\u3059\u3002<br><a href=\"http:\/\/dataaspirant.com\/2017\/01\/25\/svm-classifier-implemenation-python-scikit-learn\/\" rel=\"nofollow noopener\" target=\"_blank\">\u753b\u50cf\u5f15\u7528\u5143: SUPPORT VECTOR MACHINE (SVM CLASSIFIER) IMPLEMENATION IN PYTHON WITH SCIKIT-LEARN<\/a><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/camo.qiitausercontent.com\/38ba2b7178699dbf30c0dcac4ec8645667af673b\/68747470733a2f2f71696974612d696d6167652d73746f72652e73332e616d617a6f6e6177732e636f6d2f302f3137313731352f37356137636664352d313331372d616332632d346636312d3230343935613432336335372e706e67\" alt=\"\"><\/p>\n<p><a href=\"http:\/\/sebastianraschka.com\/Articles\/2014_python_lda.html\" rel=\"nofollow noopener\" target=\"_blank\">\u753b\u50cf\u5f15\u7528\u5143: iris dataset<\/a><br><strong>petal: \u82b1\u5f01<\/strong><br><strong>sepal: \u304c\u304f<\/strong><\/p>\n<p>\u30a2\u30e4\u30e1\u306e\u54c1\u7a2e\u5206\u985e\u30bf\u30b9\u30af\u306f\u3001<strong>\u82b1\u306e\u304c\u304f\u306e\u9577\u3055\u3068\u82b1\u306e\u304c\u304f\u306e\u5e45\u3001\u82b1\u306e\u82b1\u5f01\u306e\u9577\u3055\u3068\u82b1\u306e\u82b1\u5f01\u306e\u5e45<\/strong>\u306e4\u3064\u3092\u7528\u3044\u3066\u3001<strong>\u82b1\u306e\u54c1\u7a2e\u3092\u5206\u985e\u3057\u3088\u3046<\/strong>\u3068\u3044\u3046\u3082\u306e\u3067\u3059\u3002<br>\u3067\u3059\u306e\u3067\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u306e\u4e2d\u306b\u306f\u3001<strong><em>4\u3064\u306e\u6e2c\u5b9a\u5024(\u7279\u5fb4\u91cf)\u30683\u7a2e\u985e\u306e\u82b1(Setosal\u3001Versicolor\u3001Versinica)\u304c\u30bb\u30c3\u30c8\u306b\u306a\u3063\u305f\u30c7\u30fc\u30bf\u304c150\u500b\u4e0e\u3048\u3089\u308c\u3066\u3044\u307e\u3059\u3002<\/em><\/strong><\/p>\n<table>\n<thead>\n<tr>\n<th>\u756a\u53f7<\/th>\n<th>\u9577\u3055\u30fb\u5e45(cm)<\/th>\n<th>Petal\u3068Sepal<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>Sepal Length<\/td>\n<td>Sepal\uff08\u304c\u304f\u306e\u9577\u3055\uff09\u306e\u9577\u3055<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>Sepal Width<\/td>\n<td>Sepal\uff08\u304c\u304f\u306e\u9577\u3055\uff09\u306e\u5e45<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>Petal length<\/td>\n<td>Petal\uff08\u82b1\u3073\u3089\uff09\u306e\u9577\u3055<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td>petal Width<\/td>\n<td>Petal\uff08\u82b1\u3073\u3089\uff09\u306e\u5e45<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u305d\u3057\u3066\u3001\u6b63\u89e3\u5024(\u30e9\u30d9\u30eb: \u82b1\u306e\u540d\u79f0)\u306f\u3001\u305d\u308c\u305e\u308c\u4e0b\u8a18\u306b\u306a\u308a\u307e\u3059\u3002<br>0: Setosa<br>1: Versicolor<br>2: Versinica<\/p>\n<p><strong><em>\u304f\u3069\u3044\u3088\u3046\u3067\u3059\u304c\u3001\u4eca\u56de\u306e\u76ee\u7684\u306f\u30014\u3064\u306e\u6e2c\u5b9a\u5024\u304c\u30e2\u30c7\u30eb\u306b\u5165\u529b\u3055\u308c\u305f\u3068\u304d\u3001\u82b1\u306e\u54c1\u7a2e\u30923\u7a2e\u985e(Setosa\u3001Versicolor\u3001Versinica)\u306e\u3046\u3061\u3001\u3069\u306e\u82b1\u306b\u8a72\u5f53\u3059\u308b\u306e\u304b\u3092\u5f53\u3066\u3089\u308c\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/em><\/strong><\/p>\n<p>\u6b21\u306f\u518d\u5ea6\u3001\u5165\u529b\u3068\u51fa\u529b\u306e\u95a2\u4fc2\u3092\u78ba\u8a8d\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/aiacademy.jp\/assets\/images\/iris.png\" alt=\"\"><\/p>\n<p>\u4e0a\u306e\u753b\u50cf\u3067\u306f\u5165\u529b\u306b\u753b\u50cf\u3092\u5165\u529b\u3057\u3066\u3044\u308b\u3088\u3046\u3067\u3059\u304c\u3001\u5b9f\u969b\u306f\u3001\u304c\u304f\u306e\u9577\u3055\u3084\u304c\u304f\u306e\u5e45\u3001\u82b1\u3073\u3089\u306e\u9577\u3055\u3001\u82b1\u3073\u3089\u306e\u5e45\u306e4\u3064\u306e\u6e2c\u5b9a\u5024\u306f\u3092\u5165\u529b\u3057\u307e\u3059\u3002<br>\u4f8b\u3048\u3070\u3001\u5165\u529b\u3068\u306a\u308b4\u3064\u306e\u5024\u304c\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><strong>\u5165\u529b\u4f8b<\/strong><\/p>\n<table>\n<thead>\n<tr>\n<th>\u7279\u5fb4<\/th>\n<th>cm<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u304c\u304f\u306e\u9577\u3055(Sepal Length)<\/td>\n<td>1.4<\/td>\n<\/tr>\n<tr>\n<td>\u304c\u304f\u306e\u5e45 (Sepal Width)<\/td>\n<td>3.5<\/td>\n<\/tr>\n<tr>\n<td>\u82b1\u3073\u3089\u306e\u9577\u3055 (Petal Length)<\/td>\n<td>5.1<\/td>\n<\/tr>\n<tr>\n<td>\u82b1\u3073\u3089\u306e\u5e45 (Petal Width)<\/td>\n<td>0.2<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Python\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u306f\u6b21\u306e\u3088\u3046\u306b\u66f8\u304d\u307e\u3059\u3002<\/strong><\/p>\n<pre><code class=\"python:\">\"\"\"\n\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u6a5f\u68b0\u5b66\u7fd2\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u4f53\u9a13\uff08\u5b9f\u88c5\uff09\u3067\u5b9f\u88c5\u3057\u307e\u3059\u304c\u3001\n\u4ee5\u4e0b\u306e\u51e6\u7406\u307e\u3067\u306b\u306f\u3001\u30c7\u30fc\u30bf\u306e\u8aad\u307f\u8fbc\u307f\u3001\u30e2\u30c7\u30eb\u306e\u4f5c\u6210\u3001\u5b66\u7fd2\u3068\u3044\u3063\u305f\u6d41\u308c\u3092\u884c\u3044\u307e\u3059\u3002\n\"\"\"\n\nmodel.predict([[1.4, 3.5, 5.1, 0.2]])\n<\/code><\/pre>\n<p><strong>\u51fa\u529b\u306f\u4f8b\u3048\u3070\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/strong><br><strong>\u4f8b\u3048\u3070\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u51fa\u529b\u5024\u304c2(\u3064\u307e\u308aVersinica\u3068\u5224\u5b9a\uff09\u3068\u8fd4\u3063\u3066\u304d\u307e\u3059\u3002<\/strong><\/p>\n<pre><code class=\"shell:\">[2]\n<\/code><\/pre>\n<h2 id=\"i-6\">\u6a5f\u68b0\u5b66\u7fd2\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u4f53\u9a13\uff08\u5b9f\u88c5\uff09<\/h2>\n<p>\u6982\u8aac\u306f\u4ee5\u4e0a\u306b\u3057\u3001\u5b9f\u88c5\u3092\u3057\u3066\u3044\u304d\u307e\u3059\u3002<br>\u3055\u3066\u3001\u3053\u3053\u3067\u306f<a href=\"https:\/\/aiacademy.jp\/texts\/show\/?id=178\">SVM\uff08\u30b5\u30dd\u30fc\u30c8\u30d9\u30af\u30bf\u30fc\u30de\u30b7\u30f3\uff09<\/a>\u3068\u547c\u3070\u308c\u308b\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u3092\u4f7f\u3063\u3066\u5206\u985e\u3092\u884c\u306a\u3044\u307e\u3059\u3002<br>\u307e\u305a\u306f\u3001sklearn\u304b\u3089\u3001Iris\u306edataset\u3068SVM\u3092\u8aad\u307f\u8fbc\u307f\u307e\u3059\u3002<\/p>\n<pre><code class=\"python:\">from sklearn import datasets\nfrom sklearn import svm\n<\/code><\/pre>\n<p>\u6b21\u306b\u3001Iris\u304c\u6301\u3063\u3066\u3044\u308b\u30c7\u30fc\u30bf\u306e\u5185\u5bb9\u3068Iris\u306e\u5f62\u72b6\u3092\u51fa\u529b\u3057\u307e\u3059\u3002<\/p>\n<pre><code># Iris\u306e\u6e2c\u5b9a\u30c7\u30fc\u30bf\u306e\u8aad\u307f\u8fbc\u307f\niris = datasets.load_iris()\n\nprint(iris.data)\nprint(iris.data.shape) # \u5f62\u72b6\n<\/code><\/pre>\n<p>\u51fa\u529b\u3059\u308b\u3068\u3001Iris\u306b\u306f150\u306e\u30c7\u30fc\u30bf\u304c\u3042\u308b\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3059\u3002<br>\u6b21\u306b\u30c7\u30fc\u30bf\u306e\u9577\u3055\u3092\u8abf\u3079\u3066\u307f\u307e\u3059\u3002<\/p>\n<pre><code>num = len(iris.data)\nprint(num)\n<\/code><\/pre>\n<p>\u3067\u306f\u3001\u30b5\u30dd\u30fc\u30c8\u30d9\u30af\u30bf\u30fc\u30de\u30b7\u30f3\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002<br>\u3055\u304d\u307b\u3069\u306e\u3001print\u306e\u51e6\u7406\u306f\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre><code class=\"python:\">\"\"\"\n\u5192\u982d\u306e\u306f\u3058\u3081\u306b\u306b\u3082\u66f8\u304d\u307e\u3057\u305f\u901a\u308a\u3001\u73fe\u5728\u306e\u30c6\u30ad\u30b9\u30c8\u306e\u30b3\u30fc\u30c9\u3067\u30ef\u30fc\u30cb\u30f3\u30b0\u304c\u51fa\u308b\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u3002\n\u30ef\u30fc\u30cb\u30f3\u30b0\u306f\u81f4\u547d\u7684\u306a\u30a8\u30e9\u30fc\u3067\u306f\u306a\u3044\u306e\u3067\u3001\u52d5\u4f5c\u306b\u306f\u554f\u984c\u3042\u308a\u307e\u305b\u3093\u3002\u305d\u306e\u305f\u3081\u4e00\u65e6\u6c17\u306b\u305b\u305a\u9032\u3081\u3066\u304f\u3060\u3055\u3044\u3002\n\"\"\"\nclf = svm.SVC(gamma=\"auto\")\nclf.fit(iris.data, iris.target)\n<\/code><\/pre>\n<p>\u3053\u3053\u3067\u3001svm.SVC()\u3068fit()\u306b\u95a2\u3057\u3066\u8aac\u660e\u3057\u307e\u3059\u3002<br>\u307e\u305a\u3001<strong>svm.SVC()\u306f\u3001SVM(\u30b5\u30dd\u30fc\u30c8\u30d9\u30af\u30bf\u30fc\u30de\u30b7\u30f3)\u3068\u3044\u3046\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u3067\u3059\u3002<\/strong><br>Scikit-learn\u3067\u306f\u5206\u985e\u306b\u95a2\u3059\u308bSVM\u306f3\u7a2e\u985e(SVC,LinearSVC,NuSVC)\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u3002<br>\u305d\u306e\u4e2d\u306eSVC()\u3092\u5229\u7528\u3057\u307e\u3059\u3002<br>\u6b21\u306b\u3001fit()\u3067\u3059\u304c\u3001<strong>fit()\u3092\u4f7f\u3046\u4e8b\u3067\u5b66\u7fd2(\u6a5f\u68b0\u5b66\u7fd2)\u304c\u884c\u3048\u307e\u3059\u3002<\/strong><br>fit()\u306e\u7b2c1\u5f15\u6570\u306b\u7279\u5fb4\u91cfX\u3092\u4e0e\u3048\u3001\u7b2c2\u5f15\u6570\u306b\u30e9\u30d9\u30eb\u30c7\u30fc\u30bfY\u3092\u4e0e\u3048\u5229\u7528\u3057\u307e\u3059\u3002<br>\u7d9a\u3044\u3066\u3001\u4f5c\u3063\u305f\u30e2\u30c7\u30eb\u306b\u95a2\u3057\u3066\u3001\u4e88\u6e2c\u3092\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<br>\u4e0e\u3048\u305f\u3082\u306e\u3068\u3057\u3066\u306f\u3001<br>\u304c\u304f\u306e\u9577\u3055\u304c1.4<br>\u304c\u304f\u306e\u5e45\u304c1.8<br>\u82b1\u3073\u3089\u306e\u9577\u3055\u304c3.9<br>\u82b1\u3073\u3089\u306e\u5e45\u304c0.5<br>\u306e\u3082\u306e\u306f\u3069\u306e\u82b1\u304b\u3068\u3044\u3046\u3082\u306e\u3067\u3059\u3002<\/p>\n<pre><code>print(clf.predict([[1.4, 1.8, 3.9, 0.5]]))\n<\/code><\/pre>\n<p>\u51fa\u529b\u306f0,1,2(\u82b1\u306e\u30e9\u30d9\u30eb)\u306e\u3069\u308c\u304b\u306b\u306a\u308a\u307e\u3059\u304c\u3001<strong>\u82b1\u306e\u304c\u304f\u306e\u9577\u3055\u3068\u82b1\u306e\u304c\u304f\u306e\u5e45\u3001\u82b1\u306e\u82b1\u5f01\u306e\u9577\u3055\u3068\u82b1\u306e\u82b1\u5f01\u306e\u5e45<\/strong>\u3092\u5165\u529b\u3059\u308b\u3068\u3001<strong>\u82b1\uff08\u306e\u30e9\u30d9\u30eb\uff09<\/strong>\u3092\u4e88\u6e2c\u304c\u51fa\u6765\u307e\u3057\u305f\u3002<br>\u3053\u3053\u307e\u3067\u306e\u5168\u4f53\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3067\u3059\u3002<\/p>\n<pre><code class=\"python:\">\"\"\"\nfrom sklearn import datasets\nfrom sklearn import svm\n\n# Iris\u306e\u6e2c\u5b9a\u30c7\u30fc\u30bf\u306e\u8aad\u307f\u8fbc\u307f\niris = datasets.load_iris()\nclf = svm.SVC()\nclf.fit(iris.data, iris.target)\nprint(clf.predict([[1.4, 3.5, 5.1, 0.2], [6.5, 2.6, 4.4, 1.4], [5.9, 3.0, 5.2, 1.5]]))\n\"\"\"\n\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.ensemble import RandomForestClassifier\nfrom sklearn import svm\nfrom sklearn.metrics import accuracy_score\n\n# \u30c7\u30fc\u30bf\u306e\u8aad\u307f\u8fbc\u307f\niris = datasets.load_iris()\nx, y = iris.data, iris.target\n\n# \u30c8\u30ec\u30fc\u30cb\u30f3\u30b0\u30c7\u30fc\u30bf\u3068\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u306b\u5206\u3051\u308b\nx_train, x_test, y_train, y_test = train_test_split(x, y, random_state=1)\n\n# \u30e2\u30c7\u30eb\u306e\u9078\u629e\nmodel = svm.SVC()\n# \u5b66\u7fd2\nmodel.fit(x_train, y_train)\n\n# \u8a55\u4fa1\npred = model.predict(x_test)\nprint(accuracy_score(y_test, pred))\n\n# \u5b66\u7fd2\u6e08\u307f\u30e2\u30c7\u30eb\u3092\u4f7f\u3046\nprint(model.predict([[1.4, 3.5, 5.1, 0.2]]))\n\n# \u6b21\u306e\u3088\u3046\u306b\u3001\u8907\u6570\u6e21\u3059\u3053\u3068\u3082\u53ef\u80fd\n# print(model.predict([[1.4, 3.5, 5.1, 0.2], [6.5, 2.6, 4.4, 1.4], [5.9, 3.0, 5.2, 1.5]]))\n<\/code><\/pre>\n<h2 id=\"i-7\">\u307e\u3068\u3081<\/h2>\n<p>\u3053\u306e\u7ae0\u3067\u306f\u3001Scikit-learn\u3092\u4f7f\u3063\u3066\u30a2\u30a4\u30ea\u30b9\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u306e\u54c1\u7a2e\u5206\u985e\u3092\u884c\u3044\u6a5f\u68b0\u5b66\u7fd2\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3092\u4f53\u9a13\u3057\u307e\u3057\u305f\u3002<br>\u4eca\u56de\u6271\u3063\u305f\u30c6\u30fc\u30de\u306f\u3001\u6a5f\u68b0\u5b66\u7fd2\u306e\u6559\u5e2b\u3042\u308a\u5b66\u7fd2\u306e\u5206\u985e\u306b\u95a2\u3057\u3066\u306e\u307f\u3067\u3059\u3002<br>\u4ed6\u306b\u3082\u3001\u56de\u5e30\u306a\u3069\u3082\u3042\u308a\u307e\u3059\u306e\u3067\u3001\u3082\u3063\u3068\u5b66\u3073\u305f\u3044\u65b9\u306f<a href=\"https:\/\/aiacademy.jp\/texts\/#ml_tutorial\">\u6a5f\u68b0\u5b66\u7fd2\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u5165\u9580\u7de8<\/a>\u3092\u9032\u3081\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"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 Google Colaboratory\u3067\u6a5f\u68b0\u5b66\u7fd2\u3092\u306f\u3058\u3081\u3088\u3046\uff01 \u30ce\u30fc\u30c8\u30d6\u30c3\u30af\u306e\u4f5c\u6210 GPU\u3092\u4f7f\u3063\u3066\u307f\u308b \u6559\u5e2b\u3042\u308a\u5b66\u7fd2 \u6a5f\u68b0\u5b66\u7fd2\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u4f53\u9a13\uff08\u6982\u8981\uff09 \u6a5f\u68b0\u5b66\u7fd2\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u4f53\u9a13\uff08\u5b9f\u88c5\uff09 \u307e\u3068\u3081 \u306f\u3058\u3081 &#8230; <\/p>\n","protected":false},"author":1,"featured_media":487,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[85],"tags":[],"class_list":{"0":"post-109","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-python"},"_links":{"self":[{"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=\/wp\/v2\/posts\/109","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=109"}],"version-history":[{"count":5,"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=\/wp\/v2\/posts\/109\/revisions"}],"predecessor-version":[{"id":4741,"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=\/wp\/v2\/posts\/109\/revisions\/4741"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=\/wp\/v2\/media\/487"}],"wp:attachment":[{"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=109"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=109"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}