{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.11.11","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":39763,"databundleVersionId":11756775,"sourceType":"competition"},{"sourceId":247897800,"sourceType":"kernelVersion"},{"sourceId":248122901,"sourceType":"kernelVersion"},{"sourceId":248155489,"sourceType":"kernelVersion"}],"dockerImageVersionId":31040,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport pickle\nimport matplotlib.pyplot as plt\nimport pickle","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2025-06-29T22:17:52.377032Z","iopub.execute_input":"2025-06-29T22:17:52.377338Z","iopub.status.idle":"2025-06-29T22:17:55.074595Z","shell.execute_reply.started":"2025-06-29T22:17:52.37731Z","shell.execute_reply":"2025-06-29T22:17:55.073741Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"val_labels = pickle.load(open('/kaggle/input/gwi-preds-37-52-ds-to-notebook/val_labels.p', 'br'))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-29T22:17:55.075393Z","iopub.execute_input":"2025-06-29T22:17:55.075828Z","iopub.status.idle":"2025-06-29T22:17:56.075291Z","shell.execute_reply.started":"2025-06-29T22:17:55.0758Z","shell.execute_reply":"2025-06-29T22:17:56.074346Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"val_1 = pickle.load(open('/kaggle/input/gwi-ensemble-flip-noflip-style/val_ensemble.p', 'br'))\nval_2 = pickle.load(open('/kaggle/input/gwi-ensemble-flip-noflip-style-best/val_ensemble.p', 'br'))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-29T22:17:56.077956Z","iopub.execute_input":"2025-06-29T22:17:56.078931Z","iopub.status.idle":"2025-06-29T22:17:58.382857Z","shell.execute_reply.started":"2025-06-29T22:17:56.078893Z","shell.execute_reply":"2025-06-29T22:17:58.382033Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ensemble = (6*val_1+4*val_2)/(6+4)\nsub_dataset_scores = []\nfor i in range(10):\n    score = np.mean(np.abs(ensemble-val_labels)[i*1000:(i+1)*1000])\n    print(score)\n    sub_dataset_scores.append(score)\nprint(np.mean(sub_dataset_scores))\nweighted_score = (np.sum(sub_dataset_scores[:4])*3+\n                  np.sum(sub_dataset_scores[4:8])*5.4+\n                  np.sum(sub_dataset_scores[8:10])*6.7)/(4*3+4*5.4+2*6.7)\nprint(weighted_score)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-29T22:19:11.932552Z","iopub.execute_input":"2025-06-29T22:19:11.932899Z","iopub.status.idle":"2025-06-29T22:19:12.944139Z","shell.execute_reply.started":"2025-06-29T22:19:11.932876Z","shell.execute_reply":"2025-06-29T22:19:12.942286Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"pickle.dump(ensemble, open('val_ensemble.p', 'bw'))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-29T22:17:59.57168Z","iopub.execute_input":"2025-06-29T22:17:59.571907Z","iopub.status.idle":"2025-06-29T22:17:59.902542Z","shell.execute_reply.started":"2025-06-29T22:17:59.571888Z","shell.execute_reply":"2025-06-29T22:17:59.901635Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_1 = pickle.load(open('/kaggle/input/gwi-ensemble-flip-noflip-style/test_ensemble.p', 'br'))\ntest_2 = pickle.load(open('/kaggle/input/gwi-ensemble-flip-noflip-style-best/test_ensemble.p', 'br'))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-29T22:17:59.903505Z","iopub.execute_input":"2025-06-29T22:17:59.903806Z","iopub.status.idle":"2025-06-29T22:18:12.435538Z","shell.execute_reply.started":"2025-06-29T22:17:59.903781Z","shell.execute_reply":"2025-06-29T22:18:12.434587Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test = (6*test_1+4*test_2)/(6+4)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-29T22:18:17.527931Z","iopub.execute_input":"2025-06-29T22:18:17.528331Z","iopub.status.idle":"2025-06-29T22:18:18.739993Z","shell.execute_reply.started":"2025-06-29T22:18:17.528304Z","shell.execute_reply":"2025-06-29T22:18:18.739134Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.imshow(test[0])","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-29T22:18:12.446008Z","iopub.status.idle":"2025-06-29T22:18:12.446418Z","shell.execute_reply.started":"2025-06-29T22:18:12.446208Z","shell.execute_reply":"2025-06-29T22:18:12.446242Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"sample_submission = pd.read_csv('/kaggle/input/waveform-inversion/sample_submission.csv')\nsample_submission.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-29T22:18:12.448099Z","iopub.status.idle":"2025-06-29T22:18:12.448509Z","shell.execute_reply.started":"2025-06-29T22:18:12.448323Z","shell.execute_reply":"2025-06-29T22:18:12.448341Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"all_preds = np.zeros((4607260,35))\nbatch_size = 128\nx_odds = np.asarray(range(1,71,2))\nfor i in range(65818//batch_size+1):\n    preds = test[i*batch_size:(i+1)*batch_size]\n    preds = preds*100+3000\n    all_preds[i*70*batch_size:(i+1)*70*batch_size] = np.reshape(np.asarray(preds)[:, :, x_odds], [-1,35])\npickle.dump(test, open('test_ensemble.p', 'bw'))\nsample_submission.iloc[:, -35:] = all_preds\nsample_submission.to_parquet('submission.parquet', index=False)\nsubmission = pd.read_parquet('/kaggle/working/submission.parquet')\nplt.imshow(np.asarray(submission[:70])[:, 1:].astype(float))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-29T22:18:12.450208Z","iopub.status.idle":"2025-06-29T22:18:12.450625Z","shell.execute_reply.started":"2025-06-29T22:18:12.450423Z","shell.execute_reply":"2025-06-29T22:18:12.45044Z"}},"outputs":[],"execution_count":null}]}