{"id":4057,"date":"2023-07-13T20:58:15","date_gmt":"2023-07-13T20:58:15","guid":{"rendered":"https:\/\/statorials.org\/ja\/python%e3%81%ae%e8%82%98%e3%83%a1%e3%82%bd%e3%83%83%e3%83%88%e3%82%99\/"},"modified":"2023-07-13T20:58:15","modified_gmt":"2023-07-13T20:58:15","slug":"python%e3%81%ae%e8%82%98%e3%83%a1%e3%82%bd%e3%83%83%e3%83%88%e3%82%99","status":"publish","type":"post","link":"https:\/\/statorials.org\/ja\/python%e3%81%ae%e8%82%98%e3%83%a1%e3%82%bd%e3%83%83%e3%83%88%e3%82%99\/","title":{"rendered":"Python \u3067\u30a8\u30eb\u30dc\u6cd5\u3092\u4f7f\u7528\u3057\u3066\u6700\u9069\u306a\u30af\u30e9\u30b9\u30bf\u30fc\u3092\u898b\u3064\u3051\u308b\u65b9\u6cd5"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\"><a href=\"https:\/\/statorials.org\/ja\/-10\/\" target=\"_blank\" rel=\"noopener\">\u6a5f\u68b0\u5b66\u7fd2<\/a>\u3067\u6700\u3082\u4e00\u822c\u7684\u306a\u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0 \u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u306e 1 \u3064\u306f<strong>\u3001k-means \u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0<\/strong>\u3068\u3057\u3066\u77e5\u3089\u308c\u3066\u3044\u307e\u3059\u3002<\/span><\/p>\n<p> <span style=\"color: #000000;\">K \u5e73\u5747\u6cd5\u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0\u306f\u3001\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u306e\u5404\u89b3\u6e2c\u5024\u3092<em>K<\/em>\u500b\u306e\u30af\u30e9\u30b9\u30bf\u30fc\u306e 1 \u3064\u306b\u914d\u7f6e\u3059\u308b\u624b\u6cd5\u3067\u3059\u3002<\/span><\/p>\n<p><span style=\"color: #000000;\">\u6700\u7d42\u7684\u306a\u76ee\u6a19\u306f\u3001\u5404\u30af\u30e9\u30b9\u30bf\u30fc\u5185\u306e\u89b3\u6e2c\u5024\u304c\u4e92\u3044\u306b\u3088\u304f\u4f3c\u3066\u3044\u308b\u4e00\u65b9\u3067\u3001\u7570\u306a\u308b\u30af\u30e9\u30b9\u30bf\u30fc\u5185\u306e\u89b3\u6e2c\u5024\u304c\u4e92\u3044\u306b\u307e\u3063\u305f\u304f\u7570\u306a\u308b<em>K<\/em>\u500b\u306e\u30af\u30e9\u30b9\u30bf\u30fc\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u3067\u3059\u3002<\/span><\/p>\n<p> <span style=\"color: #000000;\">K \u5e73\u5747\u6cd5\u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0\u3092\u884c\u3046\u5834\u5408\u3001\u6700\u521d\u306e\u30b9\u30c6\u30c3\u30d7\u306f<em>K<\/em>\u306e\u5024 (\u89b3\u6e2c\u5024\u3092\u914d\u7f6e\u3059\u308b\u30af\u30e9\u30b9\u30bf\u30fc\u306e\u6570) \u3092\u9078\u629e\u3059\u308b\u3053\u3068\u3067\u3059\u3002<\/span><\/p>\n<p> <span style=\"color: #000000;\"><em>K<\/em>\u306e\u5024\u3092\u9078\u629e\u3059\u308b\u6700\u3082\u4e00\u822c\u7684\u306a\u65b9\u6cd5\u306e 1 \u3064\u306f\u3001<strong>\u30a8\u30eb\u30dc\u6cd5<\/strong>\u3068\u3057\u3066\u77e5\u3089\u308c\u3066\u3044\u307e\u3059\u3002\u3053\u308c\u306b\u306f\u3001x \u8ef8\u306b\u30af\u30e9\u30b9\u30bf\u30fc\u306e\u6570\u3001y \u8ef8\u306b\u5e73\u65b9\u548c\u306e\u5408\u8a08\u3092\u4f7f\u7528\u3057\u3066\u30d7\u30ed\u30c3\u30c8\u3092\u4f5c\u6210\u3057\u3001\u305d\u306e\u5f8c\u3001\u30d7\u30ed\u30c3\u30c8\u5185\u3067\u300c\u819d\u300d\u307e\u305f\u306f\u30bf\u30fc\u30f3\u304c\u73fe\u308c\u308b\u5834\u6240\u3002<\/span><\/p>\n<p> <span style=\"color: #000000;\">\u300c\u30cb\u30fc\u300d\u304c\u767a\u751f\u3059\u308b x \u8ef8\u4e0a\u306e\u70b9\u306f\u3001k-means \u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0 \u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u3067\u4f7f\u7528\u3059\u308b\u6700\u9069\u306a\u30af\u30e9\u30b9\u30bf\u30fc\u6570\u3092\u793a\u3057\u307e\u3059\u3002<\/span><\/p>\n<p><span style=\"color: #000000;\">\u6b21\u306e\u4f8b\u306f\u3001Python \u3067\u30a8\u30eb\u30dc \u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3059\u308b\u65b9\u6cd5\u3092\u793a\u3057\u3066\u3044\u307e\u3059\u3002<\/span><\/p>\n<h2><span style=\"color: #000000;\"><strong>\u30b9\u30c6\u30c3\u30d7 1: \u5fc5\u8981\u306a\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3059\u308b<\/strong><\/span><\/h2>\n<p><span style=\"color: #000000;\">\u307e\u305a\u3001K \u5e73\u5747\u6cd5\u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0\u3092\u5b9f\u884c\u3059\u308b\u305f\u3081\u306b\u5fc5\u8981\u306a\u3059\u3079\u3066\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u307e\u3059\u3002<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008000;\">import<\/span> pandas <span style=\"color: #008000;\">as<\/span> pd\n<span style=\"color: #008000;\">import<\/span> numpy <span style=\"color: #008000;\">as<\/span> np\n<span style=\"color: #008000;\">import<\/span> matplotlib. <span style=\"color: #3366ff;\">pyplot<\/span> <span style=\"color: #008000;\">as<\/span> plt\n<span style=\"color: #008000;\">from<\/span> sklearn. <span style=\"color: #3366ff;\">cluster<\/span> <span style=\"color: #008000;\">import<\/span> KMeans\n<span style=\"color: #008000;\">from<\/span> sklearn. <span style=\"color: #3366ff;\">preprocessing<\/span> <span style=\"color: #008000;\">import<\/span> StandardScaler<\/strong><\/span><\/pre>\n<h2><span style=\"color: #000000;\"><strong>\u30b9\u30c6\u30c3\u30d7 2: \u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u3092\u4f5c\u6210\u3059\u308b<\/strong><\/span><\/h2>\n<p><span style=\"color: #000000;\">\u6b21\u306b\u300120 \u4eba\u306e\u7570\u306a\u308b\u30d0\u30b9\u30b1\u30c3\u30c8\u30dc\u30fc\u30eb\u9078\u624b\u306e 3 \u3064\u306e\u5909\u6570\u3092\u542b\u3080 DataFrame \u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008080;\">#createDataFrame\n<\/span>df = pd. <span style=\"color: #3366ff;\">DataFrame<\/span> ({' <span style=\"color: #ff0000;\">points<\/span> ': [18, np.nan, 19, 14, 14, 11, 20, 28, 30, 31,\n                              35, 33, 29, 25, 25, 27, 29, 30, 19, 23],\n                   ' <span style=\"color: #ff0000;\">assists<\/span> ': [3, 3, 4, 5, 4, 7, 8, 7, 6, 9, 12, 14,\n                               np.nan, 9, 4, 3, 4, 12, 15, 11],\n                   ' <span style=\"color: #ff0000;\">rebounds<\/span> ': [15, 14, 14, 10, 8, 14, 13, 9, 5, 4,\n                                11, 6, 5, 5, 3, 8, 12, 7, 6, 5]})\n\n<span style=\"color: #008080;\">#drop rows with NA values in any columns\n<span style=\"color: #000000;\">df = df. <span style=\"color: #3366ff;\">dropna<\/span> ()<\/span>\n\n#create scaled DataFrame where each variable has mean of 0 and standard dev of 1\n<span style=\"color: #000000;\">scaled_df = StandardScaler(). <span style=\"color: #3366ff;\">fit_transform<\/span> (df)\n<\/span><\/span><\/strong><\/span><\/pre>\n<h2><span style=\"color: #000000;\"><strong>\u30b9\u30c6\u30c3\u30d7 3: \u30a8\u30eb\u30dc\u30fc\u6cd5\u3092\u4f7f\u7528\u3057\u3066\u6700\u9069\u306a\u30af\u30e9\u30b9\u30bf\u30fc\u6570\u3092\u898b\u3064\u3051\u308b<\/strong><\/span><\/h2>\n<p><span style=\"color: #000000;\">K \u5e73\u5747\u6cd5\u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0\u3092\u4f7f\u7528\u3057\u3066\u3001\u3053\u308c\u3089 3 \u3064\u306e\u30e1\u30c8\u30ea\u30af\u30b9\u306b\u57fa\u3065\u3044\u3066\u985e\u4f3c\u3057\u305f\u30a2\u30af\u30bf\u30fc\u3092\u30b0\u30eb\u30fc\u30d7\u5316\u3057\u305f\u3044\u3068\u3057\u307e\u3059\u3002<\/span><\/p>\n<p> <span style=\"color: #000000;\">Python \u3067 K-means \u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0\u3092\u5b9f\u884c\u3059\u308b\u306b\u306f\u3001 <strong>sklearn<\/strong>\u30e2\u30b8\u30e5\u30fc\u30eb\u306e<a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.cluster.KMeans.html\" target=\"_blank\" rel=\"noopener\">KMeans<\/a>\u95a2\u6570\u3092\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002<\/span><\/p>\n<p><span style=\"color: #000000;\">\u3053\u306e\u95a2\u6570\u306e\u6700\u3082\u91cd\u8981\u306a\u5f15\u6570\u306f<strong>n_clusters<\/strong>\u3067\u3001\u89b3\u6e2c\u5024\u3092\u914d\u7f6e\u3059\u308b\u30af\u30e9\u30b9\u30bf\u30fc\u306e\u6570\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/span><\/p>\n<p><span style=\"color: #000000;\">\u6700\u9069\u306a\u30af\u30e9\u30b9\u30bf\u30fc\u6570\u3092\u6c7a\u5b9a\u3059\u308b\u305f\u3081\u306b\u3001\u30af\u30e9\u30b9\u30bf\u30fc\u6570\u3068\u30e2\u30c7\u30eb\u306e SSE (\u4e8c\u4e57\u8aa4\u5dee\u306e\u5408\u8a08) \u3092\u8868\u793a\u3059\u308b\u30b0\u30e9\u30d5\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/span><\/p>\n<p><span style=\"color: #000000;\">\u6b21\u306b\u3001\u4e8c\u4e57\u548c\u304c\u300c\u66f2\u304c\u308b\u300d\u304b\u5b89\u5b9a\u3057\u59cb\u3081\u308b\u300c\u819d\u300d\u3092\u63a2\u3057\u307e\u3059\u3002\u3053\u306e\u70b9\u306f\u3001\u30af\u30e9\u30b9\u30bf\u30fc\u306e\u6700\u9069\u306a\u6570\u3092\u8868\u3057\u307e\u3059\u3002<\/span><\/p>\n<p><span style=\"color: #000000;\">\u6b21\u306e\u30b3\u30fc\u30c9\u306f\u3001x \u8ef8\u306b\u30af\u30e9\u30b9\u30bf\u30fc\u306e\u6570\u3001y \u8ef8\u306b SSE \u3092\u8868\u793a\u3059\u308b\u3053\u306e\u30bf\u30a4\u30d7\u306e\u30d7\u30ed\u30c3\u30c8\u3092\u4f5c\u6210\u3059\u308b\u65b9\u6cd5\u3092\u793a\u3057\u3066\u3044\u307e\u3059\u3002<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#initialize kmeans parameters\n<\/span>kmeans_kwargs = {\n\" <span style=\"color: #ff0000;\">init<\/span> \": \" <span style=\"color: #ff0000;\">random<\/span> \",\n\" <span style=\"color: #ff0000;\">n_init<\/span> \": 10,\n\" <span style=\"color: #ff0000;\">random_state<\/span> \": 1,\n}\n\n<span style=\"color: #008080;\">#create list to hold SSE values for each k\n<\/span>sse = []\n<span style=\"color: #008000;\">for<\/span> k <span style=\"color: #008000;\">in<\/span> range(1, 11):\n    kmeans = KMeans(n_clusters=k, <span style=\"color: #800080;\">**<\/span> kmeans_kwargs)\n    kmeans. <span style=\"color: #3366ff;\">fit<\/span> (scaled_df)\n    sse. <span style=\"color: #3366ff;\">append<\/span> (kmeans.inertia_)\n\n<span style=\"color: #008080;\">#visualize results\n<\/span>plt. <span style=\"color: #3366ff;\">plot<\/span> (range(1, 11), sse)\nplt. <span style=\"color: #3366ff;\">xticks<\/span> (range(1, 11))\nplt. <span style=\"color: #3366ff;\">xlabel<\/span> (\" <span style=\"color: #ff0000;\">Number of Clusters<\/span> \")\nplt. <span style=\"color: #3366ff;\">ylabel<\/span> (\u201c <span style=\"color: #ff0000;\">SSE<\/span> \u201d)\nplt. <span style=\"color: #3366ff;\">show<\/span> ()<\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-29557 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/kmmoyenne1.jpg\" alt=\"\" width=\"531\" height=\"408\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p><span style=\"color: #000000;\">\u3053\u306e\u30b0\u30e9\u30d5\u3067\u306f\u3001 k = <strong>3 \u30af\u30e9\u30b9\u30bf\u30fc<\/strong>\u306b\u306d\u3058\u308c\u307e\u305f\u306f\u300c\u30cb\u30fc\u300d\u304c\u3042\u308b\u3088\u3046\u306b\u898b\u3048\u307e\u3059\u3002<\/span><\/p>\n<p><span style=\"color: #000000;\">\u3057\u305f\u304c\u3063\u3066\u3001\u6b21\u306e\u30b9\u30c6\u30c3\u30d7\u3067 K-means \u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0 \u30e2\u30c7\u30eb\u3092\u30d5\u30a3\u30c3\u30c6\u30a3\u30f3\u30b0\u3059\u308b\u3068\u304d\u306b 3 \u3064\u306e\u30af\u30e9\u30b9\u30bf\u30fc\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/span><\/p>\n<h2><span style=\"color: #000000;\"><strong>\u30b9\u30c6\u30c3\u30d7 4: \u6700\u9069\u306a<em>K<\/em>\u3092\u4f7f\u7528\u3057\u3066 K-Means \u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0\u3092\u5b9f\u884c\u3059\u308b<\/strong><\/span><\/h2>\n<p><span style=\"color: #000000;\">\u6b21\u306e\u30b3\u30fc\u30c9\u306f\u3001 <em>k<\/em>\u306e\u6700\u9069\u5024 3 \u3092\u4f7f\u7528\u3057\u3066\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u306b\u5bfe\u3057\u3066 k-means \u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0\u3092\u5b9f\u884c\u3059\u308b\u65b9\u6cd5\u3092\u793a\u3057\u3066\u3044\u307e\u3059\u3002<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008080;\">#instantiate the k-means class, using optimal number of clusters\n<\/span>kmeans = KMeans(init=\" <span style=\"color: #ff0000;\">random<\/span> \", n_clusters= <span style=\"color: #008000;\">3<\/span> , n_init= <span style=\"color: #008000;\">10<\/span> , random_state= <span style=\"color: #008000;\">1<\/span> )\n\n<span style=\"color: #008080;\">#fit k-means algorithm to data\n<\/span>kmeans. <span style=\"color: #3366ff;\">fit<\/span> (scaled_df)\n\n<span style=\"color: #008080;\">#view cluster assignments for each observation\n<\/span>kmeans. <span style=\"color: #3366ff;\">labels_\n\n<\/span>array([1, 1, 1, 1, 1, 1, 2, 2, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0]) \n<\/span><\/span><\/strong><\/pre>\n<p><span style=\"color: #000000;\">\u7d50\u679c\u306e\u30c6\u30fc\u30d6\u30eb\u306b\u306f\u3001DataFrame \u5185\u306e\u5404\u89b3\u6e2c\u5024\u306e\u30af\u30e9\u30b9\u30bf\u30fc\u5272\u308a\u5f53\u3066\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/span><\/p>\n<p><span style=\"color: #000000;\">\u3053\u308c\u3089\u306e\u7d50\u679c\u3092\u89e3\u91c8\u3057\u3084\u3059\u304f\u3059\u308b\u305f\u3081\u306b\u3001\u5404\u30d7\u30ec\u30fc\u30e4\u30fc\u306e\u30af\u30e9\u30b9\u30bf\u30fc\u5272\u308a\u5f53\u3066\u3092\u793a\u3059\u5217\u3092 DataFrame \u306b\u8ffd\u52a0\u3067\u304d\u307e\u3059\u3002<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008080;\">#append cluster assingments to original DataFrame\n<\/span>df[' <span style=\"color: #ff0000;\">cluster<\/span> '] = kmeans. <span style=\"color: #3366ff;\">labels_<\/span>\n\n<span style=\"color: #008080;\">#view updated DataFrame\n<\/span><span style=\"color: #008000;\">print<\/span> (df)\n\n<\/span><\/span>points assists rebounds cluster\n0 18.0 3.0 15 1\n2 19.0 4.0 14 1\n3 14.0 5.0 10 1\n4 14.0 4.0 8 1\n5 11.0 7.0 14 1\n6 20.0 8.0 13 1\n7 28.0 7.0 9 2\n8 30.0 6.0 5 2\n9 31.0 9.0 4 0\n10 35.0 12.0 11 0\n11 33.0 14.0 6 0\n13 25.0 9.0 5 0\n14 25.0 4.0 3 2\n15 27.0 3.0 8 2\n16 29.0 4.0 12 2\n17 30.0 12.0 7 0\n18 19.0 15.0 6 0\n19 23.0 11.0 5 0\n<\/strong><\/pre>\n<p><span style=\"color: #000000;\"><strong>\u30af\u30e9\u30b9\u30bf\u30fc<\/strong>\u5217\u306b\u306f\u3001\u5404\u30d7\u30ec\u30fc\u30e4\u30fc\u306b\u5272\u308a\u5f53\u3066\u3089\u308c\u305f\u30af\u30e9\u30b9\u30bf\u30fc\u756a\u53f7 (0\u30011\u3001\u307e\u305f\u306f 2) \u304c\u542b\u307e\u308c\u307e\u3059\u3002<\/span><\/p>\n<p><span style=\"color: #000000;\">\u540c\u3058\u30af\u30e9\u30b9\u30bf\u30fc\u306b\u5c5e\u3059\u308b\u30d7\u30ec\u30fc\u30e4\u30fc\u306f\u3001<strong>\u30dd\u30a4\u30f3\u30c8<\/strong>\u3001<strong>\u30a2\u30b7\u30b9\u30c8<\/strong>\u3001<strong>\u30ea\u30d0\u30a6\u30f3\u30c9\u306e<\/strong>\u5217\u306e\u5024\u304c\u307b\u307c\u4f3c\u3066\u3044\u307e\u3059\u3002<\/span><\/p>\n<p><span style=\"color: #000000;\"><strong>\u6ce8<\/strong>: <strong>sklearn<\/strong>\u306e<strong>KMeans<\/strong>\u95a2\u6570\u306e\u5b8c\u5168\u306a\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306f<a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.cluster.KMeans.html\" target=\"_blank\" rel=\"noopener\">\u3053\u3053\u3067<\/a>\u898b\u3064\u3051\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/span><\/p>\n<h2><span style=\"color: #000000;\"><strong>\u8ffd\u52a0\u30ea\u30bd\u30fc\u30b9<\/strong><\/span><\/h2>\n<p><span style=\"color: #000000;\">\u6b21\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u306f\u3001Python \u3067\u4ed6\u306e\u4e00\u822c\u7684\u306a\u30bf\u30b9\u30af\u3092\u5b9f\u884c\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/ja\/\u7dda\u5f62\u56de\u5e30python\/\" target=\"_blank\" rel=\"noopener\">Python \u3067\u7dda\u5f62\u56de\u5e30\u3092\u5b9f\u884c\u3059\u308b\u65b9\u6cd5<\/a><br \/><a href=\"https:\/\/statorials.org\/ja\/\u30ed\u30b7\u3099\u30b9\u30c6\u30a3\u30c3\u30af\u56de\u5e30python\/\" target=\"_blank\" rel=\"noopener\">Python \u3067\u30ed\u30b8\u30b9\u30c6\u30a3\u30c3\u30af\u56de\u5e30\u3092\u5b9f\u884c\u3059\u308b\u65b9\u6cd5<\/a><br \/><a href=\"https:\/\/statorials.org\/ja\/python\u3066\u3099\u306ek\u30d5\u30a9\u30fc\u30eb\u30c8\u3099\u76f8\u4e92\u691c\u8a3c\/\" target=\"_blank\" rel=\"noopener\">Python \u3067 K-Fold \u76f8\u4e92\u691c\u8a3c\u3092\u5b9f\u884c\u3059\u308b\u65b9\u6cd5<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6a5f\u68b0\u5b66\u7fd2\u3067\u6700\u3082\u4e00\u822c\u7684\u306a\u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0 \u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u306e 1 \u3064\u306f\u3001k-means \u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0\u3068\u3057\u3066\u77e5\u3089\u308c\u3066\u3044\u307e\u3059\u3002 K \u5e73\u5747\u6cd5\u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0\u306f\u3001\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u306e\u5404\u89b3\u6e2c\u5024\u3092K\u500b\u306e\u30af\u30e9\u30b9\u30bf\u30fc\u306e 1 \u3064\u306b\u914d\u7f6e\u3059\u308b\u624b\u6cd5\u3067\u3059\u3002 \u6700 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-4057","post","type-post","status-publish","format-standard","hentry","category-16"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python \u3067\u30a8\u30eb\u30dc\u6cd5\u3092\u4f7f\u7528\u3057\u3066\u6700\u9069\u306a\u30af\u30e9\u30b9\u30bf\u30fc\u3092\u898b\u3064\u3051\u308b\u65b9\u6cd5 - Statorials<\/title>\n<meta name=\"description\" content=\"\u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u306f\u3001Python \u3067 Elbow \u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u3001\u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0 \u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u3067\u4f7f\u7528\u3059\u308b\u6700\u9069\u306a\u30af\u30e9\u30b9\u30bf\u30fc\u6570\u3092\u898b\u3064\u3051\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/statorials.org\/ja\/python\u306e\u8098\u30e1\u30bd\u30c3\u30c8\u3099\/\" \/>\n<meta property=\"og:locale\" content=\"ja_JP\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python \u3067\u30a8\u30eb\u30dc\u6cd5\u3092\u4f7f\u7528\u3057\u3066\u6700\u9069\u306a\u30af\u30e9\u30b9\u30bf\u30fc\u3092\u898b\u3064\u3051\u308b\u65b9\u6cd5 - Statorials\" \/>\n<meta property=\"og:description\" content=\"\u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u306f\u3001Python \u3067 Elbow \u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u3001\u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0 \u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u3067\u4f7f\u7528\u3059\u308b\u6700\u9069\u306a\u30af\u30e9\u30b9\u30bf\u30fc\u6570\u3092\u898b\u3064\u3051\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/ja\/python\u306e\u8098\u30e1\u30bd\u30c3\u30c8\u3099\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-13T20:58:15+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/kmmoyenne1.jpg\" \/>\n<meta name=\"author\" content=\"\u30d9\u30f3\u30b8\u30e3\u30df\u30f3\u30fb\u30a2\u30f3\u30c0\u30fc\u30bd\u30f3\u535a\u58eb\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u57f7\u7b46\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u30d9\u30f3\u30b8\u30e3\u30df\u30f3\u30fb\u30a2\u30f3\u30c0\u30fc\u30bd\u30f3\u535a\u58eb\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u63a8\u5b9a\u8aad\u307f\u53d6\u308a\u6642\u9593\" \/>\n\t<meta name=\"twitter:data2\" content=\"1\u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/ja\/python%e3%81%ae%e8%82%98%e3%83%a1%e3%82%bd%e3%83%83%e3%83%88%e3%82%99\/\",\"url\":\"https:\/\/statorials.org\/ja\/python%e3%81%ae%e8%82%98%e3%83%a1%e3%82%bd%e3%83%83%e3%83%88%e3%82%99\/\",\"name\":\"Python \u3067\u30a8\u30eb\u30dc\u6cd5\u3092\u4f7f\u7528\u3057\u3066\u6700\u9069\u306a\u30af\u30e9\u30b9\u30bf\u30fc\u3092\u898b\u3064\u3051\u308b\u65b9\u6cd5 - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/ja\/#website\"},\"datePublished\":\"2023-07-13T20:58:15+00:00\",\"dateModified\":\"2023-07-13T20:58:15+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/ja\/#\/schema\/person\/86b92d2dd87368b26360d19d9c6a5d83\"},\"description\":\"\u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u306f\u3001Python \u3067 Elbow \u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u3001\u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0 \u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u3067\u4f7f\u7528\u3059\u308b\u6700\u9069\u306a\u30af\u30e9\u30b9\u30bf\u30fc\u6570\u3092\u898b\u3064\u3051\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/ja\/python%e3%81%ae%e8%82%98%e3%83%a1%e3%82%bd%e3%83%83%e3%83%88%e3%82%99\/#breadcrumb\"},\"inLanguage\":\"ja\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/ja\/python%e3%81%ae%e8%82%98%e3%83%a1%e3%82%bd%e3%83%83%e3%83%88%e3%82%99\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/ja\/python%e3%81%ae%e8%82%98%e3%83%a1%e3%82%bd%e3%83%83%e3%83%88%e3%82%99\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u5bb6\",\"item\":\"https:\/\/statorials.org\/ja\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python \u3067\u30a8\u30eb\u30dc\u6cd5\u3092\u4f7f\u7528\u3057\u3066\u6700\u9069\u306a\u30af\u30e9\u30b9\u30bf\u30fc\u3092\u898b\u3064\u3051\u308b\u65b9\u6cd5\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/ja\/#website\",\"url\":\"https:\/\/statorials.org\/ja\/\",\"name\":\"Statorials\",\"description\":\"\u7d71\u8a08\u80fd\u529b\u3078\u306e\u30ac\u30a4\u30c9\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/ja\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"ja\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/ja\/#\/schema\/person\/86b92d2dd87368b26360d19d9c6a5d83\",\"name\":\"\u30d9\u30f3\u30b8\u30e3\u30df\u30f3\u30fb\u30a2\u30f3\u30c0\u30fc\u30bd\u30f3\u535a\u58eb\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/statorials.org\/ja\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/statorials.org\/ja\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"http:\/\/statorials.org\/ja\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"caption\":\"\u30d9\u30f3\u30b8\u30e3\u30df\u30f3\u30fb\u30a2\u30f3\u30c0\u30fc\u30bd\u30f3\u535a\u58eb\"},\"description\":\"\u79c1\u306f\u30d9\u30f3\u30b8\u30e3\u30df\u30f3\u3067\u3059\u3002\u9000\u8077\u3057\u305f\u7d71\u8a08\u6559\u6388\u304b\u3089\u3001\u5c02\u4efb\u306e Statorials \u6559\u80b2\u8005\u306b\u306a\u308a\u307e\u3057\u305f\u3002 \u7d71\u8a08\u5206\u91ce\u306b\u304a\u3051\u308b\u8c4a\u5bcc\u306a\u7d4c\u9a13\u3068\u5c02\u9580\u77e5\u8b58\u3092\u6d3b\u304b\u3057\u3066\u3001\u79c1\u306f Statorials \u3092\u901a\u3058\u3066\u5b66\u751f\u306b\u529b\u3092\u4e0e\u3048\u308b\u305f\u3081\u306b\u81ea\u5206\u306e\u77e5\u8b58\u3092\u5171\u6709\u3059\u308b\u3053\u3068\u306b\u5c3d\u529b\u3057\u3066\u3044\u307e\u3059\u3002\u3082\u3063\u3068\u77e5\u308b\",\"sameAs\":[\"http:\/\/statorials.org\/ja\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python \u3067\u30a8\u30eb\u30dc\u6cd5\u3092\u4f7f\u7528\u3057\u3066\u6700\u9069\u306a\u30af\u30e9\u30b9\u30bf\u30fc\u3092\u898b\u3064\u3051\u308b\u65b9\u6cd5 - Statorials","description":"\u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u306f\u3001Python \u3067 Elbow \u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u3001\u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0 \u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u3067\u4f7f\u7528\u3059\u308b\u6700\u9069\u306a\u30af\u30e9\u30b9\u30bf\u30fc\u6570\u3092\u898b\u3064\u3051\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/statorials.org\/ja\/python\u306e\u8098\u30e1\u30bd\u30c3\u30c8\u3099\/","og_locale":"ja_JP","og_type":"article","og_title":"Python \u3067\u30a8\u30eb\u30dc\u6cd5\u3092\u4f7f\u7528\u3057\u3066\u6700\u9069\u306a\u30af\u30e9\u30b9\u30bf\u30fc\u3092\u898b\u3064\u3051\u308b\u65b9\u6cd5 - Statorials","og_description":"\u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u306f\u3001Python \u3067 Elbow \u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u3001\u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0 \u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u3067\u4f7f\u7528\u3059\u308b\u6700\u9069\u306a\u30af\u30e9\u30b9\u30bf\u30fc\u6570\u3092\u898b\u3064\u3051\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002","og_url":"https:\/\/statorials.org\/ja\/python\u306e\u8098\u30e1\u30bd\u30c3\u30c8\u3099\/","og_site_name":"Statorials","article_published_time":"2023-07-13T20:58:15+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/kmmoyenne1.jpg"}],"author":"\u30d9\u30f3\u30b8\u30e3\u30df\u30f3\u30fb\u30a2\u30f3\u30c0\u30fc\u30bd\u30f3\u535a\u58eb","twitter_card":"summary_large_image","twitter_misc":{"\u57f7\u7b46\u8005":"\u30d9\u30f3\u30b8\u30e3\u30df\u30f3\u30fb\u30a2\u30f3\u30c0\u30fc\u30bd\u30f3\u535a\u58eb","\u63a8\u5b9a\u8aad\u307f\u53d6\u308a\u6642\u9593":"1\u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/ja\/python%e3%81%ae%e8%82%98%e3%83%a1%e3%82%bd%e3%83%83%e3%83%88%e3%82%99\/","url":"https:\/\/statorials.org\/ja\/python%e3%81%ae%e8%82%98%e3%83%a1%e3%82%bd%e3%83%83%e3%83%88%e3%82%99\/","name":"Python \u3067\u30a8\u30eb\u30dc\u6cd5\u3092\u4f7f\u7528\u3057\u3066\u6700\u9069\u306a\u30af\u30e9\u30b9\u30bf\u30fc\u3092\u898b\u3064\u3051\u308b\u65b9\u6cd5 - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/ja\/#website"},"datePublished":"2023-07-13T20:58:15+00:00","dateModified":"2023-07-13T20:58:15+00:00","author":{"@id":"https:\/\/statorials.org\/ja\/#\/schema\/person\/86b92d2dd87368b26360d19d9c6a5d83"},"description":"\u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u306f\u3001Python \u3067 Elbow \u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u3001\u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0 \u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u3067\u4f7f\u7528\u3059\u308b\u6700\u9069\u306a\u30af\u30e9\u30b9\u30bf\u30fc\u6570\u3092\u898b\u3064\u3051\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002","breadcrumb":{"@id":"https:\/\/statorials.org\/ja\/python%e3%81%ae%e8%82%98%e3%83%a1%e3%82%bd%e3%83%83%e3%83%88%e3%82%99\/#breadcrumb"},"inLanguage":"ja","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/ja\/python%e3%81%ae%e8%82%98%e3%83%a1%e3%82%bd%e3%83%83%e3%83%88%e3%82%99\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/ja\/python%e3%81%ae%e8%82%98%e3%83%a1%e3%82%bd%e3%83%83%e3%83%88%e3%82%99\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u5bb6","item":"https:\/\/statorials.org\/ja\/"},{"@type":"ListItem","position":2,"name":"Python \u3067\u30a8\u30eb\u30dc\u6cd5\u3092\u4f7f\u7528\u3057\u3066\u6700\u9069\u306a\u30af\u30e9\u30b9\u30bf\u30fc\u3092\u898b\u3064\u3051\u308b\u65b9\u6cd5"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/ja\/#website","url":"https:\/\/statorials.org\/ja\/","name":"Statorials","description":"\u7d71\u8a08\u80fd\u529b\u3078\u306e\u30ac\u30a4\u30c9","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/ja\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"ja"},{"@type":"Person","@id":"https:\/\/statorials.org\/ja\/#\/schema\/person\/86b92d2dd87368b26360d19d9c6a5d83","name":"\u30d9\u30f3\u30b8\u30e3\u30df\u30f3\u30fb\u30a2\u30f3\u30c0\u30fc\u30bd\u30f3\u535a\u58eb","image":{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/statorials.org\/ja\/#\/schema\/person\/image\/","url":"http:\/\/statorials.org\/ja\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","contentUrl":"http:\/\/statorials.org\/ja\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","caption":"\u30d9\u30f3\u30b8\u30e3\u30df\u30f3\u30fb\u30a2\u30f3\u30c0\u30fc\u30bd\u30f3\u535a\u58eb"},"description":"\u79c1\u306f\u30d9\u30f3\u30b8\u30e3\u30df\u30f3\u3067\u3059\u3002\u9000\u8077\u3057\u305f\u7d71\u8a08\u6559\u6388\u304b\u3089\u3001\u5c02\u4efb\u306e Statorials \u6559\u80b2\u8005\u306b\u306a\u308a\u307e\u3057\u305f\u3002 \u7d71\u8a08\u5206\u91ce\u306b\u304a\u3051\u308b\u8c4a\u5bcc\u306a\u7d4c\u9a13\u3068\u5c02\u9580\u77e5\u8b58\u3092\u6d3b\u304b\u3057\u3066\u3001\u79c1\u306f Statorials \u3092\u901a\u3058\u3066\u5b66\u751f\u306b\u529b\u3092\u4e0e\u3048\u308b\u305f\u3081\u306b\u81ea\u5206\u306e\u77e5\u8b58\u3092\u5171\u6709\u3059\u308b\u3053\u3068\u306b\u5c3d\u529b\u3057\u3066\u3044\u307e\u3059\u3002\u3082\u3063\u3068\u77e5\u308b","sameAs":["http:\/\/statorials.org\/ja"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/ja\/wp-json\/wp\/v2\/posts\/4057","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/statorials.org\/ja\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/ja\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/ja\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/ja\/wp-json\/wp\/v2\/comments?post=4057"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/ja\/wp-json\/wp\/v2\/posts\/4057\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/ja\/wp-json\/wp\/v2\/media?parent=4057"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/ja\/wp-json\/wp\/v2\/categories?post=4057"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/ja\/wp-json\/wp\/v2\/tags?post=4057"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}