{"cells":[{"metadata":{"_cell_guid":"af0aab66-fb71-44fc-b80c-dd41050cdd2d","_uuid":"40833634550fe5318580f4a61b6c614c209ff271","collapsed":true},"cell_type":"markdown","source":"It looks like the training data has some peculiar behaviour. If the ip, device and os fields are plotted for each click against the corresponding time, you can see that new ips, device and os ids appear every 24 hours or so.\nThe download clicks are not distributed uniformly over these new values. "},{"metadata":{"_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_kg_hide-input":false,"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","trusted":true},"cell_type":"code","source":"import pandas as pd\nimport time\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nsample_data = pd.read_csv( '../input/train_sample.csv' )\n\nsample_data[ 'click_time' ] = pd.to_datetime( sample_data[ 'click_time' ] )\n\nclicktime = np.array( [ t.timestamp() for t in sample_data[ 'click_time' ] ] )\nclicktime -= np.min( clicktime )\n\nsample_data[ 'time' ] = clicktime.astype( int )\n\nsample_data.sort_values( by = [ 'time' ], inplace = True )\nsample_data.reset_index( drop = True, inplace = True )\n\nidx_download = sample_data.index[ sample_data[ 'is_attributed' ] == 1 ]\n\ndef plot_attribute_vs_time( sdata, idx, attr_name ):\n    plt.figure(figsize=(16, 12))\n    plt.plot( sdata[ 'time' ] / 3600, sdata[ attr_name ], 'b.', alpha = 0.1, label = 'is_attributed = 0' )\n    plt.plot( sdata[ 'time' ][idx] / 3600, sdata[ attr_name ][idx], 'ro', alpha = 0.6, label = 'is_attributed = 1' )\n    plt.xlabel( 'Time [hours]', fontsize = 16 )\n    plt.ylabel( attr_name, fontsize = 16 )\n    leg  = plt.legend( fontsize = 16 )\n    for l in leg.get_lines():\n        l.set_alpha( 1 )\n        l.set_marker( '.' )\n    plt.show()\n\nplot_attribute_vs_time( sample_data, idx_download, 'ip' )\nplot_attribute_vs_time( sample_data, idx_download, 'device' )\nplot_attribute_vs_time( sample_data, idx_download, 'os' )\n","execution_count":7,"outputs":[]},{"metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","collapsed":true,"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.4","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}