{"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-04-23T15:22:25.998012Z","iopub.execute_input":"2023-04-23T15:22:25.998685Z","iopub.status.idle":"2023-04-23T15:22:26.028420Z","shell.execute_reply.started":"2023-04-23T15:22:25.998592Z","shell.execute_reply":"2023-04-23T15:22:26.027278Z"},"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-04-23T15:22:26.030087Z","iopub.execute_input":"2023-04-23T15:22:26.030673Z","iopub.status.idle":"2023-04-23T15:22:26.054148Z","shell.execute_reply.started":"2023-04-23T15:22:26.030645Z","shell.execute_reply":"2023-04-23T15:22:26.053127Z"},"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-04-23T15:22:26.055462Z","iopub.execute_input":"2023-04-23T15:22:26.055752Z","iopub.status.idle":"2023-04-23T15:22:26.153383Z","shell.execute_reply.started":"2023-04-23T15:22:26.055728Z","shell.execute_reply":"2023-04-23T15:22:26.152318Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"! head submission.csv","metadata":{"execution":{"iopub.status.busy":"2023-04-23T15:22:26.156483Z","iopub.execute_input":"2023-04-23T15:22:26.156743Z","iopub.status.idle":"2023-04-23T15:22:26.438290Z","shell.execute_reply.started":"2023-04-23T15:22:26.156721Z","shell.execute_reply":"2023-04-23T15:22:26.437435Z"},"trusted":true},"execution_count":null,"outputs":[]}]}