{"id":533,"date":"2018-05-24T00:56:41","date_gmt":"2018-05-23T15:56:41","guid":{"rendered":"http:\/\/www.typea.info\/blog\/index.php\/2018\/05\/24\/python_6\/"},"modified":"2018-05-24T00:56:41","modified_gmt":"2018-05-23T15:56:41","slug":"python_6","status":"publish","type":"post","link":"https:\/\/www.typea.info\/blog\/index.php\/2018\/05\/24\/python_6\/","title":{"rendered":"Python \u6570\u5b66\u3001\u7d71\u8a08\u3001\u6a5f\u68b0\u5b66\u7fd2\uff1a\u57fa\u672c\u7d71\u8a08\u91cf\u3001\u5206\u6563\u3068\u6a19\u6e96\u504f\u5dee"},"content":{"rendered":"<p><a href=\"https:\/\/www.amazon.co.jp\/Think-Stats-%E2%80%95%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9E%E3%81%AE%E3%81%9F%E3%82%81%E3%81%AE%E7%B5%B1%E8%A8%88%E5%85%A5%E9%96%80-Allen-Downey\/dp\/4873117356\/ref=as_li_ss_il?ie=UTF8&amp;qid=1527090494&amp;sr=8-2&amp;keywords=think+stats+%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9E%E3%81%AE%E3%81%9F%E3%82%81%E3%81%AE%E7%B5%B1%E8%A8%88%E5%85%A5%E9%96%80&amp;linkCode=li2&amp;tag=typea09-22&amp;linkId=4701865ae6ba66d4ac374b97a41efa06\" target=\"_blank\"><img decoding=\"async\" src=\"\/\/ws-fe.amazon-adsystem.com\/widgets\/q?_encoding=UTF8&amp;ASIN=4873117356&amp;Format=_SL160_&amp;ID=AsinImage&amp;MarketPlace=JP&amp;ServiceVersion=20070822&amp;WS=1&amp;tag=typea09-22\" border=\"0\"><\/a><img loading=\"lazy\" decoding=\"async\" width=\"1\" height=\"1\" style=\"margin: 0px !important; border: currentcolor !important; border-image: none !important !important;\" alt=\"\" src=\"https:\/\/ir-jp.amazon-adsystem.com\/e\/ir?t=typea09-22&amp;l=li2&amp;o=9&amp;a=4873117356\" border=\"0\"><\/p>\n<h2>1.\u57fa\u672c\u7d71\u8a08\u91cf<\/h2>\n<p><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2018\/05\/18\/python_5\">Python \u6570\u5b66\u3001\u7d71\u8a08\u3001\u6a5f\u68b0\u5b66\u7fd2\uff1a\u57fa\u672c\u7d71\u8a08\u91cf\u3001\u30d2\u30b9\u30c8\u30b0\u30e9\u30e0<\/a> \u3067\u4f7f\u7528\u3057\u305f\u3001<a href=\"https:\/\/pythondatascience.plavox.info\/scikit-learn\/scikit-learn%E3%81%AB%E4%BB%98%E5%B1%9E%E3%81%97%E3%81%A6%E3%81%84%E3%82%8B%E3%83%87%E3%83%BC%E3%82%BF%E3%82%BB%E3%83%83%E3%83%88\">Boston\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8<\/a> \u306e\u4f4f\u5b85\u4fa1\u683c\u3092\u30d2\u30b9\u30c8\u30b0\u30e9\u30e0\u306b\u8868\u793a\u3057\u3001\u5404\u57fa\u672c\u7d71\u8a08\u91cf\u3092\u51fa\u529b\u3057\u3066\u307f\u308b\u3002<\/p>\n<pre class=\"prettyprint linenums\">from sklearn import datasets\r\nimport pandas as pd\r\nimport matplotlib.pyplot as plt\r\nimport math\r\n\r\n\r\ndef var_stdev():\r\n    \"\"\"\r\n    https:\/\/pythondatascience.plavox.info\/matplotlib\/%E6%95%A3%E5%B8%83%E5%9B%B3\r\n    https:\/\/qiita.com\/ynakayama\/items\/8d3b1f7356da5bcbe9bc\r\n    https:\/\/teratail.com\/questions\/72586\r\n    :return:\r\n    \"\"\"\r\n    boston = datasets.load_boston()\r\n\r\n    df = pd.DataFrame(boston.target)\r\n    df.columns = ['Price']\r\n\r\n    x = df['Price']\r\n    # CSV\u306b\u51fa\u529b\r\n    # x.to_csv('~\/work\/house_price.csv')\r\n\r\n    import pprint\r\n    print(pprint.pprint(dir(x)))\r\n\r\n    label = \"\"\"\r\n    mean={0:f}\r\n    median={1:f}\r\n    mode={2:f}\r\n    variance={3:f}\r\n    standard deviation={4:f}\r\n    standard error={5:f}\r\n    kurtosis={6:f}\r\n    skewness={7:f}\r\n    \"\"\".format(x.mean(), x.median(), x.mode().iloc[0], x.var(), x.std(),\r\n               x.sem(), x.kurtosis(), x.skew())\r\n\r\n    fig = plt.figure()\r\n    ax = fig.add_subplot(1,1,1)\r\n    ax.set_title('Boston house price')\r\n\r\n    ax.hist(x, bins=int(round(math.sqrt(x.count()), 0)),\r\n            rwidth=0.8, label='house price(x $1,000)')\r\n\r\n    ax.text(25, 40, label)\r\n\r\n    ax.legend()\r\n    plt.show()\r\n\r\n\r\nif __name__ == \"__main__\":\r\n    var_stdev()<\/pre>\n<p><\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/Python-2_120\/var_stdev.png\"><img loading=\"lazy\" decoding=\"async\" width=\"468\" height=\"352\" title=\"var_stdev\" style=\"display: inline; background-image: none;\" alt=\"var_stdev\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/Python-2_120\/var_stdev_thumb.png\" border=\"0\"><\/a><\/p>\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"2\">\n<tbody>\n<tr>\n<td valign=\"top\">\u57fa\u672c\u7d71\u8a08\u91cf<\/td>\n<td valign=\"top\">\u5bfe\u5fdc\u3059\u308bDataFrame\u306e\u95a2\u6570<\/td>\n<td valign=\"top\">\u6982\u8981<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\"><a href=\"https:\/\/ja.wikipedia.org\/wiki\/%E5%B9%B3%E5%9D%87\">\u5e73\u5747(mean)<\/a><\/td>\n<td valign=\"top\">mean()<\/td>\n<td valign=\"top\">\u89b3\u6e2c\u5024\u306e\u7dcf\u548c\u3092\u89b3\u6e2c\u5024\u306e\u500b\u6570\u3067\u5272\u3063\u305f\u3082\u306e<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\"><a href=\"https:\/\/ja.wikipedia.org\/wiki\/%E4%B8%AD%E5%A4%AE%E5%80%A4\">\u4e2d\u592e\u5024(median)<\/a><\/td>\n<td valign=\"top\">median()<\/td>\n<td valign=\"top\">\u6709\u9650\u500b\u306e\u30c7\u30fc\u30bf\u3092\u5c0f\u3055\u3044\u9806\u306b\u4e26\u3079\u305f\u3068\u304d\u4e2d\u592e\u306b\u4f4d\u7f6e\u3059\u308b\u5024<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\"><a href=\"https:\/\/ja.wikipedia.org\/wiki\/%E6%9C%80%E9%A0%BB%E5%80%A4\">\u6700\u983b\u5024(mode)<\/a><\/td>\n<td valign=\"top\">mode()<\/td>\n<td valign=\"top\">\u30c7\u30fc\u30bf\u7fa4\u3084\u78ba\u7387\u5206\u5e03\u3067\u6700\u3082\u983b\u7e41\u306b\u51fa\u73fe\u3059\u308b\u5024<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\"><a href=\"https:\/\/ja.wikipedia.org\/wiki\/%E5%88%86%E6%95%A3_(%E7%A2%BA%E7%8E%87%E8%AB%96)\">\u5206\u6563(variance)<\/a><\/td>\n<td valign=\"top\">var()<\/td>\n<td valign=\"top\">\u5e73\u5747\u304b\u3089\u306e\u30d0\u30e9\u30c4\u30ad\u3092\u793a\u3059\u6307\u6a19\u3001\u6a19\u6e96\u504f\u5dee\u306e\uff12\u4e57\u30010 \u306b\u8fd1\u3044\u307b\u3069\u6563\u3089\u3070\u308a\u306f\u5c0f\u3055\u3044<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\"><a href=\"https:\/\/ja.wikipedia.org\/wiki\/%E6%A8%99%E6%BA%96%E5%81%8F%E5%B7%AE\">\u6a19\u6e96\u504f\u5dee(standard deviation)<\/a><\/td>\n<td valign=\"top\">std()<\/td>\n<td valign=\"top\">\u5e73\u5747\u304b\u3089\u306e\u30d0\u30e9\u30c4\u30ad\u3092\u793a\u3059\u6307\u6a19\u3001\u5206\u6563\u306e\u6b63\u306e\u5e73\u65b9\u6839<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\"><a href=\"https:\/\/ja.wikipedia.org\/wiki\/%E6%A8%99%E6%BA%96%E8%AA%A4%E5%B7%AE\">\u6a19\u6e96\u8aa4\u5dee(standard error)<\/a><\/td>\n<td valign=\"top\">sem()<\/td>\n<td valign=\"top\">\n<p>\u6bcd\u96c6\u56e3\u304b\u3089\u3042\u308b\u6570\u306e\u6a19\u672c\u3092\u9078\u3076\u3068\u304d\u3001\u9078\u3076\u7d44\u307f\u5408\u308f\u305b\u306b\u4f9d\u3063\u3066\u7d71\u8a08\u91cf\u304c\u3069\u306e\u7a0b\u5ea6\u3070\u3089\u3064\u304f\u304b\u3092\u3001\u5168\u3066\u306e\u7d44\u307f\u5408\u308f\u305b\u306b\u3064\u3044\u3066\u306e\u6a19\u6e96\u504f\u5dee\u3067\u8868\u3057\u305f\u3082\u306e\u3002<\/p>\n<p>\u7d71\u8a08\u91cf\u3092\u6307\u5b9a\u305b\u305a\u306b\u5358\u306b\u300c\u6a19\u6e96\u8aa4\u5dee\u300d\u3068\u8a00\u3063\u305f\u5834\u5408\u3001\u6a19\u672c\u5e73\u5747\u306e\u6a19\u6e96\u8aa4\u5dee\uff08standard error of the mean\u3001SEM\uff09\u306e\u3053\u3068\u3092\u666e\u901a\u306f\u6307\u3059\u3002<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\"><a href=\"https:\/\/ja.wikipedia.org\/wiki\/%E5%B0%96%E5%BA%A6\">\u5c16\u5ea6(kurtosis)<\/a><\/td>\n<td valign=\"top\">kurtosis()<\/td>\n<td valign=\"top\">\u6b63\u898f\u5206\u5e03\u3068\u6bd4\u3079\u3066\u3001\u5c16\u5ea6\u304c\u5927\u304d\u3051\u308c\u3070\u92ed\u3044\u30d4\u30fc\u30af\u3068\u9577\u304f\u592a\u3044\u88fe\u3092\u6301\u3063\u305f\u5206\u5e03\u3092\u6301\u3061\u3001\u5c16\u5ea6\u304c\u5c0f\u3055\u3051\u308c\u3070\u3088\u308a\u4e38\u307f\u304c\u304b\u3063\u305f\u30d4\u30fc\u30af\u3068\u77ed\u304f\u7d30\u3044\u5c3e\u3092\u6301\u3063\u305f\u5206\u5e03\u3067\u3042\u308b\u3068\u3044\u3046\u4e8b\u304c\u5224\u65ad\u3067\u304d\u308b<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\"><a href=\"https:\/\/ja.wikipedia.org\/wiki\/%E6%AD%AA%E5%BA%A6\">\u6b6a\u5ea6(skewness)<\/a><\/td>\n<td valign=\"top\">skew()<\/td>\n<td valign=\"top\">\u5206\u5e03\u306e\u975e\u5bfe\u79f0\u6027\u3092\u793a\u3059\u6307\u6a19<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><a href=\"https:\/\/www.amazon.co.jp\/Think-Stats-%E2%80%95%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9E%E3%81%AE%E3%81%9F%E3%82%81%E3%81%AE%E7%B5%B1%E8%A8%88%E5%85%A5%E9%96%80-Allen-Downey\/dp\/4873117356\/ref=as_li_ss_il?ie=UTF8&amp;qid=1527090494&amp;sr=8-2&amp;keywords=think+stats+%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9E%E3%81%AE%E3%81%9F%E3%82%81%E3%81%AE%E7%B5%B1%E8%A8%88%E5%85%A5%E9%96%80&amp;linkCode=li2&amp;tag=typea09-22&amp;linkId=4701865ae6ba66d4ac374b97a41efa06\" target=\"_blank\"><img decoding=\"async\" src=\"\/\/ws-fe.amazon-adsystem.com\/widgets\/q?_encoding=UTF8&amp;ASIN=4873117356&amp;Format=_SL160_&amp;ID=AsinImage&amp;MarketPlace=JP&amp;ServiceVersion=20070822&amp;WS=1&amp;tag=typea09-22\" border=\"0\"><\/a><img loading=\"lazy\" decoding=\"async\" width=\"1\" height=\"1\" style=\"margin: 0px !important; border: currentcolor !important; border-image: none !important;\" alt=\"\" src=\"https:\/\/ir-jp.amazon-adsystem.com\/e\/ir?t=typea09-22&amp;l=li2&amp;o=9&amp;a=4873117356\" border=\"0\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1.\u57fa\u672c\u7d71\u8a08\u91cf Python \u6570\u5b66\u3001\u7d71\u8a08\u3001\u6a5f\u68b0\u5b66\u7fd2\uff1a\u57fa\u672c\u7d71\u8a08\u91cf\u3001\u30d2\u30b9\u30c8\u30b0\u30e9\u30e0 \u3067\u4f7f\u7528\u3057\u305f\u3001Boston\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8 \u306e\u4f4f\u5b85\u4fa1\u683c\u3092\u30d2\u30b9\u30c8\u30b0\u30e9\u30e0\u306b\u8868\u793a\u3057\u3001\u5404\u57fa\u672c\u7d71\u8a08\u91cf\u3092\u51fa\u529b\u3057\u3066\u307f\u308b\u3002 from sklearn import  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"sns_share_botton_hide":"","vkExUnit_sns_title":"","_vk_print_noindex":"","sitemap_hide":"","_veu_custom_css":"","veu_display_promotion_alert":"","vkexunit_cta_each_option":"","footnotes":""},"categories":[35,86],"tags":[],"class_list":["post-533","post","type-post","status-publish","format-standard","hentry","category-math","category-statistics"],"veu_head_title_object":{"title":"","add_site_title":""},"_links":{"self":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/533","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=533"}],"version-history":[{"count":0,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/533\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=533"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=533"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=533"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}