{"cells":[{"metadata":{"_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","collapsed":true,"trusted":true},"cell_type":"code","source":"import numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n","execution_count":1,"outputs":[]},{"metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","trusted":true},"cell_type":"code","source":"dtypes = {\n    'ip'            : 'uint32',\n    'app'           : 'uint16',\n    'device'        : 'uint16',\n    'os'            : 'uint16',\n    'channel'       : 'uint16',\n    'is_attributed' : 'uint8',\n    'click_id'      : 'uint32'\n}\n\nprint('Loading the test data...')\ntest = pd.read_csv(\"../input/test.csv\", dtype=dtypes)","execution_count":2,"outputs":[]},{"metadata":{"_cell_guid":"8b385fd5-0674-422d-af84-2470997b7d62","_uuid":"c67814daf1e0cbde51b2006e9b178ec620df3806","trusted":true},"cell_type":"code","source":"print(\"The percentage of not ordered index is {0}\".format(np.mean(test.index.values != test.click_id.values)))\ntest[test.index.values != test.click_id.values]","execution_count":3,"outputs":[]},{"metadata":{"_cell_guid":"3ebb79e0-8a67-4feb-abf8-62ebee9bc72a","_uuid":"905d87a2a82b316b7641c3d716480992319425df"},"cell_type":"markdown","source":"Simulating effect: Messing the order of random 0,1 with the same frequency as test"},{"metadata":{"_cell_guid":"941cee2b-31e0-4862-86e0-7c6f902cf98f","_uuid":"94d11677b8905d388e1e3b0db1f054a24b3e108f","collapsed":true,"trusted":true},"cell_type":"code","source":"N_SIM = 2500000\nresults = np.zeros((N_SIM)).astype(np.int8)\nTHRESH = 0.0025\nnp.random.seed(42)\nresults = (np.random.uniform(size=N_SIM) < THRESH).astype(int)","execution_count":4,"outputs":[]},{"metadata":{"_cell_guid":"b4e0a9ea-54b5-498e-ab78-834c3334439c","_uuid":"3f4caccd16aa87eb77e994767cc0436fa76d9f71"},"cell_type":"markdown","source":"Creating disorder same as in the test"},{"metadata":{"_cell_guid":"203252ee-180a-48f6-bc40-337a599e56c8","_uuid":"c929fda013c9c87f75706c1e45cd17fb388c4e01","collapsed":true,"trusted":true},"cell_type":"code","source":"predictions = results[test[\"click_id\"].values[:N_SIM]] ","execution_count":5,"outputs":[]},{"metadata":{"_cell_guid":"e79d7a74-72b5-4374-bfce-91f4fe519ead","_uuid":"5f7c972d0431200d6257c3e8cb4735e5e716d5cc","trusted":true},"cell_type":"code","source":"from sklearn.metrics import roc_auc_score\nroc_auc_score(results, predictions)","execution_count":6,"outputs":[]},{"metadata":{"_cell_guid":"2e8bc2ce-eaff-48ef-a6a2-e2a7089886b0","_uuid":"3dc7e9a3a1abdccd8d5c5c19e758179c6d430590"},"cell_type":"markdown","source":"AUC goes down from 1.0 to 0.92665\nWatch your ids :)"}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.6.4"}},"nbformat":4,"nbformat_minor":1}