{"id":1242,"date":"2023-07-27T04:03:40","date_gmt":"2023-07-27T04:03:40","guid":{"rendered":"https:\/\/statorials.org\/ja\/k-%e3%81%af-r-%e3%81%a6%e3%82%99%e3%82%af%e3%82%99%e3%83%ab%e3%83%bc%e3%83%95%e3%82%9a%e5%8c%96%e3%81%99%e3%82%8b%e3%81%93%e3%81%a8%e3%82%92%e6%84%8f%e5%91%b3%e3%81%97%e3%81%be%e3%81%99\/"},"modified":"2023-07-27T04:03:40","modified_gmt":"2023-07-27T04:03:40","slug":"k-%e3%81%af-r-%e3%81%a6%e3%82%99%e3%82%af%e3%82%99%e3%83%ab%e3%83%bc%e3%83%95%e3%82%9a%e5%8c%96%e3%81%99%e3%82%8b%e3%81%93%e3%81%a8%e3%82%92%e6%84%8f%e5%91%b3%e3%81%97%e3%81%be%e3%81%99","status":"publish","type":"post","link":"https:\/\/statorials.org\/ja\/k-%e3%81%af-r-%e3%81%a6%e3%82%99%e3%82%af%e3%82%99%e3%83%ab%e3%83%bc%e3%83%95%e3%82%9a%e5%8c%96%e3%81%99%e3%82%8b%e3%81%93%e3%81%a8%e3%82%92%e6%84%8f%e5%91%b3%e3%81%97%e3%81%be%e3%81%99\/","title":{"rendered":"R \u3067\u306e k-means \u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0: \u30b9\u30c6\u30c3\u30d7\u30d0\u30a4\u30b9\u30c6\u30c3\u30d7\u306e\u4f8b"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">\u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0\u306f\u3001\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u5185\u306e<a href=\"https:\/\/statorials.org\/ja\/\u7d71\u8a08\u306b\u304a\u3051\u308b\u89b3\u5bdf\/\" target=\"_blank\" rel=\"noopener noreferrer\">\u89b3\u6e2c\u5024<\/a>\u306e<em>\u30b0\u30eb\u30fc\u30d7\u3092<\/em>\u898b\u3064\u3051\u3088\u3046\u3068\u3059\u308b\u6a5f\u68b0\u5b66\u7fd2\u624b\u6cd5\u3067\u3059\u3002<\/span><\/p>\n<p><span style=\"color: #000000;\">\u76ee\u6a19\u306f\u3001\u5404\u30af\u30e9\u30b9\u30bf\u30fc\u5185\u306e\u89b3\u6e2c\u5024\u304c\u4e92\u3044\u306b\u975e\u5e38\u306b\u985e\u4f3c\u3057\u3066\u3044\u308b\u4e00\u65b9\u3067\u3001\u7570\u306a\u308b\u30af\u30e9\u30b9\u30bf\u30fc\u5185\u306e\u89b3\u6e2c\u5024\u304c\u4e92\u3044\u306b\u5927\u304d\u304f\u7570\u306a\u308b\u3088\u3046\u306a\u30af\u30e9\u30b9\u30bf\u30fc\u3092\u898b\u3064\u3051\u308b\u3053\u3068\u3067\u3059\u3002<\/span><\/p>\n<p><span style=\"color: #000000;\">\u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0\u306f\u3001 <a href=\"https:\/\/statorials.org\/ja\/\u5909\u6570\u306e\u8aac\u660e\u5fdc\u7b54\/\" target=\"_blank\" rel=\"noopener noreferrer\">\u5fdc\u7b54\u5909\u6570<\/a>\u306e\u5024\u3092\u4e88\u6e2c\u3059\u308b\u306e\u3067\u306f\u306a\u304f\u3001\u5358\u306b\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u5185\u306e\u69cb\u9020\u3092\u898b\u3064\u3051\u3088\u3046\u3068\u3057\u3066\u3044\u308b\u3060\u3051\u3067\u3042\u308b\u305f\u3081\u3001 <a href=\"https:\/\/statorials.org\/ja\/\u6559\u5e2b\u3042\u308a\u5b66\u7fd2\u3068\u6559\u5e2b\u306a\u3057\u5b66\u7fd2\/\" target=\"_blank\" rel=\"noopener noreferrer\">\u6559\u5e2b\u306a\u3057\u5b66\u7fd2<\/a>\u306e\u4e00\u7a2e\u3067\u3059\u3002<\/span><\/p>\n<p><span style=\"color: #000000;\">\u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0\u306f\u3001\u4f01\u696d\u304c\u6b21\u306e\u3088\u3046\u306a\u60c5\u5831\u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u5834\u5408\u306b\u30de\u30fc\u30b1\u30c6\u30a3\u30f3\u30b0\u3067\u3088\u304f\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002<\/span><\/p>\n<ul>\n<li><span style=\"color: #000000;\">\u4e16\u5e2f\u53ce\u5165<\/span><\/li>\n<li><span style=\"color: #000000;\">\u4e16\u5e2f\u898f\u6a21<\/span><\/li>\n<li><span style=\"color: #000000;\">\u4e16\u5e2f\u4e3b\u306e\u8077\u696d<\/span><\/li>\n<li><span style=\"color: #000000;\">\u6700\u5bc4\u308a\u306e\u5e02\u8857\u5730\u307e\u3067\u306e\u8ddd\u96e2<\/span><\/li>\n<\/ul>\n<p><span style=\"color: #000000;\">\u3053\u306e\u60c5\u5831\u304c\u5229\u7528\u53ef\u80fd\u306a\u5834\u5408\u3001\u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0\u3092\u4f7f\u7528\u3057\u3066\u3001\u7279\u5b9a\u306e\u88fd\u54c1\u3092\u8cfc\u5165\u3059\u308b\u53ef\u80fd\u6027\u304c\u9ad8\u3044\u3001\u307e\u305f\u306f\u7279\u5b9a\u306e\u7a2e\u985e\u306e\u5e83\u544a\u306b\u3088\u308a\u3088\u304f\u53cd\u5fdc\u3059\u308b\u53ef\u80fd\u6027\u304c\u9ad8\u3044\u3001\u985e\u4f3c\u3057\u305f\u4e16\u5e2f\u3092\u8b58\u5225\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/span><\/p>\n<p><span style=\"color: #000000;\">\u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0\u306e\u6700\u3082\u4e00\u822c\u7684\u306a\u5f62\u5f0f\u306e 1 \u3064\u306f\u3001 <strong>k-means \u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0<\/strong>\u3068\u3057\u3066\u77e5\u3089\u308c\u3066\u3044\u307e\u3059\u3002<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>K-Means \u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0\u3068\u306f\u4f55\u3067\u3059\u304b?<\/strong><\/span><\/h3>\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;\">\u5b9f\u969b\u306b\u306f\u3001\u6b21\u306e\u624b\u9806\u3092\u4f7f\u7528\u3057\u3066 K-means \u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>1. <em>K<\/em>\u306e\u5024\u3092\u9078\u629e\u3057\u307e\u3059\u3002<\/strong><\/span><\/p>\n<ul>\n<li><span style=\"color: #000000;\">\u307e\u305a\u3001\u30c7\u30fc\u30bf\u5185\u3067\u8b58\u5225\u3059\u308b\u30af\u30e9\u30b9\u30bf\u30fc\u306e\u6570\u3092\u6c7a\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u591a\u304f\u306e\u5834\u5408\u3001 <em>K<\/em>\u306e\u3044\u304f\u3064\u304b\u306e\u7570\u306a\u308b\u5024\u3092\u30c6\u30b9\u30c8\u3057\u3001\u305d\u306e\u7d50\u679c\u3092\u5206\u6790\u3057\u3066\u3001\u7279\u5b9a\u306e\u554f\u984c\u306b\u5bfe\u3057\u3066\u3069\u306e\u30af\u30e9\u30b9\u30bf\u30fc\u306e\u6570\u304c\u6700\u3082\u5408\u7406\u7684\u3067\u3042\u308b\u304b\u3092\u78ba\u8a8d\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\"><strong>2. \u5404\u89b3\u6e2c\u5024\u3092 1 \u304b\u3089<em>K<\/em>\u307e\u3067\u306e\u521d\u671f\u30af\u30e9\u30b9\u30bf\u30fc\u306b\u30e9\u30f3\u30c0\u30e0\u306b\u5272\u308a\u5f53\u3066\u307e\u3059\u3002<\/strong><\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>3. \u30af\u30e9\u30b9\u30bf\u30fc\u306e\u5272\u308a\u5f53\u3066\u304c\u5909\u66f4\u3055\u308c\u306a\u304f\u306a\u308b\u307e\u3067\u3001\u6b21\u306e\u624b\u9806\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/strong><\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><em>K<\/em>\u500b\u306e\u30af\u30e9\u30b9\u30bf\u30fc\u306e\u305d\u308c\u305e\u308c\u306b\u3064\u3044\u3066\u3001<em>\u30af\u30e9\u30b9\u30bf\u30fc\u306e\u91cd\u5fc3\u3092\u8a08\u7b97\u3057\u307e\u3059\u3002<\/em>\u3053\u308c\u306f\u5358\u306b\u3001 <em>k \u756a\u76ee\u306e<\/em>\u30af\u30e9\u30b9\u30bf\u30fc\u306e\u89b3\u6e2c\u5024\u306e<em>p<\/em>\u5e73\u5747\u7279\u5fb4\u306e\u30d9\u30af\u30c8\u30eb\u3067\u3059\u3002<\/span><\/li>\n<li><span style=\"color: #000000;\">\u5404\u89b3\u6e2c\u5024\u3092\u6700\u3082\u8fd1\u3044\u91cd\u5fc3\u3092\u6301\u3064\u30af\u30e9\u30b9\u30bf\u30fc\u306b\u5272\u308a\u5f53\u3066\u307e\u3059\u3002\u3053\u3053\u3067\u3001<em>\u6700\u3082\u8fd1\u3044<\/em>\u306f<a href=\"https:\/\/en.wikipedia.org\/wiki\/Euclidean_distance#Squared_Euclidean_distance\" target=\"_blank\" rel=\"noopener noreferrer\">\u30e6\u30fc\u30af\u30ea\u30c3\u30c9\u8ddd\u96e2<\/a>\u3092\u4f7f\u7528\u3057\u3066\u5b9a\u7fa9\u3055\u308c\u307e\u3059\u3002<\/span><\/li>\n<\/ul>\n<h3> <span style=\"color: #000000;\"><strong>R \u3067\u306e K-Means \u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0<\/strong><\/span><\/h3>\n<p><span style=\"color: #000000;\">\u6b21\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u306f\u3001R \u3067 K-means \u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0\u3092\u5b9f\u884c\u3059\u308b\u65b9\u6cd5\u306e\u6bb5\u968e\u7684\u306a\u4f8b\u3092\u793a\u3057\u307e\u3059\u3002<\/span><\/p>\n<h3><span style=\"color: #000000;\"><strong>\u30b9\u30c6\u30c3\u30d7 1: \u5fc5\u8981\u306a\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30ed\u30fc\u30c9\u3059\u308b<\/strong><\/span><\/h3>\n<p><span style=\"color: #000000;\">\u307e\u305a\u3001R \u306e K-means \u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0\u306b\u5f79\u7acb\u3064\u3044\u304f\u3064\u304b\u306e\u95a2\u6570\u3092\u542b\u3080 2 \u3064\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u8aad\u307f\u8fbc\u307f\u307e\u3059\u3002<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #993300;\">library<\/span> (factoextra)\n<span style=\"color: #993300;\">library<\/span> (cluster)<\/strong><\/pre>\n<h3><span style=\"color: #000000;\"><strong>\u30b9\u30c6\u30c3\u30d7 2: \u30c7\u30fc\u30bf\u306e\u30ed\u30fc\u30c9\u3068\u6e96\u5099<\/strong><\/span><\/h3>\n<p><span style=\"color: #000000;\">\u3053\u306e\u4f8b\u3067\u306f\u3001R \u306b\u7d44\u307f\u8fbc\u307e\u308c\u3066\u3044\u308b<em>USArrests<\/em>\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002\u3053\u306e\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u306b\u306f\u30011973 \u5e74\u306e\u7c73\u56fd\u5404\u5dde\u306e\u4eba\u53e3 100,000 \u4eba\u3042\u305f\u308a\u306e<em>\u6bba\u4eba<\/em>\u3001<em>\u66b4\u884c<\/em>\u3001<em>\u5f37\u59e6<\/em>\u306e\u902e\u6355\u6570\u3068\u3001\u90fd\u5e02\u90e8\u306b\u4f4f\u3080\u5404\u5dde\u306e\u4eba\u53e3\u306e\u5272\u5408\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002\u5730\u57df\u3002 \u3001<em>\u30a2\u30fc\u30d0\u30f3\u30dd\u30c3\u30d7<\/em>\u3002<\/span><\/p>\n<p><span style=\"color: #000000;\">\u6b21\u306e\u30b3\u30fc\u30c9\u306f\u3001\u6b21\u306e\u3053\u3068\u3092\u884c\u3046\u65b9\u6cd5\u3092\u793a\u3057\u3066\u3044\u307e\u3059\u3002<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><em>USArrests<\/em>\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u3092\u30ed\u30fc\u30c9\u3059\u308b<\/span><\/li>\n<li><span style=\"color: #000000;\">\u6b20\u640d\u5024\u306e\u3042\u308b\u884c\u3092\u3059\u3079\u3066\u524a\u9664\u3057\u307e\u3059<\/span><\/li>\n<li><span style=\"color: #000000;\">\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u5185\u306e\u5404\u5909\u6570\u3092\u3001\u5e73\u5747\u304c 0\u3001\u6a19\u6e96\u504f\u5dee\u304c 1 \u306b\u306a\u308b\u3088\u3046\u306b\u30b9\u30b1\u30fc\u30ea\u30f3\u30b0\u3057\u307e\u3059\u3002<\/span><\/li>\n<\/ul>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#load data<\/span>\ndf &lt;-USArrests\n\n<span style=\"color: #008080;\">#remove rows with missing values<\/span><\/strong>\n<strong>df &lt;- na. <span style=\"color: #3366ff;\">omitted<\/span> (df)\n\n<span style=\"color: #008080;\">#scale each variable to have a mean of 0 and sd of 1<\/span><\/strong>\n<strong>df &lt;- scale(df)\n\n<span style=\"color: #008080;\">#view first six rows of dataset<\/span>\nhead(df)\n\n               Murder Assault UrbanPop Rape\nAlabama 1.24256408 0.7828393 -0.5209066 -0.003416473\nAlaska 0.50786248 1.1068225 -1.2117642 2.484202941\nArizona 0.07163341 1.4788032 0.9989801 1.042878388\nArkansas 0.23234938 0.2308680 -1.0735927 -0.184916602\nCalifornia 0.27826823 1.2628144 1.7589234 2.067820292\nColorado 0.02571456 0.3988593 0.8608085 1.864967207\n<\/strong><\/pre>\n<h3><span style=\"color: #000000;\"><strong>\u30b9\u30c6\u30c3\u30d7 3: \u6700\u9069\u306a\u30af\u30e9\u30b9\u30bf\u30fc\u6570\u3092\u898b\u3064\u3051\u308b<\/strong><\/span><\/h3>\n<p><span style=\"color: #000000;\">R \u3067 K \u5e73\u5747\u6cd5\u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0\u3092\u5b9f\u884c\u3059\u308b\u306b\u306f\u3001\u6b21\u306e\u69cb\u6587\u3092\u4f7f\u7528\u3059\u308b\u7d44\u307f\u8fbc\u307f<strong>kmeans()<\/strong>\u95a2\u6570\u3092\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>kmeans (\u30c7\u30fc\u30bf\u3001\u30bb\u30f3\u30bf\u30fc\u3001nstart)<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">\u91d1\uff1a<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><strong>data:<\/strong>\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u306e\u540d\u524d\u3002<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>centers:<\/strong>\u30af\u30e9\u30b9\u30bf\u30fc\u306e\u6570 ( <em>k<\/em>\u3067\u793a\u3055\u308c\u307e\u3059)\u3002<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>nstart:<\/strong>\u521d\u671f\u8a2d\u5b9a\u306e\u6570\u3002\u521d\u671f\u958b\u59cb\u30af\u30e9\u30b9\u30bf\u30fc\u304c\u7570\u306a\u308b\u3068\u7570\u306a\u308b\u7d50\u679c\u304c\u751f\u3058\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u305f\u3081\u3001\u3044\u304f\u3064\u304b\u306e\u7570\u306a\u308b\u521d\u671f\u69cb\u6210\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3092\u304a\u52e7\u3081\u3057\u307e\u3059\u3002 K \u5e73\u5747\u6cd5\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u306f\u3001\u30af\u30e9\u30b9\u30bf\u30fc\u5185\u3067\u6700\u5c0f\u306e\u5909\u52d5\u3092\u3082\u305f\u3089\u3059\u521d\u671f\u69cb\u6210\u3092\u898b\u3064\u3051\u307e\u3059\u3002<\/span><\/li>\n<\/ul>\n<p><span style=\"color: #000000;\">\u6700\u9069\u306a\u30af\u30e9\u30b9\u30bf\u30fc\u306e\u6570\u304c\u4e8b\u524d\u306b\u308f\u304b\u3089\u306a\u3044\u305f\u3081\u3001\u6c7a\u5b9a\u306b\u5f79\u7acb\u3064 2 \u3064\u306e\u7570\u306a\u308b\u30b0\u30e9\u30d5\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>1. \u5e73\u65b9\u548c\u306e\u5408\u8a08\u306b\u5bfe\u3059\u308b\u30af\u30e9\u30b9\u30bf\u30fc\u306e\u6570<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">\u307e\u305a\u3001 <strong>fviz_nbclust()<\/strong>\u95a2\u6570\u3092\u4f7f\u7528\u3057\u3066\u3001\u30af\u30e9\u30b9\u30bf\u30fc\u6570\u3068\u5e73\u65b9\u548c\u306e\u5408\u8a08\u306e\u30d7\u30ed\u30c3\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>fviz_nbclust(df, kmeans, method = \u201c <span style=\"color: #008000;\">wss<\/span> \u201d)<\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-12310 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/kmmoyenne1.png\" alt=\"K-means \u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0\u306b\u304a\u3051\u308b\u6700\u9069\u306a\u30af\u30e9\u30b9\u30bf\u30fc\u6570\" width=\"444\" height=\"434\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p><span style=\"color: #000000;\">\u901a\u5e38\u3001\u3053\u306e\u30bf\u30a4\u30d7\u306e\u30d7\u30ed\u30c3\u30c8\u3092\u4f5c\u6210\u3059\u308b\u3068\u304d\u306f\u3001\u5e73\u65b9\u548c\u304c\u300c\u66f2\u304c\u308b\u300d\u304b\u6a2a\u3070\u3044\u306b\u306a\u308a\u59cb\u3081\u308b\u300c\u819d\u300d\u3092\u63a2\u3057\u307e\u3059\u3002\u3053\u308c\u306f\u901a\u5e38\u3001\u6700\u9069\u306a\u30af\u30e9\u30b9\u30bf\u30fc\u6570\u3067\u3059\u3002<\/span><\/p>\n<p><span style=\"color: #000000;\">\u3053\u306e\u30b0\u30e9\u30d5\u3067\u306f\u3001k = 4 \u30af\u30e9\u30b9\u30bf\u30fc\u306b\u5c0f\u3055\u306a\u306d\u3058\u308c\u307e\u305f\u306f\u300c\u66f2\u304c\u308a\u300d\u304c\u3042\u308b\u3088\u3046\u306b\u898b\u3048\u307e\u3059\u3002<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>2. \u30af\u30e9\u30b9\u30bf\u30fc\u6570\u3068\u30ae\u30e3\u30c3\u30d7\u7d71\u8a08<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">\u6700\u9069\u306a\u30af\u30e9\u30b9\u30bf\u30fc\u6570\u3092\u6c7a\u5b9a\u3059\u308b\u3082\u3046 1 \u3064\u306e\u65b9\u6cd5\u306f\u3001 <a style=\"color: #000000;\" href=\"https:\/\/web.stanford.edu\/~hastie\/Papers\/gap.pdf\" target=\"_blank\" rel=\"noopener noreferrer\">\u504f\u5dee\u7d71\u8a08<\/a>\u3068\u547c\u3070\u308c\u308b\u30e1\u30c8\u30ea\u30c3\u30af\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3059\u3002\u3053\u308c\u306f\u3001k \u306e\u3055\u307e\u3056\u307e\u306a\u5024\u306e\u30af\u30e9\u30b9\u30bf\u30fc\u5185\u5909\u52d5\u306e\u5408\u8a08\u3092\u3001\u30af\u30e9\u30b9\u30bf\u30fc\u5316\u3092\u884c\u308f\u306a\u3044\u5206\u5e03\u306e\u671f\u5f85\u5024\u3068\u6bd4\u8f03\u3057\u307e\u3059\u3002<\/span><\/p>\n<p><span style=\"color: #000000;\"><em>\u30af\u30e9\u30b9\u30bf\u30fc<\/em>\u30d1\u30c3\u30b1\u30fc\u30b8\u306e<strong>clusGap()<\/strong>\u95a2\u6570\u3092\u4f7f\u7528\u3057\u3066\u30af\u30e9\u30b9\u30bf\u30fc\u306e\u5404\u6570\u306e\u30ae\u30e3\u30c3\u30d7\u7d71\u8a08\u3092\u8a08\u7b97\u3057\u305f\u308a\u3001 <strong>fviz_gap_stat()<\/strong>\u95a2\u6570\u3092\u4f7f\u7528\u3057\u3066\u30ae\u30e3\u30c3\u30d7\u7d71\u8a08\u306b\u5bfe\u3057\u3066\u30af\u30e9\u30b9\u30bf\u30fc\u3092\u30d7\u30ed\u30c3\u30c8\u3057\u305f\u308a\u3067\u304d\u307e\u3059\u3002<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#calculate gap statistic based on number of clusters\n<\/span>gap_stat &lt;- clusGap(df,\n                    FUN = kmeans,\n                    nstart = 25,\n                    K.max = 10,\n                    B = 50)\n\n<span style=\"color: #008080;\">#plot number of clusters vs. gap statistic\n<\/span>fviz_gap_stat(gap_stat)<\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-12311 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/moyenne-km2.png\" alt=\"\u6700\u9069\u306a\u30af\u30e9\u30b9\u30bf\u30fc\u6570\u306e\u504f\u5dee\u7d71\u8a08\" width=\"454\" height=\"445\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p><span style=\"color: #000000;\">\u30b0\u30e9\u30d5\u304b\u3089\u3001\u30ae\u30e3\u30c3\u30d7\u7d71\u8a08\u304c k = 4 \u30af\u30e9\u30b9\u30bf\u30fc\u3067\u6700\u3082\u9ad8\u304f\u306a\u308b\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3059\u3002\u3053\u308c\u306f\u3001\u4ee5\u524d\u306b\u4f7f\u7528\u3057\u305f\u30a8\u30eb\u30dc\u30fc\u6cd5\u306b\u5bfe\u5fdc\u3057\u307e\u3059\u3002<\/span><\/p>\n<h3><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><\/h3>\n<p><span style=\"color: #000000;\">\u6700\u5f8c\u306b\u3001 <em>k<\/em>\u306e\u6700\u9069\u5024 4 \u3092\u4f7f\u7528\u3057\u3066\u3001\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u306b\u5bfe\u3057\u3066 k-means \u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0\u3092\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#make this example reproducible\n<span style=\"color: #000000;\">set.seed(1)<\/span>\n\n#perform k-means clustering with k = 4 clusters\n<\/span>km &lt;- kmeans(df, centers = 4, nstart = 25)\n\n<span style=\"color: #008080;\">#view results\n<\/span>km\n\nK-means clustering with 4 clusters of sizes 16, 13, 13, 8\n\nCluster means:\n      Murder Assault UrbanPop Rape\n1 -0.4894375 -0.3826001 0.5758298 -0.26165379\n2 -0.9615407 -1.1066010 -0.9301069 -0.96676331\n3 0.6950701 1.0394414 0.7226370 1.27693964\n4 1.4118898 0.8743346 -0.8145211 0.01927104\n\nVector clustering:\n       Alabama Alaska Arizona Arkansas California Colorado \n             4 3 3 4 3 3 \n   Connecticut Delaware Florida Georgia Hawaii Idaho \n             1 1 3 4 1 2 \n      Illinois Indiana Iowa Kansas Kentucky Louisiana \n             3 1 2 1 2 4 \n         Maine Maryland Massachusetts Michigan Minnesota Mississippi \n             2 3 1 3 2 4 \n      Missouri Montana Nebraska Nevada New Hampshire New Jersey \n             3 2 2 3 2 1 \n    New Mexico New York North Carolina North Dakota Ohio Oklahoma \n             3 3 4 2 1 1 \n        Oregon Pennsylvania Rhode Island South Carolina South Dakota Tennessee \n             1 1 1 4 2 4 \n         Texas Utah Vermont Virginia Washington West Virginia \n             3 1 2 1 1 2 \n     Wisconsin Wyoming \n             2 1 \n\nWithin cluster sum of squares by cluster:\n[1] 16.212213 11.952463 19.922437 8.316061\n (between_SS \/ total_SS = 71.2%)\n\nAvailable components:\n\n[1] \"cluster\" \"centers\" \"totss\" \"withinss\" \"tot.withinss\" \"betweenss\"   \n[7] \"size\" \"iter\" \"ifault\"         \n<\/strong><\/pre>\n<p><span style=\"color: #000000;\">\u7d50\u679c\u304b\u3089\u6b21\u306e\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3059\u3002<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><b>16 \u306e<\/b>\u72b6\u614b\u304c\u6700\u521d\u306e\u30af\u30e9\u30b9\u30bf\u30fc\u306b\u5272\u308a\u5f53\u3066\u3089\u308c\u307e\u3057\u305f<\/span><\/li>\n<li><span style=\"color: #000000;\"><strong>13 \u306e<\/strong>\u72b6\u614b\u304c 2 \u756a\u76ee\u306e\u30af\u30e9\u30b9\u30bf\u30fc\u306b\u5272\u308a\u5f53\u3066\u3089\u308c\u3066\u3044\u307e\u3059<\/span><\/li>\n<li><span style=\"color: #000000;\"><strong>13 \u306e<\/strong>\u5dde\u304c 3 \u756a\u76ee\u306e\u30af\u30e9\u30b9\u30bf\u30fc\u306b\u5272\u308a\u5f53\u3066\u3089\u308c\u3066\u3044\u307e\u3059<\/span><\/li>\n<li><span style=\"color: #000000;\"><b>8 \u3064\u306e<\/b>\u72b6\u614b\u304c 4 \u756a\u76ee\u306e\u30af\u30e9\u30b9\u30bf\u30fc\u306b\u5272\u308a\u5f53\u3066\u3089\u308c\u3066\u3044\u307e\u3059<\/span><\/li>\n<\/ul>\n<p><span style=\"color: #000000;\"><strong>fivz_cluster()<\/strong>\u95a2\u6570\u3092\u4f7f\u7528\u3057\u3066\u3001\u8ef8\u4e0a\u306e\u6700\u521d\u306e 2 \u3064\u306e\u4e3b\u6210\u5206\u3092\u8868\u793a\u3059\u308b\u6563\u5e03\u56f3\u3067\u30af\u30e9\u30b9\u30bf\u30fc\u3092\u8996\u899a\u5316\u3067\u304d\u307e\u3059\u3002<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#plot results of final k-means model\n<span style=\"color: #000000;\">fviz_cluster(km, data = df)\n<\/span><\/span><\/strong><\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-12313 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/kmmoyenne4.png\" alt=\"R \u306e K \u5e73\u5747\u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0 \u30d7\u30ed\u30c3\u30c8\" width=\"475\" height=\"472\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\"><strong>Aggregate()<\/strong>\u95a2\u6570\u3092\u4f7f\u7528\u3057\u3066\u3001\u5404\u30af\u30e9\u30b9\u30bf\u30fc\u5185\u306e\u5909\u6570\u306e\u5e73\u5747\u3092\u898b\u3064\u3051\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#find means of each cluster\n<span style=\"color: #000000;\">aggregate(USArrests, by= <span style=\"color: #3366ff;\">list<\/span> (cluster=km$cluster), mean)\n\ncluster Murder Assault UrbanPop Rape\n\t\t\t\t\n1 3.60000 78.53846 52.07692 12.17692\n2 10.81538 257.38462 76.00000 33.19231\n3 5.65625 138.87500 73.87500 18.78125\n4 13.93750 243.62500 53.75000 21.41250\n<\/span><\/span><\/strong><\/pre>\n<p><span style=\"color: #000000;\">\u3053\u306e\u51fa\u529b\u3092\u6b21\u306e\u3088\u3046\u306b\u89e3\u91c8\u3057\u307e\u3059\u3002<\/span><\/p>\n<ul>\n<li><span style=\"color: #000000;\">\u30b0\u30eb\u30fc\u30d7 1 \u306e\u5dde\u306e\u56fd\u6c11 10 \u4e07\u4eba\u5f53\u305f\u308a\u306e\u5e73\u5747\u6bba\u4eba\u4ef6\u6570\u306f<strong>3.6 \u4ef6<\/strong>\u3067\u3059\u3002<\/span><\/li>\n<li><span style=\"color: #000000;\">\u30b0\u30eb\u30fc\u30d7 1 \u306e\u5dde\u306e\u56fd\u6c11 10 \u4e07\u4eba\u5f53\u305f\u308a\u306e\u5e73\u5747\u66b4\u884c\u4ef6\u6570\u306f<strong>78.5 \u4ef6<\/strong>\u3067\u3059\u3002<\/span><\/li>\n<li><span style=\"color: #000000;\">\u30b0\u30eb\u30fc\u30d7 1 \u306e\u5dde\u306e\u90fd\u5e02\u90e8\u306b\u4f4f\u3093\u3067\u3044\u308b\u4f4f\u6c11\u306e\u5e73\u5747\u5272\u5408\u306f<b>52.1%<\/b>\u3067\u3059\u3002<\/span><\/li>\n<li><span style=\"color: #000000;\">\u30b0\u30eb\u30fc\u30d7 1 \u306e\u5dde\u306e\u56fd\u6c11 10 \u4e07\u4eba\u5f53\u305f\u308a\u306e\u5e73\u5747\u5f37\u59e6\u4ef6\u6570\u306f<strong>12.2 \u4ef6<\/strong>\u3067\u3059<strong>\u3002<\/strong><\/span><\/li>\n<\/ul>\n<p><span style=\"color: #000000;\">\u7b49\u3005\u3002<\/span><\/p>\n<p><span style=\"color: #000000;\">\u5404\u5dde\u306e\u30af\u30e9\u30b9\u30bf\u30fc\u5272\u308a\u5f53\u3066\u3092\u5143\u306e\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u306b\u8ffd\u52a0\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#add cluster assignment to original data\n<span style=\"color: #000000;\">final_data &lt;- cbind(USArrests, cluster = km$cluster)\n<\/span>\n#view final data\n<span style=\"color: #000000;\">head(final_data)\n\n\t<\/span><span style=\"color: #000000;\">Murder Assault UrbanPop<\/span> <span style=\"color: #000000;\">Rape<\/span> <span style=\"color: #000000;\">cluster\n\t\t\t\t\nAlabama<\/span> <span style=\"color: #000000;\">13.2<\/span> <span style=\"color: #000000;\">236 58<\/span> <span style=\"color: #000000;\">21.2<\/span> <span style=\"color: #000000;\">4\nAlaska<\/span> <span style=\"color: #000000;\">10.0 263 48<\/span> <span style=\"color: #000000;\">44.5<\/span> <span style=\"color: #000000;\">2\nArizona<\/span> <span style=\"color: #000000;\">8.1 294 80<\/span> <span style=\"color: #000000;\">31.0<\/span> <span style=\"color: #000000;\">2\nArkansas<\/span> <span style=\"color: #000000;\">8.8 190 50<\/span> <span style=\"color: #000000;\">19.5<\/span> <span style=\"color: #000000;\">4\nCalifornia<\/span> <span style=\"color: #000000;\">9.0 276 91<\/span> <span style=\"color: #000000;\">40.6<\/span> <span style=\"color: #000000;\">2\nColorado<\/span> <span style=\"color: #000000;\">7.9 204 78<\/span> <span style=\"color: #000000;\">38.7<\/span> <span style=\"color: #000000;\">2\n<\/span><\/span><\/strong><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>K-Means \u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0\u306e\u9577\u6240\u3068\u77ed\u6240<\/strong><\/span><\/h3>\n<p><span style=\"color: #000000;\">K-means \u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0\u306b\u306f\u6b21\u306e\u5229\u70b9\u304c\u3042\u308a\u307e\u3059\u3002<\/span><\/p>\n<ul>\n<li><span style=\"color: #000000;\">\u9ad8\u901f\u306a\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u3067\u3059\u3002<\/span><\/li>\n<li><span style=\"color: #000000;\">\u5927\u898f\u6a21\u306a\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u3092\u9069\u5207\u306b\u51e6\u7406\u3067\u304d\u307e\u3059\u3002<\/span><\/li>\n<\/ul>\n<p><span style=\"color: #000000;\">\u305f\u3060\u3057\u3001\u6b21\u306e\u3088\u3046\u306a\u6f5c\u5728\u7684\u306a\u6b20\u70b9\u304c\u3042\u308a\u307e\u3059\u3002<\/span><\/p>\n<ul>\n<li><span style=\"color: #000000;\">\u3053\u308c\u306b\u306f\u3001\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u3092\u5b9f\u884c\u3059\u308b\u524d\u306b\u30af\u30e9\u30b9\u30bf\u30fc\u306e\u6570\u3092\u6307\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/span><\/li>\n<li><span style=\"color: #000000;\">\u7570\u5e38\u5024\u306b\u306f\u654f\u611f\u3067\u3059\u3002<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">K \u5e73\u5747\u6cd5\u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0\u306b\u4ee3\u308f\u308b 2 \u3064\u306e\u65b9\u6cd5\u306f\u3001 <a href=\"https:\/\/statorials.org\/ja\/r-\u306e-k-medoid\/\" target=\"_blank\" rel=\"noopener noreferrer\">K \u5e73\u5747\u6cd5\u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0<\/a>\u3068\u968e\u5c64\u7684\u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0\u3067\u3059\u3002<\/span><\/p>\n<hr>\n<p><span style=\"color: #000000;\">\u3053\u306e\u4f8b\u3067\u4f7f\u7528\u3055\u308c\u3066\u3044\u308b\u5b8c\u5168\u306a R \u30b3\u30fc\u30c9\u306f\u3001 <a href=\"https:\/\/github.com\/Statorials\/R-Guides\/blob\/main\/k_means.R\" target=\"_blank\" rel=\"noopener noreferrer\">\u3053\u3053\u3067<\/a>\u898b\u3064\u3051\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0\u306f\u3001\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u5185\u306e\u89b3\u6e2c\u5024\u306e\u30b0\u30eb\u30fc\u30d7\u3092\u898b\u3064\u3051\u3088\u3046\u3068\u3059\u308b\u6a5f\u68b0\u5b66\u7fd2\u624b\u6cd5\u3067\u3059\u3002 \u76ee\u6a19\u306f\u3001\u5404\u30af\u30e9\u30b9\u30bf\u30fc\u5185\u306e\u89b3\u6e2c\u5024\u304c\u4e92\u3044\u306b\u975e\u5e38\u306b\u985e\u4f3c\u3057\u3066\u3044\u308b\u4e00\u65b9\u3067\u3001\u7570\u306a\u308b\u30af\u30e9\u30b9\u30bf\u30fc\u5185\u306e\u89b3\u6e2c\u5024\u304c\u4e92\u3044\u306b\u5927\u304d\u304f\u7570\u306a\u308b\u3088\u3046\u306a\u30af\u30e9\u30b9\u30bf\u30fc\u3092\u898b\u3064 [&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-1242","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>R \u3067\u306e K-Means \u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0: \u6bb5\u968e\u7684\u306a\u4f8b - \u7d71\u8a08\u5b66<\/title>\n<meta name=\"description\" content=\"\u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u306f\u3001R \u3067 K-means \u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0\u3092\u5b9f\u884c\u3059\u308b\u65b9\u6cd5\u306e\u6bb5\u968e\u7684\u306a\u4f8b\u3092\u793a\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\/k-\u306f-r-\u3066\u3099\u30af\u3099\u30eb\u30fc\u30d5\u309a\u5316\u3059\u308b\u3053\u3068\u3092\u610f\u5473\u3057\u307e\u3059\/\" \/>\n<meta property=\"og:locale\" content=\"ja_JP\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"R \u3067\u306e K-Means \u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0: \u6bb5\u968e\u7684\u306a\u4f8b - \u7d71\u8a08\u5b66\" \/>\n<meta property=\"og:description\" content=\"\u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u306f\u3001R \u3067 K-means \u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0\u3092\u5b9f\u884c\u3059\u308b\u65b9\u6cd5\u306e\u6bb5\u968e\u7684\u306a\u4f8b\u3092\u793a\u3057\u307e\u3059\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/ja\/k-\u306f-r-\u3066\u3099\u30af\u3099\u30eb\u30fc\u30d5\u309a\u5316\u3059\u308b\u3053\u3068\u3092\u610f\u5473\u3057\u307e\u3059\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-27T04:03:40+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/kmmoyenne1.png\" \/>\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=\"2\u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/ja\/k-%e3%81%af-r-%e3%81%a6%e3%82%99%e3%82%af%e3%82%99%e3%83%ab%e3%83%bc%e3%83%95%e3%82%9a%e5%8c%96%e3%81%99%e3%82%8b%e3%81%93%e3%81%a8%e3%82%92%e6%84%8f%e5%91%b3%e3%81%97%e3%81%be%e3%81%99\/\",\"url\":\"https:\/\/statorials.org\/ja\/k-%e3%81%af-r-%e3%81%a6%e3%82%99%e3%82%af%e3%82%99%e3%83%ab%e3%83%bc%e3%83%95%e3%82%9a%e5%8c%96%e3%81%99%e3%82%8b%e3%81%93%e3%81%a8%e3%82%92%e6%84%8f%e5%91%b3%e3%81%97%e3%81%be%e3%81%99\/\",\"name\":\"R \u3067\u306e K-Means \u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0: \u6bb5\u968e\u7684\u306a\u4f8b - \u7d71\u8a08\u5b66\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/ja\/#website\"},\"datePublished\":\"2023-07-27T04:03:40+00:00\",\"dateModified\":\"2023-07-27T04:03:40+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/ja\/#\/schema\/person\/86b92d2dd87368b26360d19d9c6a5d83\"},\"description\":\"\u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u306f\u3001R \u3067 K-means \u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0\u3092\u5b9f\u884c\u3059\u308b\u65b9\u6cd5\u306e\u6bb5\u968e\u7684\u306a\u4f8b\u3092\u793a\u3057\u307e\u3059\u3002\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/ja\/k-%e3%81%af-r-%e3%81%a6%e3%82%99%e3%82%af%e3%82%99%e3%83%ab%e3%83%bc%e3%83%95%e3%82%9a%e5%8c%96%e3%81%99%e3%82%8b%e3%81%93%e3%81%a8%e3%82%92%e6%84%8f%e5%91%b3%e3%81%97%e3%81%be%e3%81%99\/#breadcrumb\"},\"inLanguage\":\"ja\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/ja\/k-%e3%81%af-r-%e3%81%a6%e3%82%99%e3%82%af%e3%82%99%e3%83%ab%e3%83%bc%e3%83%95%e3%82%9a%e5%8c%96%e3%81%99%e3%82%8b%e3%81%93%e3%81%a8%e3%82%92%e6%84%8f%e5%91%b3%e3%81%97%e3%81%be%e3%81%99\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/ja\/k-%e3%81%af-r-%e3%81%a6%e3%82%99%e3%82%af%e3%82%99%e3%83%ab%e3%83%bc%e3%83%95%e3%82%9a%e5%8c%96%e3%81%99%e3%82%8b%e3%81%93%e3%81%a8%e3%82%92%e6%84%8f%e5%91%b3%e3%81%97%e3%81%be%e3%81%99\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u5bb6\",\"item\":\"https:\/\/statorials.org\/ja\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"R \u3067\u306e k-means \u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0: \u30b9\u30c6\u30c3\u30d7\u30d0\u30a4\u30b9\u30c6\u30c3\u30d7\u306e\u4f8b\"}]},{\"@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":"R \u3067\u306e K-Means \u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0: \u6bb5\u968e\u7684\u306a\u4f8b - \u7d71\u8a08\u5b66","description":"\u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u306f\u3001R \u3067 K-means \u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0\u3092\u5b9f\u884c\u3059\u308b\u65b9\u6cd5\u306e\u6bb5\u968e\u7684\u306a\u4f8b\u3092\u793a\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\/k-\u306f-r-\u3066\u3099\u30af\u3099\u30eb\u30fc\u30d5\u309a\u5316\u3059\u308b\u3053\u3068\u3092\u610f\u5473\u3057\u307e\u3059\/","og_locale":"ja_JP","og_type":"article","og_title":"R \u3067\u306e K-Means \u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0: \u6bb5\u968e\u7684\u306a\u4f8b - \u7d71\u8a08\u5b66","og_description":"\u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u306f\u3001R \u3067 K-means \u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0\u3092\u5b9f\u884c\u3059\u308b\u65b9\u6cd5\u306e\u6bb5\u968e\u7684\u306a\u4f8b\u3092\u793a\u3057\u307e\u3059\u3002","og_url":"https:\/\/statorials.org\/ja\/k-\u306f-r-\u3066\u3099\u30af\u3099\u30eb\u30fc\u30d5\u309a\u5316\u3059\u308b\u3053\u3068\u3092\u610f\u5473\u3057\u307e\u3059\/","og_site_name":"Statorials","article_published_time":"2023-07-27T04:03:40+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/kmmoyenne1.png"}],"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":"2\u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/ja\/k-%e3%81%af-r-%e3%81%a6%e3%82%99%e3%82%af%e3%82%99%e3%83%ab%e3%83%bc%e3%83%95%e3%82%9a%e5%8c%96%e3%81%99%e3%82%8b%e3%81%93%e3%81%a8%e3%82%92%e6%84%8f%e5%91%b3%e3%81%97%e3%81%be%e3%81%99\/","url":"https:\/\/statorials.org\/ja\/k-%e3%81%af-r-%e3%81%a6%e3%82%99%e3%82%af%e3%82%99%e3%83%ab%e3%83%bc%e3%83%95%e3%82%9a%e5%8c%96%e3%81%99%e3%82%8b%e3%81%93%e3%81%a8%e3%82%92%e6%84%8f%e5%91%b3%e3%81%97%e3%81%be%e3%81%99\/","name":"R \u3067\u306e K-Means \u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0: \u6bb5\u968e\u7684\u306a\u4f8b - \u7d71\u8a08\u5b66","isPartOf":{"@id":"https:\/\/statorials.org\/ja\/#website"},"datePublished":"2023-07-27T04:03:40+00:00","dateModified":"2023-07-27T04:03:40+00:00","author":{"@id":"https:\/\/statorials.org\/ja\/#\/schema\/person\/86b92d2dd87368b26360d19d9c6a5d83"},"description":"\u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u306f\u3001R \u3067 K-means \u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0\u3092\u5b9f\u884c\u3059\u308b\u65b9\u6cd5\u306e\u6bb5\u968e\u7684\u306a\u4f8b\u3092\u793a\u3057\u307e\u3059\u3002","breadcrumb":{"@id":"https:\/\/statorials.org\/ja\/k-%e3%81%af-r-%e3%81%a6%e3%82%99%e3%82%af%e3%82%99%e3%83%ab%e3%83%bc%e3%83%95%e3%82%9a%e5%8c%96%e3%81%99%e3%82%8b%e3%81%93%e3%81%a8%e3%82%92%e6%84%8f%e5%91%b3%e3%81%97%e3%81%be%e3%81%99\/#breadcrumb"},"inLanguage":"ja","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/ja\/k-%e3%81%af-r-%e3%81%a6%e3%82%99%e3%82%af%e3%82%99%e3%83%ab%e3%83%bc%e3%83%95%e3%82%9a%e5%8c%96%e3%81%99%e3%82%8b%e3%81%93%e3%81%a8%e3%82%92%e6%84%8f%e5%91%b3%e3%81%97%e3%81%be%e3%81%99\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/ja\/k-%e3%81%af-r-%e3%81%a6%e3%82%99%e3%82%af%e3%82%99%e3%83%ab%e3%83%bc%e3%83%95%e3%82%9a%e5%8c%96%e3%81%99%e3%82%8b%e3%81%93%e3%81%a8%e3%82%92%e6%84%8f%e5%91%b3%e3%81%97%e3%81%be%e3%81%99\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u5bb6","item":"https:\/\/statorials.org\/ja\/"},{"@type":"ListItem","position":2,"name":"R \u3067\u306e k-means \u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0: \u30b9\u30c6\u30c3\u30d7\u30d0\u30a4\u30b9\u30c6\u30c3\u30d7\u306e\u4f8b"}]},{"@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\/1242","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=1242"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/ja\/wp-json\/wp\/v2\/posts\/1242\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/ja\/wp-json\/wp\/v2\/media?parent=1242"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/ja\/wp-json\/wp\/v2\/categories?post=1242"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/ja\/wp-json\/wp\/v2\/tags?post=1242"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}