{"id":4257,"date":"2023-12-27T12:59:15","date_gmt":"2023-12-27T03:59:15","guid":{"rendered":"https:\/\/blog.since2020.jp\/?p=4257"},"modified":"2023-12-27T13:02:08","modified_gmt":"2023-12-27T04:02:08","slug":"low-memory-basket-from-bigquery","status":"publish","type":"post","link":"https:\/\/since2020.jp\/media\/low-memory-basket-from-bigquery\/","title":{"rendered":"BigQuery\u4e0a\u306e\u30c7\u30fc\u30bf\u3092\u4f7f\u3063\u3066\u7701\u30e1\u30e2\u30ea\u3067\u30d0\u30b9\u30b1\u30c3\u30c8\u5206\u6790"},"content":{"rendered":"\n<p>\u4eca\u56de\u306fBigQuery\u4e0a\u306e\u30c7\u30fc\u30bf\u304b\u3089\u540c\u6642\u306b\u8cfc\u5165\u3055\u308c\u308b\u5546\u54c1\u306b\u3064\u3044\u3066\u5206\u6790\u3092\u884c\u3046\u30d0\u30b9\u30b1\u30c3\u30c8\u5206\u6790\u3092\u884c\u3063\u3066\u307f\u305f\u306e\u3067\u3001\u305d\u306e\u5b9f\u88c5\u65b9\u6cd5\u3092\u307e\u3068\u3081\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002\u30c7\u30fc\u30bf\u30b5\u30a4\u30ba\u304c\u5927\u304d\u304f\u4f7f\u7528\u3059\u308b\u30e1\u30e2\u30ea\u3092\u524a\u6e1b\u3057\u305f\u5b9f\u88c5\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n\n\n<h2>\u306f\u3058\u3081\u306b<\/h2>\n\u4eca\u56de\u306fpython\u306emlxtend\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u7528\u3044\u3066BigQuery\u306b\u4fdd\u5b58\u3055\u308c\u305f\u30c6\u30fc\u30d6\u30eb\u306e\u30c7\u30fc\u30bf\u3092\u30d0\u30b9\u30b1\u30c3\u30c8\u5206\u6790\u3057\u3088\u3046\u3068\u3057\u305f\u3068\u3053\u308d\u3001\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u4e0a\u306b\u3042\u308b\u591a\u304f\u306e\u65b9\u6cd5\u3067\u306f\u30e1\u30e2\u30ea\u4e0d\u8db3\u3068\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u3002\u305d\u3053\u3067\u4e00\u90e8\u306e\u5de5\u7a0b\u3092\u624b\u3067\u4f5c\u308b\u3053\u3068\u3067\u4f7f\u7528\u3059\u308b\u30e1\u30e2\u30ea\u306e\u524a\u6e1b\u3092\u884c\u3063\u305f\u306e\u3067\u3001\u305d\u306e\u3084\u308a\u65b9\u306b\u3064\u3044\u3066\u307e\u3068\u3081\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002\u306a\u304a\u3001Google Cloud \u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u8a8d\u8a3c\u90e8\u5206\u306b\u3064\u3044\u3066\u306f\u30d6\u30e9\u30a6\u30b6\u306e\u3042\u308b\u74b0\u5883\u3092\u524d\u63d0\u3068\u3057\u3066\u3044\u307e\u3059\u3002\n\n<h2>\u30d0\u30b9\u30b1\u30c3\u30c8\u5206\u6790\u306e\u5404\u6307\u6a19\u306b\u3064\u3044\u3066<\/h2>\n\u3088\u304f\u4f7f\u308f\u308c\u308b\u6307\u6a19\u306b\u3064\u3044\u3066\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u3082\u306e\u304c\u6319\u3052\u3089\u308c\u307e\u3059\u3002mlxtend\u3067\u306fantecedents\u306b\u3088\u3063\u3066\u3001consequents\u304c\u3069\u306e\u7a0b\u5ea6\u8cfc\u5165\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u308b\u304b\u3068\u3044\u3046\u5f62\u3067\u51fa\u529b\u3057\u307e\u3059\u3002\r\n\r\n<ul>\r\n \t<li><strong>antecedents<\/strong>: \u524d\u63d0\u3068\u3059\u308b\u5546\u54c1(\u7fa4)\u3002<\/li>\r\n\t<li><strong>consequents<\/strong>: \u4eca\u8003\u3048\u3066\u3044\u308b\u5546\u54c1(\u7fa4)\u3002<\/li>\r\n\t<li><strong>support\u5024<\/strong>: \u305d\u306e\u8cfc\u5165\u306e\u4ed5\u65b9\u3092\u3057\u305f\u9867\u5ba2\u306e\u5168\u9867\u5ba2\u306b\u5bfe\u3059\u308b\u5272\u5408\u3002<\/li>\r\n\t<li><strong>confidence\u5024<\/strong>: antecedents\u3092\u8cfc\u5165\u3057\u305f\u3068\u304d\u306bconsequents\u3092\u8cfc\u5165\u3059\u308b\u6761\u4ef6\u4ed8\u304d\u78ba\u7387\u3002\u3064\u307e\u308a\u3001antecedents\u3092\u8cfc\u5165\u3057\u305f\u969b\u306b\u3001\u3069\u308c\u3060\u3051\u306e\u5272\u5408\u304cconsequents\u3092\u8cfc\u5165\u3059\u308b\u304b\u3002<\/li>\r\n\t<li><strong>lift\u5024<\/strong>: confidence\u306e\u5024\u3092consequents\u3092\u8cfc\u5165\u3059\u308b\u9867\u5ba2\u306e\u5272\u5408\u3067\u5272\u3063\u305f\u5024\u3002antecedents\u3068\u4e00\u7dd2\u306bconsequents\u3092\u8cfc\u5165\u3057\u305f\u9867\u5ba2\u306e\u5272\u5408\u3068\u3001\u5358\u7d14\u306b\u5168\u9867\u5ba2\u306b\u5bfe\u3059\u308bconsequents\u3092\u8cfc\u5165\u3059\u308b\u9867\u5ba2\u306e\u5272\u5408\u306e\u6bd4\u306a\u306e\u3067\u3001antecedents\u306b\u3088\u3063\u3066consequents\u304c\u3069\u306e\u7a0b\u5ea6\u8cb7\u308f\u308c\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u304b\u3092\u793a\u3059\u3002<\/li>\r\n<\/ul>\n\n<h2>\u4eca\u56de\u4f7f\u7528\u3057\u305f\u30c7\u30fc\u30bf<\/h2>\n\u4eca\u56de\u306f\u8cfc\u5165\u5c65\u6b74\u306e\u60c5\u5831\u3092\u4f7f\u3044\u307e\u3057\u305f\u3002\u5404\u884c1\u3064\u306e\u5546\u54c1\u304c\u8cfc\u5165\u3055\u308c\u305f\u6642\u306e\u60c5\u5831\u3092\u8868\u3057\u3066\u3044\u308b\u72b6\u614b\u3067\u3059\u3002\r\n\r\n\u3053\u3053\u3067\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30c7\u30fc\u30bf\u304cBigQuery\u4e0a\u306b\u3042\u308a\u3001\u3053\u308c\u3092\u4f7f\u7528\u3057\u305f\u3068\u3057\u307e\u3057\u3087\u3046\u3002\u5b9f\u969b\u306b\u306f\u53d6\u5f15\u5148\u30ad\u30fc\u306b\u306f\u53d6\u5f15\u76f8\u624b\u3092\u4e00\u610f\u306b\u7279\u5b9a\u3067\u304d\u308b\u3088\u3046\u306a\u3001\u5546\u54c1\u540d\u306f\u5546\u54c1\u3092\u6c7a\u5b9a\u3067\u304d\u308b\u3088\u3046\u306a\u9805\u76ee\u3067\u3059\u3002\r\n<img decoding=\"async\" src=\"https:\/\/since2020.jp\/media\/wp-content\/uploads\/2023\/12\/basket_1.png\" alt=\"\" \/>\r\n\r\n\u4e0a\u8a18\u306e\u8868\u3067\u306f\u540c\u6642\u306b\u8907\u6570\u306e\u5546\u54c1\u304c\u8cfc\u5165\u3055\u308c\u305f\u5834\u5408\u3001\u5546\u54c1\u3054\u3068\u306b\u5225\u306e\u884c\u306b\u5206\u3051\u3089\u308c\u307e\u3059\u3002\u307e\u305f\u3001\u53d7\u6ce8\u5148\u304c\u540c\u3058\u3067\u3042\u3063\u3066\u3082\u65e5\u6642\u304c\u7570\u306a\u308b\u5834\u5408\u306b\u306f\u3001\u540c\u6642\u306b\u8cfc\u5165\u3055\u308c\u3066\u3044\u308b\u308f\u3051\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u3057\u305f\u304c\u3063\u3066\u3001\u4eca\u56de\u306e\u4f8b\u3067\u306f\u53d6\u5f15\u5148\u30ad\u30fc\u3068\u53d7\u6ce8\u65e5\u6642\u304c\u540c\u3058\u3067\u3042\u308b\u3088\u3046\u306a\u3059\u3079\u3066\u306e\u30c7\u30fc\u30bf\u3092\u7d71\u5408\u3057\u305f\u4e0a\u3067\u30011\u3064\u306e\u30c7\u30fc\u30bf\u3068\u3057\u3066\u518d\u69cb\u7bc9\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\r\n\u3064\u307e\u308a\u3001\u30a4\u30e1\u30fc\u30b8\u3068\u3057\u3066\u306f\u4e0a\u8a18\u306e\u8868\u3092\u4e0b\u8a18\u306e\u3088\u3046\u306a\u3082\u306e\u306b\u66f8\u304d\u63db\u3048\u3066\u304b\u3089\u8003\u3048\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002\r\n<img decoding=\"async\" src=\"https:\/\/since2020.jp\/media\/wp-content\/uploads\/2023\/12\/basket2.png\" alt=\"\" \/>\r\n\n\n<h2>\u30e2\u30b8\u30e5\u30fc\u30eb\u306eimport<\/h2>\n\u4f7f\u3046\u30e2\u30b8\u30e5\u30fc\u30eb\u306fmlxtend\u3001pandas\u3001google.cloud\u3067\u3059\u3002\r\n<div class=\"hcb_wrap\">\r\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>import mlxtend\r\nfrom mlxtend.preprocessing import TransactionEncoder\r\nfrom mlxtend.frequent_patterns import apriori\r\nfrom mlxtend.frequent_patterns import association_rules\r\nfrom google.cloud import bigquery\r\nimport pandas as pd<\/code><\/pre>\r\n<\/div>\n\n<h2>gcloud CLI\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb(Local\u74b0\u5883\u306e\u5834\u5408)<\/h2>\nGoogle Cloud\u306e<a href=\"https:\/\/cloud.google.com\/sdk\/docs\/install?hl=ja\" title=\"\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u30da\u30fc\u30b8\">gcloud CLI<\/a>\u304b\u3089\u81ea\u5206\u306eOS\u306b\u3042\u3063\u305f\u3082\u306e\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30e9\u30fc\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u3001\u30a4\u30f3\u30b9\u30c8\u30fc\u30e9\u30fc\u306b\u5f93\u3063\u3066\u9032\u307f\u307e\u3057\u3087\u3046\u3002\r\n\r\n\u305d\u306e\u5f8c\u3001\u4f7f\u7528\u3059\u308b\u30c6\u30fc\u30d6\u30eb\u304c\u3042\u308b\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4ee5\u4e0b\u306e\u624b\u9806\u3067\u8a8d\u8a3c\u3057\u307e\u3057\u3087\u3046\u3002\r\n\r\n1. `gcloud init`\u30b3\u30de\u30f3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u521d\u671f\u5316\u3059\u308b\u3002\u306f\u3058\u3081\u3066\u306e\u5834\u5408default\u3068\u3044\u3046\u8a2d\u5b9a\u304c\u3067\u304d\u3001\u305d\u306e\u5f8c\u3001\u30d6\u30e9\u30a6\u30b6\u306b\u98db\u3093\u3067\u8a8d\u8a3c\u3092\u6c42\u3081\u3089\u308c\u308b\u306e\u3067\u8a8d\u8a3c\u3092\u884c\u3046\u3002\r\n2. \u8907\u6570\u306eGoogle Cloud Project\u304c\u305d\u306eGoogle Account\u306b\u7d10\u3065\u3044\u3066\u3044\u308b\u5834\u5408\u306b\u306f\u9078\u629e\u304c\u6c42\u3081\u3089\u308c\u308b\u306e\u3067\u3001\u4f7f\u7528\u3057\u305f\u3044\u30c7\u30fc\u30bf\u306e\u3042\u308b\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u9078\u629e\u3059\u308b\u3002\n\n<h2>BigQuery\u304b\u3089\u30c7\u30fc\u30bf\u306e\u8aad\u307f\u8fbc\u307f<\/h2>\n<div class=\"hcb_wrap\">\r\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>bq_client = bigquery.Client()\r\nquery ='Your Query'\r\nbase_df = bq_client.query(query).to_dataframe()\r\nbase_df['sales'] = base_df['\u5358\u4fa1'] * base_df['\u53d7\u6ce8\u6570']\r\nthreshold = base_df['sales'].quantile(0.85)\r\nprocessed_df = base_df[base_df['sales'] &gt;= threshold].reset_index(drop=True)<\/code><\/pre>\r\n<\/div>\r\nYour Query\u306b\u306fBigQuery\u304b\u3089\u30c7\u30fc\u30bf\u3092\u30ed\u30fc\u30c9\u3059\u308b\u30af\u30a8\u30ea\u3092\u66f8\u304d\u307e\u3057\u3087\u3046\u3002\u3053\u3053\u3067\u306f\u30c7\u30fc\u30bf\u6570\u304c\u81a8\u5927\u306a\u306e\u3067\u58f2\u4e0a\u3092\u8868\u3059sales\u5217\u3092\u4f5c\u6210\u3057\u3001\u305d\u306e\u4e0a\u4f4d15%\u306e\u307f\u3092\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u3002\u3053\u306e\u8fba\u308a\u306f\u30af\u30a8\u30ea\u3067\u524a\u6e1b\u3057\u3066\u3082\u826f\u3044\u3067\u3059\u3057\u3001\u4f7f\u3046\u30c7\u30fc\u30bf\u306e\u30b5\u30a4\u30ba\u306b\u5fdc\u3058\u3066\u5909\u66f4\u3057\u307e\u3057\u3087\u3046\u3002\n\n<h2>\u6642\u306b\u8cfc\u5165\u3055\u308c\u305f\u5546\u54c1\u3092\u307e\u3068\u3081\u308b<\/h2>\n<div class=\"hcb_wrap\">\r\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>del base_df\r\ntmp_df = (\r\n    processed_df.groupby([\"\u53d6\u5f15\u5148\u30ad\u30fc\", \"\u53d7\u6ce8\u65e5\u6642\", \"\u5546\u54c1\u540d\"], dropna=False)[\"\u53d7\u6ce8\u6570\"]\r\n    .sum()\r\n    .reset_index()\r\n)\r\ndel processed_df\r\ngrouped_df = (\r\n    tmp_df.groupby([\"\u53d6\u5f15\u5148\u30ad\u30fc\", \"\u53d7\u6ce8\u65e5\u6642\"])[\"\u5546\u54c1\u540d\"]\r\n    .apply(list)\r\n    .reset_index()\r\n)\r\nunique_products_group = tmp_df['\u5546\u54c1\u540d'].unique()\r\ndel tmp_df<\/code><\/pre>\r\n<\/div>\r\ntmp_df\u306f\u5168\u304f\u540c\u3058\u6271\u3044\u3092\u3055\u308c\u308b\u3079\u304d\u884c\u304c\u8907\u6570\u3067\u304d\u3066\u3057\u307e\u3063\u3066\u3044\u308b\u5834\u5408\u306b\u3001\u305d\u308c\u3092\u307e\u3068\u3081\u30661\u3064\u306e\u884c\u306b\u3057\u305f\u3082\u306e\u3067\u3059\u3002\u305d\u306e\u5f8c\u3001\u5148\u306b\u793a\u3057\u305f\u3088\u3046\u306b\u53d6\u5f15\u5148\u30ad\u30fc\u3068\u53d7\u6ce8\u65e5\u6642\u3054\u3068\u306b\u5546\u54c1\u3092\u307e\u3068\u3081\u3066\u30ea\u30b9\u30c8\u3068\u3057\u30011\u884c\u306b\u3057\u305f\u3082\u306e\u304cgrouped_df\u306b\u306a\u308a\u307e\u3059\u3002\u305d\u308c\u304b\u3089\u3001\u3053\u306e\u5f8c\u4f7f\u3046\u7528\u306b\u5168\u3066\u306e\u5546\u54c1\u30c7\u30fc\u30bf\u306e\u540d\u524d\u3092\u30ea\u30b9\u30c8\u3068\u3057\u3066\u53d6\u5f97\u3057\u3066\u304a\u304d\u307e\u3059\u3002\r\n\r\n\u30d0\u30b9\u30b1\u30c3\u30c8\u5206\u6790\u306b\u304a\u3044\u3066\u53d7\u6ce8\u6570\u81ea\u4f53\u306f\u610f\u5473\u3092\u6301\u305f\u305a\u3001\u305d\u306e\u5546\u54c1\u304c\u8cfc\u5165\u3055\u308c\u305f\u304b\u5426\u304b\u306e\u60c5\u5831\u306e\u307f\u304c\u91cd\u8981\u3068\u306a\u3063\u3066\u304d\u307e\u3059\u3002\u305d\u306e\u305f\u3081\u3001grouped_df\u3067\u306f\u53d7\u6ce8\u6570\u306e\u60c5\u5831\u3092\u843d\u3068\u3057\u3066\u3044\u307e\u3059\u3002\u306a\u304a\u3001\u4eca\u56de\u306e\u5b9f\u88c5\u3067\u306f\u53d7\u6ce8\u6570\u304c0\u3068\u306a\u3089\u306a\u3044\u3053\u3068\u3092\u524d\u63d0\u3068\u3057\u3066\u3044\u307e\u3059\u3002\u3082\u3057\u3001\u305d\u306e\u3088\u3046\u306a\u30b1\u30fc\u30b9\u304c\u8003\u3048\u3089\u308c\u308b\u5834\u5408\u306b\u306f\u5225\u9014\u3001tmp_df\u306b\u5bfe\u3057\u3066\u524d\u51e6\u7406\u3092\u884c\u3046\u3001apply\u3067\u4e0e\u3048\u308b\u95a2\u6570\u3092\u30ab\u30b9\u30bf\u30e0\u3059\u308b\u3068\u3044\u3063\u305f\u51e6\u7406\u3092\u884c\u3063\u3066\u304f\u3060\u3055\u3044\u3002\r\n\r\n\u307e\u305f\u3001\u30c7\u30fc\u30bf\u30b5\u30a4\u30ba\u304c\u5927\u304d\u3044\u5834\u5408\u306b\u306f\u5909\u6570\u306e\u89e3\u653e\u3092\u30d7\u30ed\u30b0\u30e9\u30e0\u4e2d\u3067\u884c\u308f\u306a\u3044\u3068\u30e1\u30e2\u30ea\u30aa\u30fc\u30d0\u30fc\u3092\u5f15\u304d\u8d77\u3053\u3057\u3066\u3057\u307e\u3046\u3053\u3068\u304c\u3042\u308b\u306e\u3067\u3001\u4f7f\u7528\u3057\u306a\u3044\u5909\u6570\u306f\u3059\u3050\u306b\u89e3\u653e\u3057\u307e\u3057\u3087\u3046\u3002\n\n<h2>mlxtend\u7528\u306eone-hot\u306e\u30c6\u30fc\u30d6\u30eb\u4f5c\u6210<\/h2>\n<div class=\"hcb_wrap\">\r\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>product_columns = {\r\n    product: grouped_df[\"\u5546\u54c1\u540d\"].apply(lambda x: product in x)\r\n    for product in unique_products\r\n}\r\nproduct_df = pd.DataFrame(product_columns)\r\ndel grouped_df, product_columns<\/code><\/pre>\r\n<\/div>\r\nmlxtend\u306f\u5217\u306b\u5546\u54c1\u540d\u3092\u3001\u884c\u306b\u5404\u9867\u5ba2\u3092\u3068\u308a\u3001\u305d\u306e\u9867\u5ba2\u304c\u305d\u306e\u5546\u54c1\u3092\u8cfc\u5165\u3057\u305f\u304b\u3092\u771f\u507d\u5024\u3068\u3057\u3066\u6301\u3064\u3088\u3046\u306a\u884c\u5217\u3092\u5165\u529b\u3068\u3057\u3066\u7528\u3044\u307e\u3059\u3002\u3053\u3053\u3067\u306f\u305d\u306e\u884c\u5217(product_df)\u306e\u4f5c\u6210\u3092\u884c\u3044\u307e\u3059\u3002\r\n\r\n\u5546\u54c1\u540d\u3054\u3068\u306e\u5217\u3092\u4f5c\u308a\u3001Lamda\u5f0f\u3092\u4f7f\u3063\u3066\u5404\u6ce8\u6587\u3067\u305d\u306e\u5546\u54c1\u304c\u8cfc\u5165\u3055\u308c\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u3092\u771f\u507d\u5024\u3067\u57cb\u3081\u3066\u3044\u304d\u307e\u3059\u3002\u3053\u308c\u3092\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u306b\u5909\u3048\u305f\u3082\u306e\u304cproduct_df\u3067\u3059\u3002\n\n<h2>\u30d0\u30b9\u30b1\u30c3\u30c8\u5206\u6790\u306e\u7d50\u679c\u51fa\u529b<\/h2>\n<div class=\"hcb_wrap\">\r\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>freq_items = apriori(\r\n    product_df,\r\n    min_support=0.01,\r\n    use_colnames=True,\r\n    max_len=2,\r\n    low_memory=True,\r\n    verbose=False,\r\n)\r\ndf_rules = association_rules(\r\n    freq_items,\r\n    metric=\"confidence\",\r\n    min_threshold=0.0,\r\n)<\/code><\/pre>\r\n<\/div>\r\n\u5148\u306e\u5de5\u7a0b\u3067\u4f5c\u6210\u3057\u305f\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u3092\u9664\u304f\u3001apriori\u95a2\u6570\u306e\u305d\u308c\u305e\u308c\u306e\u5f15\u6570\u306b\u3064\u3044\u3066\u8efd\u304f\u8aac\u660e\u3057\u307e\u3059\u3002\r\n\r\n<ul>\r\n\t<li><strong>min_support(\u5fc5\u9808)<\/strong>: support\u5024\u306e\u6700\u5c0f\u5024\u3092\u898f\u5b9a\u3057\u307e\u3059\u3002support\u5024\u304c\u5c0f\u3055\u3044\u3068\u3044\u3046\u3053\u3068\u306f\u305d\u306e\u8cfc\u5165\u30d1\u30bf\u30fc\u30f3\u306e\u51fa\u73fe\u983b\u5ea6\u304c\u5c0f\u3055\u3044\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002\u3053\u306e\u5024\u3092\u5b9a\u3081\u308b\u3053\u3068\u3067\u30ce\u30a4\u30ba\u3092\u9664\u53bb\u3057\u307e\u3059\u3002<\/li>\r\n\t<li><strong>use_colnames(\u5fc5\u9808)<\/strong>: True\u306e\u5834\u5408\u3001\u5f15\u6570\u3068\u3057\u3066\u53d6\u3063\u305f\u884c\u5217\u306e\u5217\u6210\u5206\u306e\u5024\u3092\u51fa\u529b\u3055\u308c\u308b\u30c7\u30fc\u30bf\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002\u7279\u6bb5\u306e\u7406\u7531\u304c\u306a\u3051\u308c\u3070True\u3067\u3044\u3044\u3067\u3057\u3087\u3046\u3002<\/li>\r\n\t<li><strong>max_len(\u5fc5\u9808)<\/strong>: \u540c\u6642\u306b\u8003\u616e\u3059\u308b\u5546\u54c1\u306e\u6700\u5927\u6570\u3067\u3059\u30022\u4ee5\u4e0a\u306e\u6574\u6570\u5024\u3067\u30012\u306e\u5834\u54081\u3064\u306e\u5546\u54c1\u306b\u5bfe\u3057\u3066\u5225\u306e1\u3064\u306e\u5546\u54c1\u304c\u3069\u308c\u3060\u3051\u4e00\u7dd2\u306b\u8cb7\u308f\u308c\u308b\u304b\u306e\u307f\u3092\u8868\u3057\u307e\u3059\u304c\u30013\u4ee5\u4e0a\u306b\u3059\u308b\u3068\u8907\u6570\u306e\u5546\u54c1\u304c\u8cb7\u308f\u308c\u305f\u5834\u5408\u306b\u3001\u5225\u306e\u5546\u54c1\u3084\u5546\u54c1\u7fa4\u304c\u3069\u308c\u3060\u3051\u8cb7\u308f\u308c\u3084\u3059\u3044\u304b\u3068\u3044\u3046\u591a\u5bfe\u591a\u306e\u95a2\u4fc2\u307e\u3067\u898b\u308c\u307e\u3059\u3002<\/li>\r\n\t<li><strong>low_memory<\/strong>: \u3053\u308c\u3092True\u306b\u3059\u308b\u3068\u3001\u30e1\u30e2\u30ea\u6d88\u8cbb\u3092\u6291\u3048\u3089\u308c\u308b\u4ee3\u308f\u308a\u306b\u5b9f\u884c\u6642\u9593\u304c\u9577\u304f\u306a\u308a\u307e\u3059\u3002<\/li>\r\n\t<li><strong>verbose<\/strong>: \u5b9f\u884c\u4e2d\u306b\u30b9\u30c6\u30fc\u30bf\u30b9\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u51fa\u529b\u3059\u308b\u304b\u3069\u3046\u304b\u3092\u5236\u5fa1\u3057\u307e\u3059\u3002<\/li><\/ul>\r\n\r\nassociation_rules\u95a2\u6570\u306fapriori\u95a2\u6570\u306e\u51fa\u529b\u7d50\u679c\u3092df\u306b\u3057\u3066\u3044\u308b\u30a4\u30e1\u30fc\u30b8\u3067\u3059\u3002metric\u3067\u8a55\u4fa1\u57fa\u6e96\u3068\u3057\u305f\u3044\u7d71\u8a08\u5024\u3092\u9078\u3073\u3001threshold\u3067\u305d\u306e\u4e0b\u9650\u5024\u3092\u6c7a\u3081\u307e\u3059\u3002\n\n<h2>\u51fa\u529b\u306e\u88dc\u6b63<\/h2>\n<div class=\"hcb_wrap\">\r\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>def convert_frozenset(item):\r\n    if isinstance(item, frozenset):\r\n        return ', '.join(item)\r\n    return item<\/code><\/pre>\r\n<\/div>\r\nassociation_rules\u306e\u51fa\u529b\u3059\u308b\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u306b\u304a\u3044\u3066\u3001antecedents\u3068consequents\u3092\u8868\u3059\u5217\u306ffrozenset\u3068\u547c\u3070\u308c\u308b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001\u305d\u306e\u307e\u307e\u4fdd\u5b58\u7b49\u3059\u308b\u3068\u8aad\u307f\u53d6\u308a\u306b\u304f\u3044\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3068\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u306e\u3067\u3001\u3042\u3089\u304b\u3058\u3081\u6587\u5b57\u5217\u306b\u4fee\u6b63\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002\n\n<h2>\u7d42\u308f\u308a\u306b<\/h2>\n\u4eca\u56de\u306fBigQuery\u4e0a\u306e\u30c7\u30fc\u30bf\u3092\u30d0\u30b9\u30b1\u30c3\u30c8\u5206\u6790\u3059\u308b\u65b9\u6cd5\u3092\u307e\u3068\u3081\u307e\u3057\u305f\u3002\u30c7\u30fc\u30bf\u6570\u304c\u591a\u304f\u30e1\u30e2\u30ea\u306b\u4e57\u3089\u306a\u3044\u5834\u5408\u306f\u691c\u8a0e\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002","protected":false},"excerpt":{"rendered":"<p>\u4eca\u56de\u306fBigQuery\u4e0a\u306e\u30c7\u30fc\u30bf\u304b\u3089\u540c\u6642\u306b\u8cfc\u5165\u3055\u308c\u308b\u5546\u54c1\u306b\u3064\u3044\u3066\u5206\u6790\u3092\u884c\u3046\u30d0\u30b9\u30b1\u30c3\u30c8\u5206\u6790\u3092\u884c\u3063\u3066\u307f\u305f\u306e\u3067\u3001\u305d\u306e\u5b9f\u88c5\u65b9\u6cd5\u3092\u307e\u3068\u3081\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002\u30c7\u30fc\u30bf\u30b5\u30a4\u30ba\u304c\u5927\u304d\u304f\u4f7f\u7528\u3059\u308b\u30e1\u30e2\u30ea\u3092\u524a\u6e1b\u3057\u305f\u5b9f\u88c5\u3092\u884c\u3044\u307e\u3059\u3002 \u306f\u3058\u3081\u306b \u4eca\u56de\u306f [&hellip;]<\/p>\n","protected":false},"author":26,"featured_media":4262,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"content-type":"","swell_btn_cv_data":"","footnotes":"","_wp_rev_ctl_limit":""},"categories":[1246],"tags":[108,39,34],"class_list":["post-4257","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-data-infrastructure","tag-bigquery","tag-39","tag-34"],"_links":{"self":[{"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/posts\/4257","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/users\/26"}],"replies":[{"embeddable":true,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/comments?post=4257"}],"version-history":[{"count":1,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/posts\/4257\/revisions"}],"predecessor-version":[{"id":4263,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/posts\/4257\/revisions\/4263"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/media\/4262"}],"wp:attachment":[{"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/media?parent=4257"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/categories?post=4257"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/tags?post=4257"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}