{"id":263,"date":"2020-01-24T15:44:12","date_gmt":"2020-01-24T06:44:12","guid":{"rendered":"http:\/\/aiacademy.jp\/media\/?p=263"},"modified":"2025-06-02T12:43:39","modified_gmt":"2025-06-02T03:43:39","slug":"%e4%ba%a4%e5%b7%ae%e6%a4%9c%e8%a8%bc%ef%bc%88%e3%82%af%e3%83%ad%e3%82%b9%e3%83%90%e3%83%aa%e3%83%87%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%ef%bc%89%e3%81%a8%e3%81%af%ef%bc%9f%e5%90%88%e3%82%8f%e3%81%9b","status":"publish","type":"post","link":"https:\/\/aiacademy.jp\/media\/?p=263","title":{"rendered":"\u4ea4\u5dee\u691c\u8a3c\uff08\u30af\u30ed\u30b9\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\uff09\u3068\u306f\uff1f\u5408\u308f\u305b\u3066\u30b0\u30ea\u30c3\u30c9\u30b5\u30fc\u30c1\u306b\u95a2\u3057\u3066\u3082\u5b66\u307c\u3046\uff01"},"content":{"rendered":"\n<p><span class=\"keiko_blue\">\u3053\u306e\u30b5\u30a4\u30c8\u306f\u3001Python\u3084\u751f\u6210AI\u306a\u3069\u3092\u5b66\u3079\u308b\u30aa\u30f3\u30e9\u30a4\u30f3\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30b9\u30af\u30fc\u30eb AI Academy Bootcamp\u304c\u904b\u55b6\u3057\u3066\u3044\u307e\u3059\u3002<\/span><\/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\">    <span><\/span>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-0\">\u5206\u985e\u3068\u56de\u5e30\u306b\u4f7f\u3048\u308b\u8a55\u4fa1\u65b9\u6cd5<\/a>      <\/li>      <li>        <a href=\"#i-1\">\u30db\u30fc\u30eb\u30c9\u30a2\u30a6\u30c8\u6cd5<\/a>      <\/li>      <li>        <a href=\"#i-2\">\u4ea4\u5dee\u691c\u8a3c(\u30af\u30ed\u30b9\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3)<\/a>      <\/li>      <li>        <a href=\"#i-3\"><\/a>      <\/li>      <li>        <a href=\"#i-4\">\u3010\u7121\u6599\u52d5\u753b\uff1a\u500d\u901f\u3067\u5b66\u3076\uff01\u751f\u6210AI\u3092\u6d3b\u7528\u3057\u305f\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u52c9\u5f37\u6cd5\uff08\u77ed\u7e2e\u7248\uff09\u3011<\/a>      <\/li>      <li>        <a href=\"#i-5\"><\/a>      <\/li>      <li>        <a href=\"#i-6\">\u30b0\u30ea\u30c3\u30c9\u30b5\u30fc\u30c1<\/a>      <\/li>      <li>        <a href=\"#i-7\">\u8a55\u4fa1\u307e\u3068\u3081<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-8\">\u307e\u3068\u3081<\/a>      <\/li>    <\/ul>  <\/li>  <li class=\"last\">    <a href=\"#i-4\">\u2728AI\u4eba\u6750\u30b3\u30fc\u30b9 \u53d7\u8b1b\u304a\u7533\u8fbc\u307f\u53d7\u4ed8\u4e2d\uff01<\/a>  <\/li><\/ul>\n      \n    <\/div><\/div><div class=\"toc\"><p><\/p>\n<\/div><h2 id=\"i-0\">\u5206\u985e\u3068\u56de\u5e30\u306b\u4f7f\u3048\u308b\u8a55\u4fa1\u65b9\u6cd5<\/h2>\n<p>\u6700\u5f8c\u306b\u3001\u5206\u985e\u3067\u3082\u56de\u5e30\u3067\u3082\u4f7f\u3048\u308b\u8a55\u4fa1\u65b9\u6cd5\u306e\u4ea4\u5dee\u691c\u8a3c\u3068\u30b0\u30ea\u30c3\u30c9\u30b5\u30fc\u30c1\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002<br>\uff12\u3064\u306e\u624b\u6cd5\u306e\u610f\u5473\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n<p><strong>\u30fb\u4ea4\u5dee\u691c\u8a3c\uff08Cross-validation\uff09\uff1a\u500b\u3005\u306e\u30e2\u30c7\u30eb\u306e\u6c4e\u5316\u6027\u80fd\u3092\u8a55\u4fa1\u3059\u308b\u624b\u6cd5<\/strong><br><strong>\u30fb\u30b0\u30ea\u30c3\u30c9\u30b5\u30fc\u30c1\uff08grid search\uff09\uff1a\u6a5f\u68b0\u5b66\u7fd2\u306e\u30cf\u30a4\u30d1\u30fc\u30d1\u30e9\u30e1\u30fc\u30bf\u63a2\u7d22\u306e\u65b9\u6cd5<\/strong><\/p>\n<p>\u305d\u308c\u3067\u306f\u3001\u4e00\u3064\u305a\u3064\u8a73\u7d30\u3092\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<h2 id=\"i-1\">\u30db\u30fc\u30eb\u30c9\u30a2\u30a6\u30c8\u6cd5<\/h2>\n<p><strong>\u30db\u30fc\u30eb\u30c9\u30a2\u30a6\u30c8\u6cd5\u306f\u3001\u30e2\u30c7\u30eb\u3092\u4f5c\u308b\u5b66\u7fd2\u30c7\u30fc\u30bf\u3068\u3001\u30e2\u30c7\u30eb\u3092\u8a55\u4fa1\u3059\u308b\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u306b\u5206\u5272\u3057\u3066\u8a55\u4fa1\u3057\u307e\u3059\u3002<\/strong><br>\u30c7\u30fc\u30bf\u3092\u5206\u3051\u308b\u3053\u3068\u3067\u3001\u6c4e\u5316\u6027\u80fd\uff08\u672a\u77e5\u306e\u30c7\u30fc\u30bf\u306b\u5bfe\u3059\u308b\u6027\u80fd\uff09\u3092\u5411\u4e0a\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br>\u3082\u3057\u3001\u672a\u77e5\u306e\u30c7\u30fc\u30bf\u3092\u4e88\u6e2c\u3059\u308b\u306b\u3042\u305f\u308a\u5168\u3066\u306e\u30c7\u30fc\u30bf\u3092\u5b66\u7fd2\u30c7\u30fc\u30bf\u306b\u3057\u3066\u3057\u307e\u3046\u3068\u3001\u904e\u5b66\u7fd2(\u5b66\u7fd2\u30c7\u30fc\u30bf\u306b\u3060\u3051\u9069\u5408\u3057\u3066\u3044\u3066\u672a\u5b66\u7fd2\u306e\u30c7\u30fc\u30bf\u306b\u5bfe\u3057\u3066\u6b63\u3057\u304f\u7b54\u3048\u3092\u51fa\u529b\u3067\u304d\u306a\u3044\u72b6\u614b)\u3057\u3066\u3057\u307e\u3044\u307e\u3059\u3002<br><strong>scikit-learn\u306etrain_test_split()\u3092\u4f7f\u3046\u3053\u3068\u3067\u30c7\u30fc\u30bf\u3092\u5206\u3051\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/strong><br>\u7d30\u304b\u3044\u8a2d\u5b9a\u306b\u3088\u308a\u5206\u5272\u3059\u308b\u5272\u5408\u3092\u5909\u3048\u308b\u3053\u3068\u304c\u51fa\u6765\u307e\u3059\u304c\u3001\u4f55\u3082\u8a2d\u5b9a\u3057\u306a\u3044\u5834\u5408\u3001\u30c8\u30ec\u30fc\u30cb\u30f3\u30b0\u30c7\u30fc\u30bf\u306b\u306f75%\u3001\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u306f25%\u3067\u5206\u5272\u3055\u308c\u307e\u3059\u3002(test_size\u304c25%\u306b\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u307e\u3059\u3002)<\/p>\n<pre><code class=\"python:\">from sklearn.datasets import load_iris\nfrom sklearn.model_selection import train_test_split\n\niris = load_iris()\u3000# \u30a2\u30a4\u30ea\u30b9\u306e\u82b1\u306e\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u306e\u8aad\u307f\u8fbc\u307f\nx = iris.data  # \u5168\u4f53\u306f150\u500b\ny = iris.target\nx_train, x_test, y_train, y_test = train_test_split(x, y)\u3000# \u30c7\u30fc\u30bf\u3092\u30c8\u30ec\u30fc\u30cb\u30f3\u30b0\u7528\u3068\u30c6\u30b9\u30c8\u7528\u306b\u5206\u5272\u3000\n# \uff08test_size=\u30c6\u30b9\u30c8\u30b5\u30a4\u30ba\u306e\u6570\u3092\u5f15\u6570\u306b\u6e21\u3059\u3053\u3068\u3067\u3001\u30c6\u30b9\u30c8\u30b5\u30a4\u30ba\u3092\u8abf\u6574\u53ef\u80fd\u3067\u3059\uff09\n\nprint(len(x_train)) # 112\u3000\uff08\u5168\u4f53\u306e75%\u304c\u30c8\u30ec\u30fc\u30cb\u30f3\u30b0\u30c7\u30fc\u30bf\u306b\u5206\u5272\uff09\nprint(len(x_test)) # 38\u3000\uff08\u5168\u4f53\u306e25%\u304c\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u306b\u5206\u5272\uff09\n<\/code><\/pre>\n<h2 id=\"i-2\">\u4ea4\u5dee\u691c\u8a3c(\u30af\u30ed\u30b9\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3)<\/h2>\n<p><strong>\u4ea4\u5dee\u691c\u8a3c\uff08cross-validation)\u3068\u306f\u3001\u6c4e\u5316\u6027\u80fd\u3092\u8a55\u4fa1\u3059\u308b\u7d71\u8a08\u7684\u306a\u624b\u6cd5\u3067\u3001\u5206\u985e\u3067\u3082\u56de\u5e30\u3067\u3082\u7528\u3044\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/strong><br>\u6a5f\u68b0\u5b66\u7fd2\u3092\u884c\u3046\u3068\u304d\u3001\u5b66\u7fd2\u3092\u884c\u3046\u305f\u3081\u306e\u5b66\u7fd2\u30c7\u30fc\u30bf\u3068\u672a\u77e5\u306e\u30c7\u30fc\u30bf\u306b\u9069\u7528\u3057\u305f\u3068\u304d\u306e\u30e2\u30c7\u30eb\u3092\u8a55\u4fa1\u3059\u308b\u305f\u3081\u306e\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u304c\u3042\u308a\u307e\u3059\u3002<br>\u30c8\u30ec\u30fc\u30cb\u30f3\u30b0\u30c7\u30fc\u30bf\u3067\u306e\u6027\u80fd\u304c\u3068\u3066\u3082\u826f\u3044\u306e\u306b\u3082\u304b\u304b\u308f\u3089\u305a\u3001\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u3067\u306e\u6027\u80fd\u304c\u60aa\u304f\u306a\u3063\u3066\u3057\u307e\u3046\u3053\u3068\u3092\u904e\u5b66\u7fd2\u3068\u8a00\u3044\u307e\u3059\u3002<\/p>\n<p>\u4ea4\u5dee\u691c\u8a3c\u306e\u4e2d\u3067\u3082\u3001\u3088\u304f\u5229\u7528\u3055\u308c\u308bK-\u5206\u5272\u4ea4\u5dee\u691c\u8a3c\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002<br><strong>K-\u5206\u5272\u4ea4\u5dee\u691c\u8a3c\u306f\u3001\u30c7\u30fc\u30bf\u3092K\u500b\u306b\u5206\u5272\u3057\u3066\u305d\u306e\u3046\u30611\u3064\u3092\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u306b\u6b8b\u308a\u306eK-1\u500b\u3092\u5b66\u7fd2\u30c7\u30fc\u30bf\u3068\u3057\u3066\u6b63\u89e3\u7387\u306e\u8a55\u4fa1\u3092\u884c\u3044\u307e\u3059\u3002<\/strong><br>\u3053\u308c\u3092K\u500b\u306e\u30c7\u30fc\u30bf\u3059\u3079\u3066\u304c1\u56de\u305a\u3064\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u306b\u306a\u308b\u3088\u3046\u306bK\u56de\u5b66\u7fd2\u3092\u884c\u306a\u3063\u3066\u7cbe\u5ea6\u306e\u5e73\u5747\u3092\u3068\u308b\u624b\u6cd5\u3067\u3059\u3002<\/p>\n<p><img decoding=\"async\" src=\"\/assets\/images_test\/299_16bf4f80175.png\" alt=\"\"><\/p>\n<p>\u4ea4\u5dee\u691c\u8a3c\u3092\u3059\u308b\u305f\u3081\u306e\u95a2\u6570\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><code class=\"python:\">from sklearn.model_selection import cross_val_score, KFold\nfrom scipy.stats import sem\n\ndef evaluate_cross_validation(clf, x, y, K):\n    cv = KFold(len(y), K,shuffle=True,random_state=0)\n    scores = cross_val_score(clf,x,y,cv=cv)\n    print(scores)\n    print (\"Mean score: {} (+\/-{})\".format( np.mean (scores), sem(scores)))\n<\/code><\/pre>\n<p>\u5f15\u65701\u756a\u76ee\u306eclf\u306f\u6a5f\u68b0\u5b66\u7fd2\u30e2\u30c7\u30eb\uff08\u6c7a\u5b9a\u6728\u3001SVM\u306a\u3069\uff09\u3067\u3059\u3002<br>\u5f15\u6570\u6700\u5f8c\u306eK\u306f\u30c7\u30fc\u30bf\u3092\u4f55\u5206\u5272\u3059\u308b\u304b\u6307\u5b9a\u3059\u308b\u5f15\u6570\u3067\u3059\u3002<\/p>\n<h2 id=\"i-3\">\n\n\n<\/h2>\n<h2 class=\"wp-block-heading\" id=\"i-4\">\u3010\u7121\u6599\u52d5\u753b\uff1a<strong>\u500d\u901f\u3067\u5b66\u3076\uff01\u751f\u6210AI\u3092\u6d3b\u7528\u3057\u305f\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u52c9\u5f37\u6cd5\uff08\u77ed\u7e2e\u7248\uff09\u3011<\/strong><\/h2>\n<h2 id=\"i-5\">\n\n\n\n<\/h2>\n<p>\u751f\u6210AI\u3092\u6d3b\u7528\u3057\u3066\u52b9\u7387\u7684\u306b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3092\u5b66\u3076\u65b9\u6cd5\u3092\u89e3\u8aac\u3057\u3066\u3044\u307e\u3059\u3002\u751f\u6210AI\u306e\u57fa\u672c\u7684\u306a\u4ed5\u7d44\u307f\u3084\u52b9\u679c\u7684\u306a\u6d3b\u7528\u6cd5\u3001\u6ce8\u610f\u70b9\u306b\u3064\u3044\u3066\u3082\u8a73\u3057\u304f\u8aac\u660e\u3002\u52c9\u5f37\u6cd5\u3068\u3068\u3082\u306b\u751f\u6210AI\u305d\u306e\u3082\u306e\u306b\u3064\u3044\u3066\u3082\u5b66\u3079\u308b\u5185\u5bb9\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u305c\u3072\u3054\u89a7\u304f\u3060\u3055\u3044\uff01\n\n\n<\/p>\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-vimeo wp-block-embed-vimeo wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" src=\"https:\/\/player.vimeo.com\/video\/1069835048?h=e43b17d6de&amp;dnt=1&amp;app_id=122963\" width=\"880\" height=\"495\" frameborder=\"0\" allow=\"autoplay; fullscreen; picture-in-picture; clipboard-write; encrypted-media\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<p><strong>\u5168\u7de8\u306f\u3001AI Academy\u516c\u5f0fLINE\u3067\u914d\u4fe1\u4e2d\u3067\u3059\u3002<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><a href=\"https:\/\/lin.ee\/3E4GzWk\" rel=\"nofollow noopener\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" width=\"910\" height=\"517\" src=\"https:\/\/aiacademy.jp\/media\/wp-content\/uploads\/2019\/11\/LINE_Buttom.png\" alt=\"\" class=\"wp-image-6799\" style=\"width:158px;height:auto\" srcset=\"https:\/\/aiacademy.jp\/media\/wp-content\/uploads\/2019\/11\/LINE_Buttom.png 910w, https:\/\/aiacademy.jp\/media\/wp-content\/uploads\/2019\/11\/LINE_Buttom-300x170.png 300w, https:\/\/aiacademy.jp\/media\/wp-content\/uploads\/2019\/11\/LINE_Buttom-768x436.png 768w\" sizes=\"auto, (max-width: 910px) 100vw, 910px\"><\/a><\/figure>\n\n\n\n\n\n\n<p>\n\n\n<\/p>\n<h2 id=\"i-6\">\u30b0\u30ea\u30c3\u30c9\u30b5\u30fc\u30c1<\/h2>\n<p>\u4ea4\u5dee\u691c\u8a3c\u306f\u30e2\u30c7\u30eb\u306e\u6c4e\u5316\u6027\u80fd\u3092\u6e2c\u5b9a\u3059\u308b\u65b9\u6cd5\u3067\u3057\u305f\u3002<br>\u305d\u308c\u306b\u5bfe\u3057\u3066\u30b0\u30ea\u30c3\u30c9\u30b5\u30fc\u30c1\u306f\u3001<em>\u5b66\u7fd2\u30e2\u30c7\u30eb\u306b\u7528\u3044\u3089\u308c\u308b\u30cf\u30a4\u30d1\u30fc\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u8abf\u6574\u3057\u3066\u3044\u304d\u3001\u30e2\u30c7\u30eb\u306e\u6c4e\u5316\u6027\u80fd\u3092\u5411\u4e0a\u3055\u305b\u308b\u65b9\u6cd5\u3092\u63a2\u3059\u4ee3\u8868\u7684\u306a\u624b\u6cd5\u3067\u3059\u3002<\/em><br>\u30b0\u30ea\u30c3\u30c9\u30b5\u30fc\u30c1\u3067\u306f\u3001\u6307\u5b9a\u3057\u305f\u30cf\u30a4\u30d1\u30fc\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u5168\u3066\u306e\u7d44\u307f\u5408\u308f\u305b\u306b\u5bfe\u3057\u3066\u5b66\u7fd2\u3092\u884c\u3044\u3001\u3082\u3063\u3068\u3082\u826f\u3044\u7cbe\u5ea6\u3092\u793a\u3057\u305f\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u63a1\u7528\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>\u30cf\u30a4\u30d1\u30fc\u30d1\u30e9\u30e1\u30fc\u30bf\u3068\u306f\u3001SVC\u3067\u306e\u30ab\u30fc\u30cd\u30eb\u306e\u30d0\u30f3\u30c9\u5e45gamma\u3001\u6b63\u5247\u5316\u30d1\u30e9\u30e1\u30fc\u30bfC\u306a\u3069\u306e\u3053\u3068\u3067<strong>\u4eba\u304c\u8abf\u6574\u3059\u308b\u5fc5\u8981\u306e\u3042\u308b\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u3053\u3068\u3092\u30cf\u30a4\u30d1\u30fc\u30d1\u30e9\u30e1\u30fc\u30bf\u3068\u547c\u3073\u307e\u3059\u3002<\/strong><br><a href=\"https:\/\/aiacademy.jp\/texts\/show\/?id=142\">\u30b0\u30ea\u30c3\u30c9\u30b5\u30fc\u30c1\u3067\u30cf\u30a4\u30d1\u30fc\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u6700\u9069\u5316<\/a><br><em>\u3053\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u306f\u30e2\u30c7\u30eb\u306e\u6027\u80fd\u306b\u5927\u304d\u304f\u5f71\u97ff\u3092\u4e0e\u3048\u307e\u3059\u3002<\/em><br>\u4f8b\u3048\u3070\u3001\u30cf\u30a4\u30d1\u30fc\u30d1\u30e9\u30e1\u30fc\u30bf\u3067\u3042\u308bgamma\u3068C\u306b\u305d\u308c\u305e\u308c0.001, 0.005, 0.1, 1, 5\u306a\u3069\u3068\u5f53\u3066\u306f\u3081\u3066\u3001\u30e2\u30c7\u30eb\u306e\u6c4e\u5316\u6027\u80fd\u3092\u8a66\u3057\u3066\u307f\u308b\u3060\u3051\u3067\u30015\u00d75=25\u901a\u308a\u306e\u30cf\u30a4\u30d1\u30fc\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u7d44\u307f\u5408\u308f\u305b\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u305d\u308c\u3089\u5168\u3066\u306e\u4e2d\u3067\u6c4e\u5316\u6027\u80fd\u306e\u4e00\u756a\u826f\u3044\u3082\u306e\u3092\u63a1\u629e\u3057\u307e\u3059\u3002<\/p>\n<p>\u30b0\u30ea\u30c3\u30c9\u30b5\u30fc\u30c1\u306fScikit-learn\u3092\u7528\u3044\u3066\u5b9f\u88c5\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code class=\"python:\"># from sklearn.grid_search import GridSearchCV\nfrom sklearn.model_selection import GridSearchCV\n<\/code><\/pre>\n<p>\u6b21\u306b\u3001\u6700\u9069\u5316\u3057\u305f\u3044\u30e2\u30c7\u30eb\u306e\u30cf\u30a4\u30d1\u30fc\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u8a2d\u5b9a\u3092\u884c\u3044\u307e\u3057\u3087\u3046\u3002<br>\u4f8b\u3048\u3070\u3001 SVM\u306b\u304a\u3044\u3066\u3001C\u3068gamma\u3092\u305d\u308c\u305e\u308c{1,5,10,50},{0.001,0.0001}\u3067\u6700\u9069\u5316\u3057\u305f\u3044\u3068\u3059\u308b\u3068\u3001\u3053\u306e\u3088\u3046\u306b\u30ea\u30b9\u30c8\u5185\u306b\u3001key\u306bC\u3068gamma\u3092\u6301\u3064\u8f9e\u66f8\u3092\u5165\u308c\u308c\u3070\u826f\u3044\u3067\u3059\u3002<\/p>\n<pre><code class=\"python:\">parameters = [\n    {'C': [1, 5, 10, 50],\n     'gamma': [0.001, 0.0001]}\n]\n<\/code><\/pre>\n<p>\u30b0\u30ea\u30c3\u30c9\u30b5\u30fc\u30c1\u3092\u4f7f\u3063\u305f\u30e2\u30c7\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre><code class=\"python:\">from sklearn import svm\nsvc = svm.SVC()\nclf = GridSearchCV(svc, parameters)\nclf.fit(X_train, y_train)\n<\/code><\/pre>\n<p>\u7d50\u679c\u306f<strong>clf.best_params_<\/strong>\u3067\u6700\u9069\u5316\u3057\u305f\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u78ba\u8a8d\u3067\u304d\u307e\u3059<\/p>\n<pre><code class=\"python:\">print(clf.best_params_)\n<\/code><\/pre>\n<h2 id=\"i-7\">\u8a55\u4fa1\u307e\u3068\u3081<\/h2>\n<p>\u4ee5\u4e0a\u306e\u8a55\u4fa1\u6307\u6a19\u3092\u307e\u3068\u3081\u3066\u51fa\u529b\u3055\u305b\u308b\u95a2\u6570\u3092\u4f5c\u3063\u3066\u304a\u304f\u3068\u975e\u5e38\u306b\u4fbf\u5229\u3067\u3059\u3002<\/p>\n<pre><code class=\"python:\">from sklearn import metrics\ndef measure_performance(x,y,clf, show_accuracy=True,show_classification_report=True, show_confussion_matrix=True):\n    y_pred=clf.predict(x)\n    if show_accuracy:\n        print(\"Accuracy:{0:.3f}\".format(metrics.accuracy_score(y, y_pred)), \"\\n\")\n\n    if show_classification_report:\n        print(\"Classification report\")\n        print(metrics.classification_report(y, y_pred), \"\\n\")\n\n    if show_confussion_matrix:\n        print(\"Confussion matrix\")\n        print(metrics.confusion_matrix(y, y_pred),\"\\n\")\n<\/code><\/pre>\n<p>if show_accuracy:<br>if show_classification_report:<br>if show_confussion_matrix:<br>\u3067\u3059\u304c\u6761\u4ef6\u6587\u306b\u3057\u3066\u3044\u308b\u7406\u7531\u306f\u3001\u305d\u306e\u95a2\u6570\u304c\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u975e\u8868\u793a\u3092\u3059\u308b\u305f\u3081\u306e\u3082\u306e\u3060\u304b\u3089\u3067\u3059\u3002<br>\u95a2\u6570\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u5f15\u6570\u3067\u5168\u3066True\u3092\u53d6\u3063\u3066\u3044\u308b\u305f\u3081\u3001\u305d\u306e\u307e\u307e\u547c\u3073\u51fa\u3059\u3068\u5168\u3066\u306e\u8a55\u4fa1\u6307\u6a19\u306b\u3064\u3044\u3066\u51fa\u529b\u3057\u307e\u3059\u304c\u3001\u4f8b\u3048\u3070accuracy\u3060\u3051\u6b32\u3057\u3044\u6642\u306a\u3069\u304c\u3042\u308a\u307e\u3059\u3002<br>\u305d\u3053\u3067\u305d\u308c\u4ee5\u5916\u3092False\u306b\u6307\u5b9a\u3057\u3066, \u305d\u306e\u95a2\u6570\u3092\u4f7f\u3046\u3068\u3044\u3046\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<h2 id=\"i-8\">\u307e\u3068\u3081<\/h2>\n<p>\u3053\u306e\u30c6\u30ad\u30b9\u30c8\u3067\u306f\u3001\u5206\u985e\u3067\u3082\u56de\u5e30\u3067\u3082\u5229\u7528\u53ef\u80fd\u306a\u4ea4\u5dee\u691c\u8a3c\u306b\u3064\u3044\u3066\u5b66\u3073\u307e\u3057\u305f\u3002<br>\u4ed6\u306b\u3082\u30db\u30fc\u30eb\u30c9\u30a2\u30a6\u30c8\u6cd5\u3084\u30b0\u30ea\u30c3\u30c9\u30b5\u30fc\u30c1\u3082\u3088\u304f\u5229\u7528\u3057\u307e\u3059\u306e\u3067\u3001\u3057\u3063\u304b\u308a\u3068\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n<h1 class=\"wp-block-heading\" id=\"i-4\">\u2728AI\u4eba\u6750\u30b3\u30fc\u30b9 \u53d7\u8b1b\u304a\u7533\u8fbc\u307f\u53d7\u4ed8\u4e2d\uff01<\/h1>\n\n\n\n<p><a href=\"https:\/\/aiacademy.jp\/bootcamp\">AI Academy Bootcamp<\/a>&nbsp;\u3067\u306fAI\u30fb\u30c7\u30fc\u30bf\u30b5\u30a4\u30a8\u30f3\u30b9\u3001\u6a5f\u68b0\u5b66\u7fd2\u3001Web\u30a2\u30d7\u30ea\u958b\u767a\u306e\u5b9f\u8df5\u529b\u3092\u9ad8\u3081\u308b\u5168\uff16\u30b3\u30fc\u30b9\u7d0450\u6642\u9593\u4ee5\u4e0a\u306e\u52d5\u753b\u304c\u898b\u653e\u984c\uff01AI\u306e\u5b66\u7fd2\u306b\u5fc5\u9808\u306ePython\u306e\u5b66\u7fd2\u304b\u3089\u59cb\u307e\u308a\u3001IT\u30ea\u30c6\u30e9\u30b7\u30fc\u3001LLM\u5b66\u7fd2\u306a\u3069\u3001\u76ee\u7684\u306b\u5fdc\u3058\u305f\u5e45\u5e83\u3044\u5206\u91ce\u3092\u30ab\u30d0\u30fc\u3057\u3066\u3044\u307e\u3059\u3002LINE\u516c\u5f0f\u3067\u306f\u3001\u304a\u5f97\u306a\u5272\u5f15\u30af\u30fc\u30dd\u30f3\u3082\u30d7\u30ec\u30bc\u30f3\u30c8\u3057\u3066\u3044\u307e\u3059\uff01<\/p>\n\n\n\n<p><strong>\u5358\u72ec\u3067\u5b66\u3076\u3088\u308a\u3001\u5168\u30b3\u30fc\u30b9\u3092\u4e00\u6c17\u306b\u5b66\u3076\u3053\u3068\u3067\u5f97\u3089\u308c\u308b\u300c\u5b66\u7fd2\u30b7\u30ca\u30b8\u30fc\u52b9\u679c\u300d\u304c\u7279\u9577\u3002<\/strong><br>\u57fa\u790e\u304b\u3089\u5fdc\u7528\u307e\u3067\u3001\u30c7\u30fc\u30bf\u5206\u6790\u3068AI\u958b\u767a\u306e\u30b9\u30ad\u30eb\u3092\u52b9\u7387\u3088\u304f\u8eab\u306b\u3064\u3051\u3089\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/lin.ee\/3E4GzWk\" target=\"_blank\" rel=\" noreferrer noopener nofollow\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"349\" src=\"https:\/\/aiacademy.jp\/media\/wp-content\/uploads\/2019\/11\/\u30af\u30fc\u30dd\u30f3Media06-1024x349.png\" alt=\"\" class=\"wp-image-7228\" srcset=\"https:\/\/aiacademy.jp\/media\/wp-content\/uploads\/2019\/11\/\u30af\u30fc\u30dd\u30f3Media06-1024x349.png 1024w, https:\/\/aiacademy.jp\/media\/wp-content\/uploads\/2019\/11\/\u30af\u30fc\u30dd\u30f3Media06-300x102.png 300w, https:\/\/aiacademy.jp\/media\/wp-content\/uploads\/2019\/11\/\u30af\u30fc\u30dd\u30f3Media06-768x261.png 768w, https:\/\/aiacademy.jp\/media\/wp-content\/uploads\/2019\/11\/\u30af\u30fc\u30dd\u30f3Media06-1536x523.png 1536w, https:\/\/aiacademy.jp\/media\/wp-content\/uploads\/2019\/11\/\u30af\u30fc\u30dd\u30f3Media06-2048x697.png 2048w, https:\/\/aiacademy.jp\/media\/wp-content\/uploads\/2019\/11\/\u30af\u30fc\u30dd\u30f3Media06-940x320.png 940w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><\/a><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u306e\u30b5\u30a4\u30c8\u306f\u3001Python\u3084\u751f\u6210AI\u306a\u3069\u3092\u5b66\u3079\u308b\u30aa\u30f3\u30e9\u30a4\u30f3\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30b9\u30af\u30fc\u30eb AI Academy Bootcamp\u304c\u904b\u55b6\u3057\u3066\u3044\u307e\u3059\u3002 \u76ee\u6b21 \u5206\u985e\u3068\u56de\u5e30\u306b\u4f7f\u3048\u308b\u8a55\u4fa1\u65b9\u6cd5 \u30db\u30fc\u30eb\u30c9\u30a2\u30a6\u30c8\u6cd5 \u4ea4\u5dee\u691c\u8a3c(\u30af\u30ed\u30b9\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7 &#8230; <\/p>\n","protected":false},"author":1,"featured_media":2088,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[127],"tags":[],"class_list":{"0":"post-263","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-ai-"},"_links":{"self":[{"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=\/wp\/v2\/posts\/263","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=263"}],"version-history":[{"count":45,"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=\/wp\/v2\/posts\/263\/revisions"}],"predecessor-version":[{"id":7318,"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=\/wp\/v2\/posts\/263\/revisions\/7318"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=\/wp\/v2\/media\/2088"}],"wp:attachment":[{"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=263"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=263"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=263"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}