{"id":753,"date":"2016-11-12T14:23:41","date_gmt":"2016-11-12T05:23:41","guid":{"rendered":"https:\/\/www.dogrow.net\/python\/?p=753"},"modified":"2019-10-19T11:58:22","modified_gmt":"2019-10-19T02:58:22","slug":"blog82","status":"publish","type":"post","link":"https:\/\/www.dogrow.net\/python\/blog82\/","title":{"rendered":"(82) \u91ce\u7403\u9078\u624b\u306e\u6210\u7e3e\u3092\u4e3b\u6210\u5206\u5206\u6790 (\u7d9a\u7de82\/2)"},"content":{"rendered":"<p><a href=\"https:\/\/www.dogrow.net\/python\/blog81\/\" target=_blank rel=\"noopener noreferrer\">(81) \u91ce\u7403\u9078\u624b\u306e\u6210\u7e3e\u3092\u4e3b\u6210\u5206\u5206\u6790 (\u7d9a\u7de81\/2)<\/a> \u3067\u4f5c\u3063\u305f\u30c7\u30fc\u30bf\u3092\u4f7f\u3063\u3066\u3001<br \/>\n<a href=\"https:\/\/www.dogrow.net\/python\/blog80\/\" target=_blank rel=\"noopener noreferrer\">(80) \u91ce\u7403\u9078\u624b\u3092\u6e2c\u3063\u3066\u307f\u308b 2016\u5e74\u7248<\/a> \u3068\u540c\u3058\u89e3\u6790\u3092\u3084\u3063\u3066\u307f\u308b\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.dogrow.net\/python\/wp-content\/uploads\/2016\/11\/illust1.png\" \/><br \/>\n<span class=\"my_fc_deeppinkBBig\">\u76ee\u7684\u306f\u30aa\u30ea\u30b8\u30ca\u30eb\u306e\u7269\u5dee\u3057\u3092\u4f5c\u308b\u3053\u3068\u3002<\/span><\/p>\n<h1 class=\"my_h\">1. \u8907\u6570\u5e74\u5ea6\u00d7\u8907\u6570\u30ea\u30fc\u30b0\u306e\u30c7\u30fc\u30bf\u3092\u76f4\u5217\u306b\u7e4b\u3050<\/h1>\n<p>\u300c<a href=\"https:\/\/www.dogrow.net\/python\/?p=730\" target=_blank rel=\"noopener noreferrer\">(81) \u91ce\u7403\u9078\u624b\u306e\u6210\u7e3e\u3092\u4e3b\u6210\u5206\u5206\u6790 (\u7d9a\u7de81\/2)<\/a>\u300d\u3067\u4f5c\u3063\u305f\u30c7\u30fc\u30bf\u3092\u76f4\u5217\u306b\u7e4b\u304e\u3001\u4e00\u3064\u306e\u5165\u529b\u30c7\u30fc\u30bf\u306b\u3059\u308b\u3002\u305d\u306e\u969b\u306b\u3001\u5404\u884c(\uff1d\u5404\u9078\u624b)\u306e\u5148\u982d\u5217\u306b\u5e74\u5ea6\u5024\u3092\u57cb\u3081\u8fbc\u3093\u3067\u304a\u304f\u3002\u5f8c\u3067\u300c\u25cb\u25cb\u25cb\u25cb\u5e74\u306e\u548c\u7530\u306f\u3059\u3054\u304b\u3063\u305f\uff01\u300d\u307f\u305f\u3044\u306a\u559c\u3073\u65b9\u3092\u3057\u305f\u3044\u304b\u3089\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nimport csv\r\ndef load_data(basepath):\r\n    files = glob.glob( basepath + '\/*.csv')\r\n    ary=&#x5B;]\r\n    for fpath in files:\r\n        year = fpath.split('\/')&#x5B;-1].split('_')&#x5B;0]\r\n        f = open(fpath, 'r')\r\n        dr = csv.reader(f)\r\n        for row in dr:\r\n            row.insert(0, year)\r\n            ary.append(row)\r\n    return np.array(ary)\r\n<\/pre>\n<h1 class=\"my_h\">2. 12\u5e74\u9593\u3067\u5ef6\u3079701\u4eba\u5206\u306e\u6253\u6483\u7d50\u679c\u3092\u89e3\u6790<\/h1>\n<p>12\u5e74\u9593\u9023\u7d9a\u3067\u898f\u5b9a\u6253\u5e2d\u306b\u5230\u9054\u3057\u3066\u3044\u308b\u4eba\u306f1\u4eba\u306712\u4eba\u5206\u30ab\u30a6\u30f3\u30c8\u3055\u308c\u308b\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\ndef calc_pca(X):\r\n    Xm = np.broadcast_to(X.mean(axis=0), X.shape)\r\n    Xs = np.broadcast_to(X.std(axis=0),  X.shape)\r\n    Xv = (X - Xm) \/ Xs\r\n    R1  = np.corrcoef(Xv.T)\r\n    l,v = np.linalg.eigh(R1)\r\n    r = l \/ l.sum()\r\n    return v,r,Xv\r\n\r\ndef ctrl_proc():\r\n    basepath = '..\/0081\/data'\r\n    ary_joined = load_data(basepath)\r\n    # \u4e0d\u8981\u9805\u76ee\u3092\u524a\u9664\r\n    in_data = ary_joined&#x5B;0::,6:24]\r\n    # PCA\r\n    X = in_data.astype(np.float64)\r\n    v,r,Xv = calc_pca(X)\r\n    return ary_joined,v,r,X,Xv\r\n<\/pre>\n<h1 class=\"my_h\">3. \u7d50\u679c\u306f\uff1f<\/h1>\n<p>\u300c<a href=\"https:\/\/www.dogrow.net\/python\/?p=680\" target=_blank rel=\"noopener noreferrer\">(80) \u91ce\u7403\u9078\u624b\u3092\u6e2c\u3063\u3066\u307f\u308b 2016\u5e74\u7248<\/a>\u300d\u3068\u540c\u3058\u3088\u3046\u306a\u7269\u5dee\u3057\u304c\u3067\u304d\u305f&#8230;<br \/>\n<span class=\"my_fc_gray\">\u3042\u3093\u307e\u308a\u304a\u3082\u3057\u308d\u304f\u306a\u3044\u306a\u3041<\/span><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.dogrow.net\/python\/wp-content\/uploads\/2016\/11\/Image2.gif\" \/><\/p>\n<h3 class=\"my_h\">\u7b2c1\u4e3b\u6210\u5206<\/h3>\n<p>\u3088\u304f\u8a66\u5408\u306b\u51fa\u5834\u3057\u3001\u3088\u304f\u30d2\u30c3\u30c8\u3092\u6253\u3061\u3001\u3088\u304f\u30db\u30fc\u30e0\u306b\u5e30\u308a\u3001\u9577\u6253\u3082\u591a\u304f\u3001\u6253\u70b9\u3082\u7a3c\u3050\u3001<span class=mydp>\u30b9\u30fc\u30d1\u30fc\u30b9\u30bf\u30fc\u3092\u898b\u3064\u3051\u51fa\u3059\u7269\u5dee\u3057\uff01<\/span><\/p>\n<h3 class=\"my_h\">\u7b2c2\u4e3b\u6210\u5206<\/h3>\n<p>\u3088\u304f\u6b20\u5834\u3059\u308b\u3057\u3001\u3042\u3093\u307e\u308a\u30d2\u30c3\u30c8\u6253\u305f\u306a\u3044\u3057\u3001\u8db3\u9045\u304f\u3066\u4f75\u6bba\u591a\u3044\u3057\u3001\u3067\u3082\u3068\u304d\u3069\u304d\u4e00\u6483\u3092\u304f\u3089\u308f\u3059\u30d1\u30ef\u30fc\u3092\u6301\u3064\u3001<span class=myr>\u3061\u3087\u3063\u3068\u30d3\u30df\u30e7\u30fc\u306a\u6e96\uff11\u6d41\u9078\u624b\u3092\u898b\u3064\u3051\u51fa\u3059\u7269\u5dee\u3057<\/span><\/p>\n<p>12\u5e74\u9593\u5ef6\u3079701\u4eba\u306e\u9078\u624b\u3092\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\/Image4.gif\" \/><\/p>\n<hr class=\"my_hr_bottom\">\n","protected":false},"excerpt":{"rendered":"<p>(81) \u91ce\u7403\u9078\u624b\u306e\u6210\u7e3e\u3092\u4e3b\u6210\u5206\u5206\u6790 (\u7d9a\u7de81\/2) \u3067\u4f5c\u3063\u305f\u30c7\u30fc\u30bf\u3092\u4f7f\u3063\u3066\u3001 (80) \u91ce\u7403\u9078\u624b\u3092\u6e2c\u3063\u3066\u307f\u308b 2016\u5e74\u7248 \u3068\u540c\u3058\u89e3\u6790\u3092\u3084\u3063\u3066\u307f\u308b\u3002 \u76ee\u7684\u306f\u30aa\u30ea\u30b8\u30ca\u30eb\u306e\u7269\u5dee\u3057\u3092\u4f5c\u308b\u3053\u3068\u3002 1. \u8907\u6570\u5e74\u5ea6\u00d7\u8907\u6570\u30ea\u30fc\u30b0\u306e\u30c7\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.dogrow.net\/python\/blog82\/\">\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":[26,29],"tags":[],"class_list":["post-753","post","type-post","status-publish","format-standard","hentry","category-web","category-29"],"views":3350,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/posts\/753","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=753"}],"version-history":[{"count":30,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/posts\/753\/revisions"}],"predecessor-version":[{"id":2723,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/posts\/753\/revisions\/2723"}],"wp:attachment":[{"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/media?parent=753"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/categories?post=753"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/tags?post=753"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}