{"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":"<div>\n    <h1 align=\"center\">Smart Ensembling</h1>\n    <h1 align=\"center\">Google Smartphone Decimeter Challenge</h1>   \n</div>","metadata":{}},{"cell_type":"markdown","source":"<div class=\"alert alert-success\">  \n</div>","metadata":{}},{"cell_type":"markdown","source":"<div class=\"alert alert-success\">\n    <h1 align=\"center\">If you find this work useful, please don't forget upvoting :)</h1>\n</div>","metadata":{}},{"cell_type":"code","source":"import numpy as np \nimport pandas as pd\nimport seaborn as sns\n\nimport matplotlib.pyplot as plt\nimport plotly.figure_factory as ff\nimport plotly.express as px\n%matplotlib inline","metadata":{"execution":{"iopub.status.busy":"2021-07-29T01:30:35.655799Z","iopub.execute_input":"2021-07-29T01:30:35.656449Z","iopub.status.idle":"2021-07-29T01:30:35.664568Z","shell.execute_reply.started":"2021-07-29T01:30:35.656415Z","shell.execute_reply":"2021-07-29T01:30:35.663699Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<div class=\"alert alert-success\">  \n</div>","metadata":{}},{"cell_type":"markdown","source":"Thanks to: @columbia2131 https://www.kaggle.com/columbia2131/device-eda-interpolate-by-removing-device-en-ja/output","metadata":{}},{"cell_type":"code","source":"path0 = '../input/gsdc6089/submission.csv' \n\nsub6089 = pd.read_csv(path0)","metadata":{"execution":{"iopub.status.busy":"2021-07-29T01:30:35.666395Z","iopub.execute_input":"2021-07-29T01:30:35.666693Z","iopub.status.idle":"2021-07-29T01:30:35.788278Z","shell.execute_reply.started":"2021-07-29T01:30:35.666666Z","shell.execute_reply":"2021-07-29T01:30:35.787389Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Thanks to: @tensorchoko https://www.kaggle.com/tensorchoko/google-multioutputregressor/output","metadata":{}},{"cell_type":"code","source":"path1 = '../input/gsdc5331/submission.csv'#'../input/gsdc6027/submission.csv' \n\nsub6027 = pd.read_csv(path1)","metadata":{"execution":{"iopub.status.busy":"2021-07-29T01:30:35.789953Z","iopub.execute_input":"2021-07-29T01:30:35.790288Z","iopub.status.idle":"2021-07-29T01:30:35.883664Z","shell.execute_reply.started":"2021-07-29T01:30:35.790258Z","shell.execute_reply":"2021-07-29T01:30:35.882772Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Thanks to: @t88take https://www.kaggle.com/t88take/gsdc-phones-mean-prediction/output","metadata":{}},{"cell_type":"code","source":"path2 = '../input/gsdc5364/submission_log1p_quadratic.csv'# '../input/gsdc5639/submission.csv' \n\nsub5639 = pd.read_csv(path2)","metadata":{"execution":{"iopub.status.busy":"2021-07-29T01:30:35.885480Z","iopub.execute_input":"2021-07-29T01:30:35.885859Z","iopub.status.idle":"2021-07-29T01:30:35.980023Z","shell.execute_reply.started":"2021-07-29T01:30:35.885820Z","shell.execute_reply":"2021-07-29T01:30:35.979018Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Thanks to: @bpetrb https://www.kaggle.com/bpetrb/adaptive-gauss-phone-mean/output","metadata":{}},{"cell_type":"code","source":"path3 = '../input/gsdc5370/submission.csv' \n\nsub5370 = pd.read_csv(path3)","metadata":{"execution":{"iopub.status.busy":"2021-07-29T01:30:35.981448Z","iopub.execute_input":"2021-07-29T01:30:35.981868Z","iopub.status.idle":"2021-07-29T01:30:36.075509Z","shell.execute_reply.started":"2021-07-29T01:30:35.981824Z","shell.execute_reply":"2021-07-29T01:30:36.074497Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"path4 = '../input/gsdc5364/submission_log1p_quadratic.csv' \n\nsub5364 = pd.read_csv(path4)","metadata":{"execution":{"iopub.status.busy":"2021-07-29T01:30:36.076872Z","iopub.execute_input":"2021-07-29T01:30:36.077213Z","iopub.status.idle":"2021-07-29T01:30:36.171292Z","shell.execute_reply.started":"2021-07-29T01:30:36.077183Z","shell.execute_reply":"2021-07-29T01:30:36.170541Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"path5 = '../input/gsdc5331/submission.csv' \n\nsub5331 = pd.read_csv(path5)","metadata":{"execution":{"iopub.status.busy":"2021-07-29T01:30:36.172265Z","iopub.execute_input":"2021-07-29T01:30:36.172654Z","iopub.status.idle":"2021-07-29T01:30:36.263160Z","shell.execute_reply.started":"2021-07-29T01:30:36.172626Z","shell.execute_reply":"2021-07-29T01:30:36.262455Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"path = [path0, path1, path2, path3, path4, path5]","metadata":{"execution":{"iopub.status.busy":"2021-07-29T01:30:36.264822Z","iopub.execute_input":"2021-07-29T01:30:36.265214Z","iopub.status.idle":"2021-07-29T01:30:36.268871Z","shell.execute_reply.started":"2021-07-29T01:30:36.265185Z","shell.execute_reply":"2021-07-29T01:30:36.268192Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<div class=\"alert alert-success\">  \n</div>","metadata":{}},{"cell_type":"code","source":"def ensembling(main, support, coeff1, coeff2): \n    \n    suba  = main.copy() \n    subav = suba.values\n       \n    subb  = support.copy()\n    subbv = subb.values    \n           \n    ense  = main.copy()    \n    ensev = ense.values  \n \n    for i in range (len(main)):\n        \n        pera1 = subav[i, 2]\n        pera2 = subav[i, 3]\n        \n        perb1 = subbv[i, 2]\n        perb2 = subbv[i, 3]\n\n        per1 = (pera1 * coeff1) + (perb1 * (1.0 - coeff1))\n        per2 = (pera2 * coeff2) + (perb2 * (1.0 - coeff2))\n        \n        ensev[i, 2] = per1\n        ensev[i, 3] = per2\n        \n    ense.iloc[:, 2:] = ensev[:, 2:]  \n  \n    return ense      \n","metadata":{"execution":{"iopub.status.busy":"2021-07-29T01:30:36.269994Z","iopub.execute_input":"2021-07-29T01:30:36.270470Z","iopub.status.idle":"2021-07-29T01:30:36.281799Z","shell.execute_reply.started":"2021-07-29T01:30:36.270379Z","shell.execute_reply":"2021-07-29T01:30:36.281050Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<div class=\"alert alert-success\">  \n</div>","metadata":{}},{"cell_type":"code","source":"sub1 = ensembling(sub6027,   sub6089, 0.85, 0.85)\n\nsub2 = ensembling(sub5639,   sub1   , 0.60, 0.60)\n\nsub530 = ensembling(sub5370, sub2  , 0.50, 0.50)\n\nsub4 = ensembling(sub530, sub5331, 0.85, 0.85)\n\n#sub4 = ensembling(sub5364,    sub2, 0.50, 0.50)\n\n","metadata":{"execution":{"iopub.status.busy":"2021-07-29T01:30:36.282816Z","iopub.execute_input":"2021-07-29T01:30:36.283210Z","iopub.status.idle":"2021-07-29T01:30:37.268015Z","shell.execute_reply.started":"2021-07-29T01:30:36.283183Z","shell.execute_reply":"2021-07-29T01:30:37.267228Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub530","metadata":{"execution":{"iopub.status.busy":"2021-07-29T01:30:37.268981Z","iopub.execute_input":"2021-07-29T01:30:37.269375Z","iopub.status.idle":"2021-07-29T01:30:37.284413Z","shell.execute_reply.started":"2021-07-29T01:30:37.269338Z","shell.execute_reply":"2021-07-29T01:30:37.283538Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<div class=\"alert alert-success\">  \n</div>","metadata":{}},{"cell_type":"code","source":"sub5331","metadata":{"execution":{"iopub.status.busy":"2021-07-29T01:30:37.286079Z","iopub.execute_input":"2021-07-29T01:30:37.286543Z","iopub.status.idle":"2021-07-29T01:30:37.308207Z","shell.execute_reply.started":"2021-07-29T01:30:37.286502Z","shell.execute_reply":"2021-07-29T01:30:37.306830Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub1.to_csv(\"submission1.csv\",index=False)\nsub2.to_csv(\"submission2.csv\",index=False)\nsub530.to_csv(\"submission530.csv\",index=False)\nsub4.to_csv(\"submission4.csv\",index=False)\n!ls","metadata":{"execution":{"iopub.status.busy":"2021-07-29T01:30:37.311175Z","iopub.execute_input":"2021-07-29T01:30:37.311462Z","iopub.status.idle":"2021-07-29T01:30:40.724541Z","shell.execute_reply.started":"2021-07-29T01:30:37.311435Z","shell.execute_reply":"2021-07-29T01:30:40.723451Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<div class=\"alert alert-success\">  \n</div>","metadata":{}},{"cell_type":"markdown","source":"<div class=\"alert alert-success\">  \n</div>","metadata":{}}]}