{"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":"code","source":"import numpy as np\nimport pandas as pd\nimport os\nfrom PIL import Image\nimport matplotlib.pyplot as plt\nfrom tqdm import tqdm","metadata":{"_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","papermill":{"duration":6.709787,"end_time":"2021-07-03T10:42:30.513089","exception":false,"start_time":"2021-07-03T10:42:23.803302","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-07-06T09:47:03.845664Z","iopub.execute_input":"2021-07-06T09:47:03.846223Z","iopub.status.idle":"2021-07-06T09:47:03.852196Z","shell.execute_reply.started":"2021-07-06T09:47:03.846169Z","shell.execute_reply":"2021-07-06T09:47:03.851062Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Data preparation","metadata":{}},{"cell_type":"code","source":"trainpaths=[]\nfor dirname, _, filenames in os.walk('../input/g2net-gravitational-wave-detection/train'):\n    for filename in filenames:\n        trainpaths+=[(os.path.join(dirname, filename))]","metadata":{"papermill":{"duration":90.848252,"end_time":"2021-07-03T10:44:01.386088","exception":false,"start_time":"2021-07-03T10:42:30.537836","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-07-06T09:47:03.854323Z","iopub.execute_input":"2021-07-06T09:47:03.855052Z","iopub.status.idle":"2021-07-06T09:47:08.635896Z","shell.execute_reply.started":"2021-07-06T09:47:03.855000Z","shell.execute_reply":"2021-07-06T09:47:08.635038Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(len(trainpaths))\nsorted(trainpaths)[0:5]","metadata":{"papermill":{"duration":0.177356,"end_time":"2021-07-03T10:44:01.58881","exception":false,"start_time":"2021-07-03T10:44:01.411454","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-07-06T09:47:08.637667Z","iopub.execute_input":"2021-07-06T09:47:08.638265Z","iopub.status.idle":"2021-07-06T09:47:08.777320Z","shell.execute_reply.started":"2021-07-06T09:47:08.638218Z","shell.execute_reply":"2021-07-06T09:47:08.776552Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Data visualize","metadata":{}},{"cell_type":"code","source":"# fig of original data\naa=np.load(trainpaths[2])\nfigure,axis = plt.subplots(1,3,figsize=(18,5),)\naxis[0].set_title(\"original0\")\naxis[0].set_xlabel(aa[0].shape)\naxis[0].set_ylabel(aa[0].size)\naxis[0].plot(aa[0],c=\"g\")\naxis[1].set_title(\"original1\")\naxis[1].set_xlabel(aa[1].shape)\naxis[1].set_ylabel(aa[1].size)\naxis[1].plot(aa[1],c=\"g\")\naxis[2].set_title(\"original2\")\naxis[2].set_xlabel(aa[2].shape)\naxis[2].set_ylabel(aa[2].size)\naxis[2].plot(aa[2],c=\"g\")","metadata":{"papermill":{"duration":0.764048,"end_time":"2021-07-03T10:44:45.356217","exception":false,"start_time":"2021-07-03T10:44:44.592169","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-07-06T09:47:08.778567Z","iopub.execute_input":"2021-07-06T09:47:08.778977Z","iopub.status.idle":"2021-07-06T09:47:09.234988Z","shell.execute_reply.started":"2021-07-06T09:47:08.778947Z","shell.execute_reply":"2021-07-06T09:47:09.234256Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# fig of lighteded data\naa1=np.zeros((3,128))\nfor i in range(0,32*128,32):\n    aa1[:,i//32]+=aa[:,i]\nfigure,axis = plt.subplots(1,3,figsize=(18,5),)\naxis[0].set_title(\"lightened 0\")\naxis[0].set_xlabel(aa1[0].shape)\naxis[0].set_ylabel(aa1[0].size)\naxis[0].plot(aa1[0],c=\"g\")\naxis[1].set_title(\"lightend 1\")\naxis[1].set_xlabel(aa1[1].shape)\naxis[1].set_ylabel(aa1[1].size)\naxis[1].plot(aa1[1],c=\"g\")\naxis[2].set_title(\"lightend 2\")\naxis[2].set_xlabel(aa1[2].shape)\naxis[2].set_ylabel(aa1[2].size)\naxis[2].plot(aa1[2],c=\"g\")","metadata":{"execution":{"iopub.status.busy":"2021-07-06T09:47:09.235931Z","iopub.execute_input":"2021-07-06T09:47:09.236204Z","iopub.status.idle":"2021-07-06T09:47:09.644118Z","shell.execute_reply.started":"2021-07-06T09:47:09.236178Z","shell.execute_reply":"2021-07-06T09:47:09.643478Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"aa1t=pd.DataFrame(aa1).T\naa1t","metadata":{"execution":{"iopub.status.busy":"2021-07-06T09:47:09.645201Z","iopub.execute_input":"2021-07-06T09:47:09.645645Z","iopub.status.idle":"2021-07-06T09:47:09.672179Z","shell.execute_reply.started":"2021-07-06T09:47:09.645597Z","shell.execute_reply":"2021-07-06T09:47:09.671242Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"aa1t=pd.DataFrame(aa1).T\naa1t['0 max']=aa1t.loc[:,0].rolling(window=8).max()\naa1t['1 max']=aa1t.loc[:,1].rolling(window=8).max()\naa1t['2 max']=aa1t.loc[:,2].rolling(window=8).max()\naa1t","metadata":{"execution":{"iopub.status.busy":"2021-07-06T09:47:09.674155Z","iopub.execute_input":"2021-07-06T09:47:09.674469Z","iopub.status.idle":"2021-07-06T09:47:09.715844Z","shell.execute_reply.started":"2021-07-06T09:47:09.674441Z","shell.execute_reply":"2021-07-06T09:47:09.714869Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# fig of rolling max data\naa2=np.array(aa1t.T)\nfigure,axis = plt.subplots(1,3,figsize=(18,5),)\naxis[0].set_title(\"rolling max 0\")\naxis[0].set_xlabel(aa2[0].shape)\naxis[0].set_ylabel(aa2[0].size)\naxis[0].plot(aa2[3],c=\"g\")\naxis[1].set_title(\"rolling max 1\")\naxis[1].set_xlabel(aa2[0].shape)\naxis[1].set_ylabel(aa2[0].size)\naxis[1].plot(aa2[4],c=\"g\")\naxis[2].set_title(\"rolling max 2\")\naxis[2].set_xlabel(aa2[0].shape)\naxis[2].set_ylabel(aa2[0].size)\naxis[2].plot(aa2[5],c=\"g\")","metadata":{"execution":{"iopub.status.busy":"2021-07-06T09:47:09.717126Z","iopub.execute_input":"2021-07-06T09:47:09.717445Z","iopub.status.idle":"2021-07-06T09:47:10.117855Z","shell.execute_reply.started":"2021-07-06T09:47:09.717415Z","shell.execute_reply":"2021-07-06T09:47:10.117078Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}