{"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 random","metadata":{"papermill":{"duration":0.023295,"end_time":"2022-06-03T21:13:10.412151","exception":false,"start_time":"2022-06-03T21:13:10.388856","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-05-07T20:50:26.606858Z","iopub.execute_input":"2023-05-07T20:50:26.607578Z","iopub.status.idle":"2023-05-07T20:50:26.632809Z","shell.execute_reply.started":"2023-05-07T20:50:26.607485Z","shell.execute_reply":"2023-05-07T20:50:26.631999Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import jo_wilder\nenv = jo_wilder.make_env()\niter_test = env.iter_test()","metadata":{"papermill":{"duration":0.036198,"end_time":"2022-06-03T21:13:10.454318","exception":false,"start_time":"2022-06-03T21:13:10.41812","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-05-07T20:50:26.647371Z","iopub.execute_input":"2023-05-07T20:50:26.649427Z","iopub.status.idle":"2023-05-07T20:50:26.678128Z","shell.execute_reply.started":"2023-05-07T20:50:26.649393Z","shell.execute_reply":"2023-05-07T20:50:26.677314Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Define which questions to predict for each level_group (key=level_group, values=questions)\nlimits = {'0-4':(1,4), '5-12':(4,14), '13-22':(14,19)}\n\nfor (test, sample_submission) in iter_test:\n    \n    # Creates a column 'question' that only contains the question number\n    sample_submission['question'] = [int(label.split('_')[1][1:]) for label in sample_submission['session_id']]\n    \n    # finds which level_group to predict at this iteration (they all all the same so I use [0] to get the first)\n    level_group_to_predict = test[\"level_group\"].values[0]\n    \n    # set the limits (range of questions to predict) based on level_group\n    a,b = limits[level_group_to_predict]\n    \n    for quest_nr in range(a,b):\n        sample_submission.loc[sample_submission.question == quest_nr, 'correct'] = 1\n        \n    env.predict(sample_submission[['session_id', 'correct']])","metadata":{"papermill":{"duration":0.337707,"end_time":"2022-06-03T21:13:10.798069","exception":false,"start_time":"2022-06-03T21:13:10.460362","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-05-07T20:50:26.682045Z","iopub.execute_input":"2023-05-07T20:50:26.682653Z","iopub.status.idle":"2023-05-07T20:50:26.784619Z","shell.execute_reply.started":"2023-05-07T20:50:26.682620Z","shell.execute_reply":"2023-05-07T20:50:26.783761Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"! head submission.csv","metadata":{"execution":{"iopub.status.busy":"2023-05-07T20:50:26.785883Z","iopub.execute_input":"2023-05-07T20:50:26.786600Z","iopub.status.idle":"2023-05-07T20:50:27.817395Z","shell.execute_reply.started":"2023-05-07T20:50:26.786567Z","shell.execute_reply":"2023-05-07T20:50:27.816278Z"},"trusted":true},"execution_count":null,"outputs":[]}]}