{"id":680,"date":"2016-11-12T05:09:36","date_gmt":"2016-11-11T20:09:36","guid":{"rendered":"https:\/\/www.dogrow.net\/python\/?p=680"},"modified":"2019-10-19T11:49:23","modified_gmt":"2019-10-19T02:49:23","slug":"blog80","status":"publish","type":"post","link":"https:\/\/www.dogrow.net\/python\/blog80\/","title":{"rendered":"(80) \u91ce\u7403\u9078\u624b\u3092\u6e2c\u3063\u3066\u307f\u308b 2016\u5e74\u7248"},"content":{"rendered":"<p>\u59c9\u59b9\u30b5\u30a4\u30c8 <a href=\"https:\/\/www.dogrow.net\/octave\/\" target=\"_blank\" rel=\"noopener noreferrer\">Octave\u3084\u3063\u3066\u307f\u308b\uff01<\/a> \u30672014\u5e74\u306b\u904a\u3093\u3067\u307f\u305f <a href=\"https:\/\/www.dogrow.net\/octave\/blog32\/\" target=_blank rel=\"noopener noreferrer\">(32) \u91ce\u7403\u9078\u624b\u306e\u6210\u7e3e\u3092\u4e3b\u6210\u5206\u5206\u6790<\/a> \u3068\u540c\u3058\u3053\u3068\u3092 Python\u3067\u3082\u3084\u3063\u3066\u307f\u308b\u3002<\/p>\n<p>\u5bfe\u8c61\u30c7\u30fc\u30bf\u306f 2016\u5e74\u306e\u30d7\u30ed\u91ce\u7403\u30bb\u30d1\u4e21\u30ea\u30fc\u30b0\u306e\u30ec\u30ae\u30e5\u30e9\u30fc\u30af\u30e9\u30b9 55\u4eba\u306e\u6253\u8005\u6210\u7e3e\u3068\u3059\u308b\u3002<br \/>\n<a href=\"http:\/\/baseball.yahoo.co.jp\/npb\/stats\/batter?series=1\" target=_blank rel=\"noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/www.dogrow.net\/python\/wp-content\/uploads\/2016\/11\/Image3.gif\" style=\"border:1px #888 solid;\" \/><\/a><br \/>\n\u30c7\u30fc\u30bf\u306fYahoo!\u3055\u3093\u306e\u30b5\u30a4\u30c8(\u2191)\u304b\u3089\u304a\u501f\u308a\u3057\u307e\u3057\u305f\u3002m(_ _)m<\/p>\n<h1 class=\"my_h\">1. \u30c6\u30fc\u30de\u306f\u91ce\u7403\u9078\u624b\u306e\u7dcf\u5408\u8a55\u4fa1<\/h1>\n<p>\u500b\u4eba\u7684\u306b\u306f\u3001\u4f55\u3067\u3082\u305d\u3064\u306a\u304f\u3053\u306a\u3059\u9078\u624b\u304c\u597d\u304d\u3067\u3059\u3002<br \/>\n<a href=\"https:\/\/ja.wikipedia.org\/wiki\/%E7%B0%91%E7%94%B0%E6%B5%A9%E4%BA%8C\" target=_blank rel=\"noopener noreferrer\">\u84d1\u7530\u9078\u624b\uff08\u962a\u6025\uff09<\/a><br \/>\n<a href=\"https:\/\/ja.wikipedia.org\/wiki\/%E6%9D%BE%E6%B0%B8%E6%B5%A9%E7%BE%8E\" target=_blank rel=\"noopener noreferrer\">\u677e\u6c38\u9078\u624b\uff08\u962a\u6025\uff09<\/a><br \/>\n<a href=\"https:\/\/ja.wikipedia.org\/wiki\/%E5%89%8D%E7%94%B0%E6%99%BA%E5%BE%B3\" target=_blank rel=\"noopener noreferrer\">\u524d\u7530\u9078\u624b\uff08\u5e83\u5cf6\uff09<\/a><br \/>\n\u306a\u3069\u306a\u3069\u3001\u672c\u5841\u6253\u3001\u6253\u70b9\u3001\u6253\u7387\u306a\u3069\u306e\u5358\u4e00\u9805\u76ee\u3067\u306e\u8a55\u4fa1\u3067\u306f\u306a\u304f\u3001<br \/>\n<span class=\"my_fc_deeppinkBBig\">\u30bf\u30a4\u30c8\u30eb\u30db\u30eb\u30c0\u30fc\u3058\u3083\u306a\u3044\u3051\u3069\u30b9\u30b4\u30a4\u9078\u624b\uff01<\/span><br \/>\n\u306e\u5ea6\u5408\u304c\u8a08\u6e2c\u3067\u304d\u308b\u3001\u305d\u3093\u306a\u7269\u5dee\u3057\u3092\u898b\u3064\u3051\u3066\u304f\u308c\u308b\u3053\u3068\u3092\u697d\u3057\u307f\u306b\u3084\u3063\u3066\u307f\u307e\u3059\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.dogrow.net\/python\/wp-content\/uploads\/2016\/11\/illust1.png\" style=\"background-color:transparent;width:10rem;\"><\/p>\n<h1 class=\"my_h\">2. \u8a08\u7b97\u624b\u9806<\/h1>\n<p>\u4e3b\u6210\u5206\u5206\u6790\u306e\u5bfe\u8c61\u3068\u3059\u308b\u5909\u91cf\uff08\u6253\u8005\u6210\u7e3e\u9805\u76ee\uff09\u306f\u3001\u4ee5\u4e0b\u306e9\u9805\u76ee\u3068\u3059\u308b\u3002<br \/>\n\u6253\u5e2d\u6570\u3001\u5b89\u6253\u3001\u672c\u5841\u6253\u3001\u5841\u6253\u6570\u3001\u6253\u70b9\u3001\u5f97\u70b9\u3001\u4e09\u632f\u3001\u56db\u7403\u3001\u76d7\u5841<\/p>\n<p>\u524d\u8ff0\u306e\u6253\u8005\u6210\u7e3e\u3092CSV\u30d5\u30a1\u30a4\u30eb\u306b\u4fdd\u5b58\u3057\u3066\u304a\u304d\u3001\u3053\u308c\u3092Python\u3067\u30ed\u30fc\u30c9\u3059\u308b\u3002<br \/>\n<span class=\"my_fc_crimsonB\">\u203b\u4eca\u56de\u306fscikit-learn\u3092\u4f7f\u308f\u305a\u306bPCA\u3057\u3066\u307f\u308b\u3002<\/span><\/p>\n<pre>\r\n&gt;&gt;&gt; import numpy as np\r\n&gt;&gt;&gt; X = np.loadtxt('in_data.csv', delimiter=',')\r\n&gt;&gt;&gt; X\r\narray([[ 576.,  168.,   23.,  271.,   75.,   96.,   67.,   81.,   13.],\r\n       [ 528.,  156.,   29.,  285.,   95.,   76.,   79.,   53.,   16.],\r\n       [ 561.,  151.,   44.,  319.,  110.,   89.,  105.,   87.,    0.],\r\n       [ 640.,  181.,   13.,  248.,   56.,   92.,  106.,   40.,   13.],\r\n       [ 523.,  141.,   11.,  205.,   59.,   52.,   78.,   61.,    0.],\r\n       [ 590.,  146.,   38.,  292.,  102.,  102.,  101.,   97.,   30.],\r\n       [ 576.,  160.,   25.,  267.,   81.,   58.,   83.,   38.,    1.],\r\n       [ 458.,  127.,    1.,  154.,   32.,   48.,   31.,   34.,    3.],\r\n       [ 513.,  136.,   19.,  220.,  101.,   66.,  101.,   54.,    0.],\r\n       [ 607.,  155.,    0.,  179.,   39.,   74.,   66.,   63.,    7.],\r\n       [ 566.,  157.,    1.,  183.,   38.,   38.,   98.,   22.,    2.],\r\n       [ 656.,  175.,    3.,  229.,   27.,   80.,   69.,   46.,   26.],\r\n       [ 652.,  162.,   20.,  268.,   90.,   98.,  107.,   84.,   23.],\r\n       [ 522.,  131.,   11.,  191.,   49.,   80.,   93.,   38.,   19.],\r\n       [ 618.,  163.,   11.,  232.,   42.,   58.,   78.,   33.,    8.],\r\n       [ 530.,  136.,    8.,  193.,   65.,   48.,  109.,   27.,    5.],\r\n       [ 471.,  114.,   22.,  202.,   68.,   63.,   68.,   44.,    1.],\r\n       [ 450.,  108.,   18.,  190.,   56.,   69.,  110.,   49.,   26.],\r\n       [ 537.,  123.,   31.,  236.,   96.,   64.,  116.,   72.,    0.],\r\n       [ 679.,  154.,   13.,  216.,   39.,  102.,  119.,   77.,   28.],\r\n       [ 518.,  127.,   34.,  258.,   95.,   66.,   75.,   24.,    0.],\r\n       [ 465.,  109.,   24.,  205.,   68.,   48.,  106.,   39.,    0.],\r\n       [ 554.,  127.,   22.,  213.,   79.,   58.,  130.,   48.,    2.],\r\n       [ 507.,  116.,    6.,  165.,   46.,   38.,   69.,   27.,    1.],\r\n       [ 494.,  103.,   14.,  171.,   73.,   61.,   89.,   72.,    4.],\r\n       [ 533.,  106.,    7.,  145.,   36.,   49.,   80.,   75.,   13.],\r\n       [ 458.,   81.,    4.,  107.,   35.,   27.,   76.,   36.,    2.],\r\n       [ 607.,  178.,    8.,  242.,   69.,   74.,   64.,   68.,   12.],\r\n       [ 593.,  155.,    5.,  196.,   43.,   76.,  113.,   73.,   41.],\r\n       [ 611.,  172.,   24.,  284.,   82.,   73.,  108.,   38.,    8.],\r\n       [ 616.,  163.,   17.,  240.,   70.,   79.,   84.,   75.,   53.],\r\n       [ 536.,  131.,   18.,  224.,   73.,   82.,   97.,  100.,   23.],\r\n       [ 605.,  169.,   18.,  242.,  106.,   62.,   53.,   38.,    3.],\r\n       [ 671.,  171.,   11.,  244.,   62.,   98.,  103.,   77.,   18.],\r\n       [ 555.,  145.,   14.,  213.,   61.,   66.,  121.,   42.,    5.],\r\n       [ 612.,  140.,    7.,  184.,   50.,   69.,   53.,   99.,    6.],\r\n       [ 583.,  143.,    6.,  195.,   61.,   62.,   56.,   50.,    3.],\r\n       [ 513.,  129.,   20.,  214.,   76.,   56.,  105.,   47.,    5.],\r\n       [ 570.,  139.,   24.,  238.,   92.,   81.,   89.,   64.,    0.],\r\n       [ 569.,  133.,    3.,  176.,   41.,   52.,   87.,   83.,    0.],\r\n       [ 481.,  118.,    7.,  173.,   40.,   56.,   95.,   30.,   11.],\r\n       [ 497.,  116.,    2.,  141.,   43.,   39.,   49.,   61.,    1.],\r\n       [ 488.,  110.,    1.,  130.,   34.,   51.,   53.,   42.,    6.],\r\n       [ 626.,  147.,    2.,  169.,   53.,   61.,   56.,   69.,   22.],\r\n       [ 520.,  122.,    1.,  143.,   33.,   64.,   69.,   40.,   53.],\r\n       [ 589.,  137.,   27.,  247.,   88.,   74.,  123.,   58.,    2.],\r\n       [ 449.,  108.,    0.,  131.,   46.,   27.,   44.,   19.,    1.],\r\n       [ 610.,  142.,    2.,  178.,   33.,   63.,   55.,   56.,   16.],\r\n       [ 598.,  144.,   39.,  282.,   97.,   71.,  138.,   44.,    0.],\r\n       [ 609.,  142.,   27.,  256.,   85.,   79.,  141.,   48.,    6.],\r\n       [ 583.,  129.,   35.,  260.,  103.,   73.,  148.,   59.,    1.],\r\n       [ 485.,  106.,    6.,  145.,   35.,   44.,   49.,   46.,    7.],\r\n       [ 624.,  142.,   25.,  245.,  110.,   61.,  126.,   47.,    2.],\r\n       [ 590.,  122.,   10.,  184.,   56.,   74.,   86.,   47.,    8.],\r\n       [ 600.,  115.,    0.,  127.,   28.,   66.,  117.,   63.,   23.]])\r\n<\/pre>\n<p>\u6253\u8005\u9805\u76ee\u306b\u3088\u3063\u3066\u6570\u5024\u306e\u7bc4\u56f2\u306b\u3070\u3089\u3064\u304d\u304c\u3042\u308b\u305f\u3081\u3001\u5e73\u57470\u3001\u5206\u65631\u306b\u6a19\u6e96\u5316\u3057\u3066\u304a\u304f\u3002<br \/>\n<span class=\"my_fc_gray\">\u3067\u3082\u3001\u9805\u76ee\u306b\u3088\u3063\u3066\u4fa1\u5024\u304c\u3060\u3044\u3076\u9055\u3046\u3082\u306e\u3082\u3042\u308b\u306e\u3067\u3001\u9805\u76ee\u5225\u306e\u30ec\u30f3\u30b8\u8abf\u6574\u304c\u5fc5\u8981\u304b\u3082\u2026<\/span><\/p>\n<pre>\r\n&gt;&gt;&gt; Xm = np.broadcast_to(X.mean(axis=0), X.shape)\r\n&gt;&gt;&gt; Xs = np.broadcast_to(X.std(axis=0),  X.shape)\r\n&gt;&gt;&gt; Xv = (X - Xm) \/ Xs\r\n<\/pre>\n<p>\u56fa\u6709\u30d9\u30af\u30c8\u30eb(v), \u56fa\u6709\u5024(l)\u3092\u6c42\u3081\u308b\u3002<\/p>\n<pre>\r\n&gt;&gt;&gt; R1  = np.corrcoef(Xv.T)\r\n&gt;&gt;&gt; l,v = np.linalg.eigh(R1)\r\n<\/pre>\n<p>\u30e9\u30f3\u30af\u304c\u898b\u3084\u3059\u3044\u3088\u3046\u306b\u5bc4\u4e0e\u7387\u3092\u7b97\u51fa\u3059\u308b\u3002<\/p>\n<pre>\r\n&gt;&gt;&gt; l \/ l.sum() * 100\r\narray([  0.08933219,   1.01050674,   1.50297613,   2.19603783,\r\n         6.06787656,   8.22801916,  11.12005857,  23.43222355,  46.35296927])\r\n<\/pre>\n<p>\u5bc4\u4e0e\u7387\u304c\u5927\u304d\u3044\u3082\u306e\u306f\u3001<br \/>\n\u7b2c1\u4e3b\u6210\u5206 (8) 46.4%<br \/>\n\u7b2c2\u4e3b\u6210\u5206 (7) 23.4%<br \/>\n\u7b2c3\u4e3b\u6210\u5206 (6) 11.1%<br \/>\n\u3053\u3053\u307e\u3067\u3067 80.9% <\/p>\n<p>\u9078\u3093\u30603\u7a2e\u985e\u306e\u4e3b\u6210\u5206\u30b9\u30b3\u30a2\u3092\u7b97\u51fa\u3059\u308b\u3002<\/p>\n<pre>\r\n&gt;&gt;&gt; scr_8  = Xv * np.broadcast_to(v[::,8:9].T, X.shape)\r\n&gt;&gt;&gt; scr_7  = Xv * np.broadcast_to(v[::,7:8].T, X.shape)\r\n&gt;&gt;&gt; scr_6  = Xv * np.broadcast_to(v[::,6:7].T, X.shape)\r\n<\/pre>\n<h1 class=\"my_h\">3. \u7d50\u679c\u3092\u898b\u3066\u307f\u308b\u3002<\/h1>\n<p>\u7b2c1\u4e3b\u6210\u5206\u304b\u3089\u7b2c3\u4e3b\u6210\u5206\u307e\u3067\u3001\u4f5c\u3063\u3066\u304f\u308c\u305f\u7269\u5dee\u3057\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u3082\u306e\u3002<br \/>\n<span class=\"my_fc_crimsonB\">\u203b\u76f4\u89b3\u7684\u306b\u91ce\u7403\u6210\u7e3e\u3068\u6bd4\u8f03\u3057\u3084\u3059\u3044\u3088\u3046\u306b\u6b63\u8ca0\u306e\u5411\u304d\u3092\u9006\u306b\u3057\u305f\u3002<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.dogrow.net\/python\/wp-content\/uploads\/2016\/11\/Image5.gif\" \/><\/p>\n<h3 class=\"my_h\">\u7b2c1\u4e3b\u6210\u5206 (46.4%)<\/h3>\n<p>\u30b1\u30ac\u306a\u304f\u51fa\u5834\u3057\u3001\u5b89\u6253\u6253\u3061\u307e\u304f\u308a\u3001\u30c7\u30ab\u3044\u306e\u3082\u6253\u3066\u3001\u3088\u304f\u672c\u5841\u306b\u5e30\u3063\u3066\u304f\u308b\u3002<br \/>\n\u3044\u308f\u3086\u308b\u30aa\u30fc\u30eb\u30de\u30a4\u30c6\u30a3\u306a\u9078\u624b<br \/>\n<span class=\"my_fc_deeppinkB\">\u2193\u3092\u898b\u308b\u3068\u3001\u78ba\u304b\u306b\u8ab0\u3082\u304c\u30b9\u30b4\u30a4\u3068\u7d0d\u5f97\u3059\u308b\u9078\u624b\u304c\u4e0a\u4f4d\u306b\u4e26\u3093\u3067\u3044\u308b\u3002<\/span><\/p>\n<h3 class=\"my_h\">\u7b2c2\u4e3b\u6210\u5206 (23.4%)<\/h3>\n<p>\u51fa\u5834\u6a5f\u4f1a\u306f\u5c11\u306a\u3044\u304c\u3001\u672c\u5841\u6253\u3092\u3088\u304f\u6253\u3061\u6253\u70b9\u3092\u7a3c\u3050\u3002\u3067\u3082\u65e9\u6253\u3061\uff06\u9078\u7403\u773c\u30a4\u30de\u30a4\u30c1\u3067\u920d\u8db3\u3002<br \/>\n\u3044\u308f\u3086\u308b\u5f53\u305f\u308c\u3070\u98db\u3076\u4e00\u767a\u5c4b\u30bf\u30a4\u30d7<br \/>\n<span class=\"my_fc_deeppinkB\">\u2193\u3092\u898b\u308b\u3068\u3001\u78ba\u304b\u306b\u4e00\u767a\u5c4b\u306e\u52a9\u3063\u4eba\u5916\u56fd\u4eba\u9078\u624b\u304c\u4e0a\u4f4d\u306b\u4e26\u3093\u3067\u3044\u308b\u3002<\/span><\/p>\n<h3 class=\"my_h\">\u7b2c3\u4e3b\u6210\u5206 (11.1%)<\/h3>\n<p>\u975e\u529b\u3067\u3042\u307e\u308a\u30d2\u30c3\u30c8\u3092\u6253\u305f\u306a\u3044\u304c\u3001\u3088\u304f\u56db\u7403\u3092\u9078\u3093\u3067\u51fa\u5841\u3057\u3001\u76d7\u5841\u3067\u76f8\u624b\u5b88\u5099\u3092\u304b\u304d\u4e71\u3059\u3002<br \/>\n\u3044\u308f\u3086\u308b\uff1f\uff1f\uff1f<br \/>\n<span class=\"my_fc_crimsonB\">\u96e3\u3057\u3044\u306a\u3041\u3001\u30ea\u30fc\u30c9\u30aa\u30d5\u30de\u30f3\u30bf\u30a4\u30d7\u3067\u3082\u306a\u3044\u3057\u306a\u3041\u3001\u5de8\u4eba\u9234\u6728\u9078\u624b\u30bf\u30a4\u30d7\u304b\uff1f<br \/>\n\u5bc4\u4e0e\u738711%\u3060\u304b\u3089\u3053\u3093\u306a\u3082\u3093\u304b&#8230;<\/span><\/p>\n<p>\u516855\u4eba\u3092\u5404\u7269\u5dee\u3057\u3067\u6e2c\u3063\u305f\u7d50\u679c\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.dogrow.net\/python\/wp-content\/uploads\/2016\/11\/Image7.gif\" style=\"width:100%;\" \/><\/p>\n<h1 class=\"my_h\">x. \u5099\u5fd8\u9332<\/h2>\n<p>\u30ea\u30fc\u30c9\u30aa\u30d5\u30de\u30f3\u7269\u5dee\u3057\u304c\u51fa\u6765\u306a\u304b\u3063\u305f\u306e\u304c\u6b8b\u5ff5\u3060\u3002<br \/>\n\u5909\u91cf\u306b\u30ea\u30fc\u30c9\u30aa\u30d5\u30de\u30f3\u306e\u7279\u5fb4\u3092\u8868\u3059\u3088\u3046\u306a\u9805\u76ee\u3092\u8ffd\u52a0\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u305d\u3046\u3060\u3002<\/p>\n<hr class=\"my_hr_bottom\">\n","protected":false},"excerpt":{"rendered":"<p>\u59c9\u59b9\u30b5\u30a4\u30c8 Octave\u3084\u3063\u3066\u307f\u308b\uff01 \u30672014\u5e74\u306b\u904a\u3093\u3067\u307f\u305f (32) \u91ce\u7403\u9078\u624b\u306e\u6210\u7e3e\u3092\u4e3b\u6210\u5206\u5206\u6790 \u3068\u540c\u3058\u3053\u3068\u3092 Python\u3067\u3082\u3084\u3063\u3066\u307f\u308b\u3002 \u5bfe\u8c61\u30c7\u30fc\u30bf\u306f 2016\u5e74\u306e\u30d7\u30ed\u91ce\u7403\u30bb\u30d1\u4e21\u30ea\u30fc\u30b0\u306e\u30ec\u30ae\u30e5\u30e9\u30fc\u30af\u30e9\u30b9 55\u4eba\u306e\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.dogrow.net\/python\/blog80\/\">\u7d9a\u304d\u3092\u8aad\u3080 &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29],"tags":[],"class_list":["post-680","post","type-post","status-publish","format-standard","hentry","category-29"],"views":3567,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/posts\/680","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/comments?post=680"}],"version-history":[{"count":55,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/posts\/680\/revisions"}],"predecessor-version":[{"id":2715,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/posts\/680\/revisions\/2715"}],"wp:attachment":[{"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/media?parent=680"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/categories?post=680"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/tags?post=680"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}