{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# Leakage Estimation\n\nProbing用の参照用サブ。最初の行からx%を`id`で埋めた時の点数を求める。\n（$x \\in [0, 1]$のprobe結果と比較する用）。","metadata":{}},{"cell_type":"code","source":"from math import nan, isnan\n\nimport pandas as pd\nfrom tqdm import tqdm","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-07-09T04:39:44.207265Z","iopub.execute_input":"2022-07-09T04:39:44.207651Z","iopub.status.idle":"2022-07-09T04:39:44.212752Z","shell.execute_reply.started":"2022-07-09T04:39:44.207617Z","shell.execute_reply":"2022-07-09T04:39:44.211521Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class cfg:\n    fill_ratio = 0.9","metadata":{"execution":{"iopub.status.busy":"2022-07-09T04:41:06.144164Z","iopub.execute_input":"2022-07-09T04:41:06.14455Z","iopub.status.idle":"2022-07-09T04:41:06.149411Z","shell.execute_reply.started":"2022-07-09T04:41:06.144518Z","shell.execute_reply":"2022-07-09T04:41:06.148048Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test = pd.read_csv(\"../input/foursquare-location-matching/test.csv\", usecols=[\"id\"])\ntest","metadata":{"execution":{"iopub.status.busy":"2022-07-09T04:40:34.089012Z","iopub.execute_input":"2022-07-09T04:40:34.089396Z","iopub.status.idle":"2022-07-09T04:40:34.104376Z","shell.execute_reply.started":"2022-07-09T04:40:34.089364Z","shell.execute_reply":"2022-07-09T04:40:34.10297Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission = pd.DataFrame({\"id\": test[\"id\"], \"matches\": [nan] * len(test)})\nsubmission","metadata":{"execution":{"iopub.status.busy":"2022-07-09T04:41:12.955048Z","iopub.execute_input":"2022-07-09T04:41:12.955426Z","iopub.status.idle":"2022-07-09T04:41:12.969516Z","shell.execute_reply.started":"2022-07-09T04:41:12.955394Z","shell.execute_reply":"2022-07-09T04:41:12.968288Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"idxs = submission.index < int(len(submission) * cfg.fill_ratio)\nsubmission.loc[idxs, \"matches\"] = submission.loc[idxs, \"id\"]\nsubmission","metadata":{"execution":{"iopub.status.busy":"2022-07-09T04:41:21.021929Z","iopub.execute_input":"2022-07-09T04:41:21.02233Z","iopub.status.idle":"2022-07-09T04:41:21.035756Z","shell.execute_reply.started":"2022-07-09T04:41:21.022299Z","shell.execute_reply":"2022-07-09T04:41:21.034535Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.to_csv(\"submission.csv\", index=False)\npd.read_csv(\"submission.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-07-09T04:41:35.488897Z","iopub.execute_input":"2022-07-09T04:41:35.489325Z","iopub.status.idle":"2022-07-09T04:41:35.505634Z","shell.execute_reply.started":"2022-07-09T04:41:35.489279Z","shell.execute_reply":"2022-07-09T04:41:35.504725Z"},"trusted":true},"execution_count":null,"outputs":[]}]}