{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nimport os","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-09-07T05:34:46.911785Z","iopub.execute_input":"2023-09-07T05:34:46.912152Z","iopub.status.idle":"2023-09-07T05:34:46.918235Z","shell.execute_reply.started":"2023-09-07T05:34:46.912122Z","shell.execute_reply":"2023-09-07T05:34:46.916792Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"BASE = \"data/\" if \"data\" in os.listdir(\"./\") else \"/kaggle/input/child-mind-institute-detect-sleep-states/\"\n\n# only reads test data\nte = pd.read_parquet(BASE+\"/test_series.parquet\")\n\n# set baseline hours for sleeping and waking up\nonset = te[te[\"timestamp\"].str.slice(11,19)==\"23:00:00\"].set_index(\"series_id\")[\"step\"]\nwakeup = te[te[\"timestamp\"].str.slice(11,19)==\"06:30:00\"].set_index(\"series_id\")[\"step\"]","metadata":{"execution":{"iopub.status.busy":"2023-09-07T05:34:46.920491Z","iopub.execute_input":"2023-09-07T05:34:46.921075Z","iopub.status.idle":"2023-09-07T05:34:46.943580Z","shell.execute_reply.started":"2023-09-07T05:34:46.921002Z","shell.execute_reply":"2023-09-07T05:34:46.941686Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# prep sub\nsub = pd.concat([\n    onset.reset_index().assign(event=\"onset\"),\n    wakeup.reset_index().assign(event=\"wakeup\"),\n])\nsub[\"score\"] = 0.5\nsub.sort_values([\"series_id\",\"event\"], ascending=[0,1], inplace=True)\nsub.reset_index(drop=True, inplace=True)\nsub[\"row_id\"] = sub.index\nsub = sub[[\"row_id\",\"series_id\",\"step\",\"event\",\"score\"]]\nsub.to_csv(\"submission.csv\", index=False)","metadata":{"execution":{"iopub.status.busy":"2023-09-07T05:34:46.945347Z","iopub.execute_input":"2023-09-07T05:34:46.946018Z","iopub.status.idle":"2023-09-07T05:34:46.962169Z","shell.execute_reply.started":"2023-09-07T05:34:46.945987Z","shell.execute_reply":"2023-09-07T05:34:46.961125Z"},"trusted":true},"execution_count":null,"outputs":[]}],"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"}}