{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.7.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":45533,"databundleVersionId":5748852,"sourceType":"competition"},{"sourceId":7529065,"sourceType":"datasetVersion","datasetId":4385274}],"dockerImageVersionId":30396,"isInternetEnabled":false,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import os\nimport gc\nimport sys\nimport numpy as np\nimport pandas as pd\nimport polars as pl\nimport xgboost as xgb\nfrom xgboost import XGBClassifier\nfrom collections import defaultdict\n\nimport warnings\nwarnings.filterwarnings('ignore')","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2024-02-01T10:27:17.397997Z","iopub.execute_input":"2024-02-01T10:27:17.398766Z","iopub.status.idle":"2024-02-01T10:27:20.1883Z","shell.execute_reply.started":"2024-02-01T10:27:17.398625Z","shell.execute_reply":"2024-02-01T10:27:20.186948Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"CATS = ['event_name', 'name', 'fqid', 'room_fqid', 'text_fqid']\nNUMS = ['page', 'room_coor_x', 'room_coor_y', 'screen_coor_x', 'screen_coor_y',\n                              'hover_duration', 'elapsed_time_diff', \"total_coor\"]\n\nfqid_lists = ['worker', 'archivist', 'gramps', 'wells', 'toentry', 'confrontation', 'crane_ranger', 'groupconvo', 'flag_girl', 'tomap', 'tostacks', 'tobasement', 'archivist_glasses', 'boss', 'journals', 'seescratches', 'groupconvo_flag', 'cs', 'teddy', 'expert', 'businesscards', 'ch3start', 'tunic.historicalsociety', 'tofrontdesk', 'savedteddy', 'plaque', 'glasses', 'tunic.drycleaner', 'reader_flag', 'tunic.library', 'tracks', 'tunic.capitol_2', 'trigger_scarf', 'reader', 'directory', 'tunic.capitol_1', 'journals.pic_0.next', 'unlockdoor', 'tunic', 'what_happened', 'tunic.kohlcenter', 'tunic.humanecology', 'colorbook', 'logbook', 'businesscards.card_0.next', 'journals.hub.topics', 'logbook.page.bingo', 'journals.pic_1.next', 'journals_flag', 'reader.paper0.next', 'tracks.hub.deer', 'reader_flag.paper0.next', 'trigger_coffee', 'wellsbadge', 'journals.pic_2.next', 'tomicrofiche', 'journals_flag.pic_0.bingo', 'plaque.face.date', 'notebook', 'tocloset_dirty', 'businesscards.card_bingo.bingo', 'businesscards.card_1.next', 'tunic.wildlife', 'tunic.hub.slip', 'tocage', 'journals.pic_2.bingo', 'tocollectionflag', 'tocollection', 'chap4_finale_c', 'chap2_finale_c', 'lockeddoor', 'journals_flag.hub.topics', 'tunic.capitol_0', 'reader_flag.paper2.bingo', 'photo', 'tunic.flaghouse', 'reader.paper1.next', 'directory.closeup.archivist', 'intro', 'businesscards.card_bingo.next', 'reader.paper2.bingo', 'retirement_letter', 'remove_cup', 'journals_flag.pic_0.next', 'magnify', 'coffee', 'key', 'togrampa', 'reader_flag.paper1.next', 'janitor', 'tohallway', 'chap1_finale', 'report', 'outtolunch', 'journals_flag.hub.topics_old', 'journals_flag.pic_1.next', 'reader.paper2.next', 'chap1_finale_c', 'reader_flag.paper2.next', 'door_block_talk', 'journals_flag.pic_1.bingo', 'journals_flag.pic_2.next', 'journals_flag.pic_2.bingo', 'block_magnify', 'reader.paper0.prev', 'block', 'reader_flag.paper0.prev', 'block_0', 'door_block_clean', 'reader.paper2.prev', 'reader.paper1.prev', 'doorblock', 'tocloset', 'reader_flag.paper2.prev', 'reader_flag.paper1.prev', 'block_tomap2', 'journals_flag.pic_0_old.next', 'journals_flag.pic_1_old.next', 'block_tocollection', 'block_nelson', 'journals_flag.pic_2_old.next', 'block_tomap1', 'block_badge', 'need_glasses', 'block_badge_2', 'fox', 'block_1']\n\nDIALOGS = ['that', 'this', 'it', 'you','find','found','Found','notebook','Wells','wells','help','need', 'Oh','Ooh','Jo', 'flag', 'can','and','is','the','to']\n\nname_feature = ['basic', 'undefined', 'close', 'open', 'prev', 'next']\n\nevent_name_feature = ['cutscene_click', 'person_click', 'navigate_click',\n                                           'observation_click', 'notification_click', 'object_click',\n                                           'object_hover', 'map_hover', 'map_click', 'checkpoint',\n                                           'notebook_click']\n\ntext_lists = ['tunic.historicalsociety.cage.confrontation', 'tunic.wildlife.center.crane_ranger.crane', 'tunic.historicalsociety.frontdesk.archivist.newspaper', 'tunic.historicalsociety.entry.groupconvo', 'tunic.wildlife.center.wells.nodeer', 'tunic.historicalsociety.frontdesk.archivist.have_glass', 'tunic.drycleaner.frontdesk.worker.hub', 'tunic.historicalsociety.closet_dirty.gramps.news', 'tunic.humanecology.frontdesk.worker.intro', 'tunic.historicalsociety.frontdesk.archivist_glasses.confrontation', 'tunic.historicalsociety.basement.seescratches', 'tunic.historicalsociety.collection.cs', 'tunic.flaghouse.entry.flag_girl.hello', 'tunic.historicalsociety.collection.gramps.found', 'tunic.historicalsociety.basement.ch3start', 'tunic.historicalsociety.entry.groupconvo_flag', 'tunic.library.frontdesk.worker.hello', 'tunic.library.frontdesk.worker.wells', 'tunic.historicalsociety.collection_flag.gramps.flag', 'tunic.historicalsociety.basement.savedteddy', 'tunic.library.frontdesk.worker.nelson', 'tunic.wildlife.center.expert.removed_cup', 'tunic.library.frontdesk.worker.flag', 'tunic.historicalsociety.frontdesk.archivist.hello', 'tunic.historicalsociety.closet.gramps.intro_0_cs_0', 'tunic.historicalsociety.entry.boss.flag', 'tunic.flaghouse.entry.flag_girl.symbol', 'tunic.historicalsociety.closet_dirty.trigger_scarf', 'tunic.drycleaner.frontdesk.worker.done', 'tunic.historicalsociety.closet_dirty.what_happened', 'tunic.wildlife.center.wells.animals', 'tunic.historicalsociety.closet.teddy.intro_0_cs_0', 'tunic.historicalsociety.cage.glasses.afterteddy', 'tunic.historicalsociety.cage.teddy.trapped', 'tunic.historicalsociety.cage.unlockdoor', 'tunic.historicalsociety.stacks.journals.pic_2.bingo', 'tunic.historicalsociety.entry.wells.flag', 'tunic.humanecology.frontdesk.worker.badger', 'tunic.historicalsociety.stacks.journals_flag.pic_0.bingo', 'tunic.historicalsociety.closet.intro', 'tunic.historicalsociety.closet.retirement_letter.hub', 'tunic.historicalsociety.entry.directory.closeup.archivist', 'tunic.historicalsociety.collection.tunic.slip', 'tunic.kohlcenter.halloffame.plaque.face.date', 'tunic.historicalsociety.closet_dirty.trigger_coffee', 'tunic.drycleaner.frontdesk.logbook.page.bingo', 'tunic.library.microfiche.reader.paper2.bingo', 'tunic.kohlcenter.halloffame.togrampa', 'tunic.capitol_2.hall.boss.haveyougotit', 'tunic.wildlife.center.wells.nodeer_recap', 'tunic.historicalsociety.cage.glasses.beforeteddy', 'tunic.historicalsociety.closet_dirty.gramps.helpclean', 'tunic.wildlife.center.expert.recap', 'tunic.historicalsociety.frontdesk.archivist.have_glass_recap', 'tunic.historicalsociety.stacks.journals_flag.pic_1.bingo', 'tunic.historicalsociety.cage.lockeddoor', 'tunic.historicalsociety.stacks.journals_flag.pic_2.bingo', 'tunic.historicalsociety.collection.gramps.lost', 'tunic.historicalsociety.closet.notebook', 'tunic.historicalsociety.frontdesk.magnify', 'tunic.humanecology.frontdesk.businesscards.card_bingo.bingo', 'tunic.wildlife.center.remove_cup', 'tunic.library.frontdesk.wellsbadge.hub', 'tunic.wildlife.center.tracks.hub.deer', 'tunic.historicalsociety.frontdesk.key', 'tunic.library.microfiche.reader_flag.paper2.bingo', 'tunic.flaghouse.entry.colorbook', 'tunic.wildlife.center.coffee', 'tunic.capitol_1.hall.boss.haveyougotit', 'tunic.historicalsociety.basement.janitor', 'tunic.historicalsociety.collection_flag.gramps.recap', 'tunic.wildlife.center.wells.animals2', 'tunic.flaghouse.entry.flag_girl.symbol_recap', 'tunic.historicalsociety.closet_dirty.photo', 'tunic.historicalsociety.stacks.outtolunch', 'tunic.library.frontdesk.worker.wells_recap', 'tunic.historicalsociety.frontdesk.archivist_glasses.confrontation_recap', 'tunic.capitol_0.hall.boss.talktogramps', 'tunic.historicalsociety.closet.photo', 'tunic.historicalsociety.collection.tunic', 'tunic.historicalsociety.closet.teddy.intro_0_cs_5', 'tunic.historicalsociety.closet_dirty.gramps.archivist', 'tunic.historicalsociety.closet_dirty.door_block_talk', 'tunic.historicalsociety.entry.boss.flag_recap', 'tunic.historicalsociety.frontdesk.archivist.need_glass_0', 'tunic.historicalsociety.entry.wells.talktogramps', 'tunic.historicalsociety.frontdesk.block_magnify', 'tunic.historicalsociety.frontdesk.archivist.foundtheodora', 'tunic.historicalsociety.closet_dirty.gramps.nothing', 'tunic.historicalsociety.closet_dirty.door_block_clean', 'tunic.capitol_1.hall.boss.writeitup', 'tunic.library.frontdesk.worker.nelson_recap', 'tunic.library.frontdesk.worker.hello_short', 'tunic.historicalsociety.stacks.block', 'tunic.historicalsociety.frontdesk.archivist.need_glass_1', 'tunic.historicalsociety.entry.boss.talktogramps', 'tunic.historicalsociety.frontdesk.archivist.newspaper_recap', 'tunic.historicalsociety.entry.wells.flag_recap', 'tunic.drycleaner.frontdesk.worker.done2', 'tunic.library.frontdesk.worker.flag_recap', 'tunic.humanecology.frontdesk.block_0', 'tunic.library.frontdesk.worker.preflag', 'tunic.historicalsociety.basement.gramps.seeyalater', 'tunic.flaghouse.entry.flag_girl.hello_recap', 'tunic.historicalsociety.closet.doorblock', 'tunic.drycleaner.frontdesk.worker.takealook', 'tunic.historicalsociety.basement.gramps.whatdo', 'tunic.library.frontdesk.worker.droppedbadge', 'tunic.historicalsociety.entry.block_tomap2', 'tunic.library.frontdesk.block_nelson', 'tunic.library.microfiche.block_0', 'tunic.historicalsociety.entry.block_tocollection', 'tunic.historicalsociety.entry.block_tomap1', 'tunic.historicalsociety.collection.gramps.look_0', 'tunic.library.frontdesk.block_badge', 'tunic.historicalsociety.cage.need_glasses', 'tunic.library.frontdesk.block_badge_2', 'tunic.kohlcenter.halloffame.block_0', 'tunic.capitol_0.hall.chap1_finale_c', 'tunic.capitol_1.hall.chap2_finale_c', 'tunic.capitol_2.hall.chap4_finale_c', 'tunic.wildlife.center.fox.concern', 'tunic.drycleaner.frontdesk.block_0', 'tunic.historicalsociety.entry.gramps.hub', 'tunic.humanecology.frontdesk.block_1', 'tunic.drycleaner.frontdesk.block_1']\nroom_lists = ['tunic.historicalsociety.entry', 'tunic.wildlife.center', 'tunic.historicalsociety.cage', 'tunic.library.frontdesk', 'tunic.historicalsociety.frontdesk', 'tunic.historicalsociety.stacks', 'tunic.historicalsociety.closet_dirty', 'tunic.humanecology.frontdesk', 'tunic.historicalsociety.basement', 'tunic.kohlcenter.halloffame', 'tunic.library.microfiche', 'tunic.drycleaner.frontdesk', 'tunic.historicalsociety.collection', 'tunic.historicalsociety.closet', 'tunic.flaghouse.entry', 'tunic.historicalsociety.collection_flag', 'tunic.capitol_1.hall', 'tunic.capitol_0.hall', 'tunic.capitol_2.hall']\n\nday_lists = [3, 0, 1, 2, 4, 5, 6]\n\nFEATURES_name_dict = {}\n\nFEATURES_name_dict['LEVELS_1'] = [1, 2, 3, 4]\nFEATURES_name_dict['LEVELS_2'] = [5, 6, 7, 8, 9, 10, 11, 12]\nFEATURES_name_dict['LEVELS_3'] = [13, 14, 15, 16, 17, 18, 19, 20, 21, 22]\n\nFEATURES_name_dict['level_groups_1'] = [\"0-4\"]\nFEATURES_name_dict['level_groups_2'] = [\"5-12\"]\nFEATURES_name_dict['level_groups_3'] = [\"13-22\"]\nFEATURES_name_dict['day_lists'] = [3, 0, 1, 2, 4, 5, 6]\n\nFEATURES_name_dict['fqid_list_1'] = ['gramps',\n 'wells',\n 'toentry',\n 'groupconvo',\n 'tomap',\n 'tostacks',\n 'tobasement',\n 'boss',\n 'cs',\n 'teddy',\n 'tunic.historicalsociety',\n 'plaque',\n 'directory',\n 'tunic',\n 'tunic.kohlcenter',\n 'plaque.face.date',\n 'notebook',\n 'tunic.hub.slip',\n 'tocollection',\n 'tunic.capitol_0',\n 'photo',\n 'intro',\n 'retirement_letter',\n 'togrampa',\n 'janitor',\n 'chap1_finale',\n 'report',\n 'outtolunch',\n 'chap1_finale_c',\n 'block_0',\n 'doorblock',\n 'tocloset',\n 'block_tomap2',\n 'block_tocollection',\n 'block_tomap1']\n\nFEATURES_name_dict['fqid_list_2'] = ['worker',\n 'archivist',\n 'gramps',\n 'toentry',\n 'tomap',\n 'tostacks',\n 'tobasement',\n 'boss',\n 'journals',\n 'businesscards',\n 'tunic.historicalsociety',\n 'tofrontdesk',\n 'plaque',\n 'tunic.drycleaner',\n 'tunic.library',\n 'trigger_scarf',\n 'reader',\n 'directory',\n 'tunic.capitol_1',\n 'journals.pic_0.next',\n 'tunic',\n 'what_happened',\n 'tunic.kohlcenter',\n 'tunic.humanecology',\n 'logbook',\n 'businesscards.card_0.next',\n 'journals.hub.topics',\n 'logbook.page.bingo',\n 'journals.pic_1.next',\n 'reader.paper0.next',\n 'trigger_coffee',\n 'wellsbadge',\n 'journals.pic_2.next',\n 'tomicrofiche',\n 'tocloset_dirty',\n 'businesscards.card_bingo.bingo',\n 'businesscards.card_1.next',\n 'tunic.hub.slip',\n 'journals.pic_2.bingo',\n 'tocollection',\n 'chap2_finale_c',\n 'tunic.capitol_0',\n 'photo',\n 'reader.paper1.next',\n 'businesscards.card_bingo.next',\n 'reader.paper2.bingo',\n 'magnify',\n 'janitor',\n 'tohallway',\n 'outtolunch',\n 'reader.paper2.next',\n 'door_block_talk',\n 'block_magnify',\n 'reader.paper0.prev',\n 'block',\n 'block_0',\n 'door_block_clean',\n 'reader.paper2.prev',\n 'reader.paper1.prev',\n 'block_badge',\n 'block_badge_2',\n 'block_1']\n\nFEATURES_name_dict['fqid_list_3'] = ['worker',\n 'gramps',\n 'wells',\n 'toentry',\n 'confrontation',\n 'crane_ranger',\n 'flag_girl',\n 'tomap',\n 'tostacks',\n 'tobasement',\n 'archivist_glasses',\n 'boss',\n 'journals',\n 'seescratches',\n 'groupconvo_flag',\n 'teddy',\n 'expert',\n 'businesscards',\n 'ch3start',\n 'tunic.historicalsociety',\n 'tofrontdesk',\n 'savedteddy',\n 'plaque',\n 'glasses',\n 'tunic.drycleaner',\n 'reader_flag',\n 'tunic.library',\n 'tracks',\n 'tunic.capitol_2',\n 'reader',\n 'directory',\n 'tunic.capitol_1',\n 'journals.pic_0.next',\n 'unlockdoor',\n 'tunic',\n 'tunic.kohlcenter',\n 'tunic.humanecology',\n 'colorbook',\n 'logbook',\n 'businesscards.card_0.next',\n 'journals.hub.topics',\n 'journals.pic_1.next',\n 'journals_flag',\n 'reader.paper0.next',\n 'tracks.hub.deer',\n 'reader_flag.paper0.next',\n 'journals.pic_2.next',\n 'tomicrofiche',\n 'journals_flag.pic_0.bingo',\n 'tocloset_dirty',\n 'businesscards.card_1.next',\n 'tunic.wildlife',\n 'tunic.hub.slip',\n 'tocage',\n 'journals.pic_2.bingo',\n 'tocollectionflag',\n 'tocollection',\n 'chap4_finale_c',\n 'lockeddoor',\n 'journals_flag.hub.topics',\n 'reader_flag.paper2.bingo',\n 'photo',\n 'tunic.flaghouse',\n 'reader.paper1.next',\n 'directory.closeup.archivist',\n 'businesscards.card_bingo.next',\n 'remove_cup',\n 'journals_flag.pic_0.next',\n 'coffee',\n 'key',\n 'reader_flag.paper1.next',\n 'tohallway',\n 'outtolunch',\n 'journals_flag.hub.topics_old',\n 'journals_flag.pic_1.next',\n 'reader.paper2.next',\n 'reader_flag.paper2.next',\n 'journals_flag.pic_1.bingo',\n 'journals_flag.pic_2.next',\n 'journals_flag.pic_2.bingo',\n 'reader.paper0.prev',\n 'reader_flag.paper0.prev',\n 'reader.paper2.prev',\n 'reader.paper1.prev',\n 'reader_flag.paper2.prev',\n 'reader_flag.paper1.prev',\n 'journals_flag.pic_0_old.next',\n 'journals_flag.pic_1_old.next',\n 'block_nelson',\n 'journals_flag.pic_2_old.next',\n 'need_glasses',\n 'fox']\n\nFEATURES_name_dict['text_list_1'] = ['tunic.historicalsociety.entry.groupconvo',\n 'tunic.historicalsociety.collection.cs',\n 'tunic.historicalsociety.collection.gramps.found',\n 'tunic.historicalsociety.closet.gramps.intro_0_cs_0',\n 'tunic.historicalsociety.closet.teddy.intro_0_cs_0',\n 'tunic.historicalsociety.closet.intro',\n 'tunic.historicalsociety.closet.retirement_letter.hub',\n 'tunic.historicalsociety.collection.tunic.slip',\n 'tunic.kohlcenter.halloffame.plaque.face.date',\n 'tunic.kohlcenter.halloffame.togrampa',\n 'tunic.historicalsociety.collection.gramps.lost',\n 'tunic.historicalsociety.closet.notebook',\n 'tunic.historicalsociety.basement.janitor',\n 'tunic.historicalsociety.stacks.outtolunch',\n 'tunic.historicalsociety.closet.photo',\n 'tunic.historicalsociety.collection.tunic',\n 'tunic.historicalsociety.closet.teddy.intro_0_cs_5',\n 'tunic.historicalsociety.entry.wells.talktogramps',\n 'tunic.historicalsociety.entry.boss.talktogramps',\n 'tunic.historicalsociety.closet.doorblock',\n 'tunic.historicalsociety.entry.block_tomap2',\n 'tunic.historicalsociety.entry.block_tocollection',\n 'tunic.historicalsociety.entry.block_tomap1',\n 'tunic.historicalsociety.collection.gramps.look_0',\n 'tunic.kohlcenter.halloffame.block_0',\n 'tunic.capitol_0.hall.chap1_finale_c',\n 'tunic.historicalsociety.entry.gramps.hub']\n\nFEATURES_name_dict['text_list_2'] = ['tunic.historicalsociety.frontdesk.archivist.newspaper',\n 'tunic.historicalsociety.frontdesk.archivist.have_glass',\n 'tunic.drycleaner.frontdesk.worker.hub',\n 'tunic.historicalsociety.closet_dirty.gramps.news',\n 'tunic.humanecology.frontdesk.worker.intro',\n 'tunic.library.frontdesk.worker.hello',\n 'tunic.library.frontdesk.worker.wells',\n 'tunic.historicalsociety.frontdesk.archivist.hello',\n 'tunic.historicalsociety.closet_dirty.trigger_scarf',\n 'tunic.drycleaner.frontdesk.worker.done',\n 'tunic.historicalsociety.closet_dirty.what_happened',\n 'tunic.historicalsociety.stacks.journals.pic_2.bingo',\n 'tunic.humanecology.frontdesk.worker.badger',\n 'tunic.historicalsociety.closet_dirty.trigger_coffee',\n 'tunic.drycleaner.frontdesk.logbook.page.bingo',\n 'tunic.library.microfiche.reader.paper2.bingo',\n 'tunic.historicalsociety.closet_dirty.gramps.helpclean',\n 'tunic.historicalsociety.frontdesk.archivist.have_glass_recap',\n 'tunic.historicalsociety.frontdesk.magnify',\n 'tunic.humanecology.frontdesk.businesscards.card_bingo.bingo',\n 'tunic.library.frontdesk.wellsbadge.hub',\n 'tunic.capitol_1.hall.boss.haveyougotit',\n 'tunic.historicalsociety.basement.janitor',\n 'tunic.historicalsociety.closet_dirty.photo',\n 'tunic.historicalsociety.stacks.outtolunch',\n 'tunic.library.frontdesk.worker.wells_recap',\n 'tunic.capitol_0.hall.boss.talktogramps',\n 'tunic.historicalsociety.closet_dirty.gramps.archivist',\n 'tunic.historicalsociety.closet_dirty.door_block_talk',\n 'tunic.historicalsociety.frontdesk.archivist.need_glass_0',\n 'tunic.historicalsociety.frontdesk.block_magnify',\n 'tunic.historicalsociety.frontdesk.archivist.foundtheodora',\n 'tunic.historicalsociety.closet_dirty.gramps.nothing',\n 'tunic.historicalsociety.closet_dirty.door_block_clean',\n 'tunic.library.frontdesk.worker.hello_short',\n 'tunic.historicalsociety.stacks.block',\n 'tunic.historicalsociety.frontdesk.archivist.need_glass_1',\n 'tunic.historicalsociety.frontdesk.archivist.newspaper_recap',\n 'tunic.drycleaner.frontdesk.worker.done2',\n 'tunic.humanecology.frontdesk.block_0',\n 'tunic.library.frontdesk.worker.preflag',\n 'tunic.drycleaner.frontdesk.worker.takealook',\n 'tunic.library.frontdesk.worker.droppedbadge',\n 'tunic.library.microfiche.block_0',\n 'tunic.library.frontdesk.block_badge',\n 'tunic.library.frontdesk.block_badge_2',\n 'tunic.capitol_1.hall.chap2_finale_c',\n 'tunic.drycleaner.frontdesk.block_0',\n 'tunic.humanecology.frontdesk.block_1',\n 'tunic.drycleaner.frontdesk.block_1']\n\nFEATURES_name_dict['text_list_3'] = ['tunic.historicalsociety.cage.confrontation',\n 'tunic.wildlife.center.crane_ranger.crane',\n 'tunic.wildlife.center.wells.nodeer',\n 'tunic.historicalsociety.frontdesk.archivist_glasses.confrontation',\n 'tunic.historicalsociety.basement.seescratches',\n 'tunic.flaghouse.entry.flag_girl.hello',\n 'tunic.historicalsociety.basement.ch3start',\n 'tunic.historicalsociety.entry.groupconvo_flag',\n 'tunic.historicalsociety.collection_flag.gramps.flag',\n 'tunic.historicalsociety.basement.savedteddy',\n 'tunic.library.frontdesk.worker.nelson',\n 'tunic.wildlife.center.expert.removed_cup',\n 'tunic.library.frontdesk.worker.flag',\n 'tunic.historicalsociety.entry.boss.flag',\n 'tunic.flaghouse.entry.flag_girl.symbol',\n 'tunic.wildlife.center.wells.animals',\n 'tunic.historicalsociety.cage.glasses.afterteddy',\n 'tunic.historicalsociety.cage.teddy.trapped',\n 'tunic.historicalsociety.cage.unlockdoor',\n 'tunic.historicalsociety.stacks.journals.pic_2.bingo',\n 'tunic.historicalsociety.entry.wells.flag',\n 'tunic.humanecology.frontdesk.worker.badger',\n 'tunic.historicalsociety.stacks.journals_flag.pic_0.bingo',\n 'tunic.historicalsociety.entry.directory.closeup.archivist',\n 'tunic.capitol_2.hall.boss.haveyougotit',\n 'tunic.wildlife.center.wells.nodeer_recap',\n 'tunic.historicalsociety.cage.glasses.beforeteddy',\n 'tunic.wildlife.center.expert.recap',\n 'tunic.historicalsociety.stacks.journals_flag.pic_1.bingo',\n 'tunic.historicalsociety.cage.lockeddoor',\n 'tunic.historicalsociety.stacks.journals_flag.pic_2.bingo',\n 'tunic.wildlife.center.remove_cup',\n 'tunic.wildlife.center.tracks.hub.deer',\n 'tunic.historicalsociety.frontdesk.key',\n 'tunic.library.microfiche.reader_flag.paper2.bingo',\n 'tunic.flaghouse.entry.colorbook',\n 'tunic.wildlife.center.coffee',\n 'tunic.historicalsociety.collection_flag.gramps.recap',\n 'tunic.wildlife.center.wells.animals2',\n 'tunic.flaghouse.entry.flag_girl.symbol_recap',\n 'tunic.historicalsociety.closet_dirty.photo',\n 'tunic.historicalsociety.stacks.outtolunch',\n 'tunic.historicalsociety.frontdesk.archivist_glasses.confrontation_recap',\n 'tunic.historicalsociety.entry.boss.flag_recap',\n 'tunic.capitol_1.hall.boss.writeitup',\n 'tunic.library.frontdesk.worker.nelson_recap',\n 'tunic.historicalsociety.entry.wells.flag_recap',\n 'tunic.drycleaner.frontdesk.worker.done2',\n 'tunic.library.frontdesk.worker.flag_recap',\n 'tunic.library.frontdesk.worker.preflag',\n 'tunic.historicalsociety.basement.gramps.seeyalater',\n 'tunic.flaghouse.entry.flag_girl.hello_recap',\n 'tunic.historicalsociety.basement.gramps.whatdo',\n 'tunic.library.frontdesk.block_nelson',\n 'tunic.historicalsociety.cage.need_glasses',\n 'tunic.capitol_2.hall.chap4_finale_c',\n 'tunic.wildlife.center.fox.concern']\n\nFEATURES_name_dict['DIALOGS_1'] = ['can',\n 'and',\n 'Wells',\n 'notebook',\n 'that',\n 'find',\n 'Found',\n 'need',\n 'you',\n 'the',\n 'Jo',\n 'Ooh',\n 'it',\n 'this',\n 'help',\n 'to',\n 'is']\n\nFEATURES_name_dict['DIALOGS_2'] = ['Oh',\n 'can',\n 'and',\n 'Wells',\n 'that',\n 'find',\n 'found',\n 'need',\n 'you',\n 'the',\n 'Jo',\n 'Ooh',\n 'it',\n 'this',\n 'help',\n 'to',\n 'is']\n\nFEATURES_name_dict['DIALOGS_3'] = ['Oh',\n 'can',\n 'and',\n 'Wells',\n 'that',\n 'find',\n 'found',\n 'need',\n 'flag',\n 'you',\n 'the',\n 'Jo',\n 'Ooh',\n 'it',\n 'this',\n 'help',\n 'to',\n 'is']\n\nFEATURES_name_dict['text_features_1'] = ['Whatcha doing over there, Jo?',\n 'Ooh, I like clues!',\n 'Could be. But we need evidence!',\n 'See you later, Teddy.',\n 'No... because history is boring!',\n 'Come on, Jo!',\n 'This button never works!',\n \"Hmmm. Shouldn't you be doing your homework?\",\n 'Besides, I already figured out the shirt.',\n 'Well, Leopold here is always losing papers...',\n 'That settles it.',\n 'Yes! This old slip from 1916.',\n 'Wait, you mean Wells is wrong?!',\n 'I love these photos of me and Teddy!',\n 'Grab your notebook and come upstairs!',\n \"Hmmm. Don't forget about your homework.\",\n \"Let's get started. The Wisconsin Wonders exhibit opens tomorrow!\",\n 'I should see what Grampa is up to!',\n 'Your grampa is waiting for you in the collection room.',\n 'Teddy and I were gonna go climb that huge tree out back!',\n \"This can't be right!\",\n \"Well, I did SOME of those. I just couldn't find them!\",\n \"It's true, they do keep going missing lately.\",\n 'Hopefully you can rustle up some clues!',\n 'Your teacher said you missed 7 assignments in a row!',\n 'Sure!',\n 'Who wants to investigate the shirt artifact?',\n 'Ha. Told you so!',\n 'I should go talk to Gramps!',\n 'I need to get to the Capitol and tell Gramps!',\n 'Sure thing, Jo. Grab your notebook and come upstairs!',\n 'Gramps is a great historian!',\n 'We need to talk about that missing paperwork.',\n 'Hang tight, Teddy.',\n 'Now where did I put my notebook?',\n \"Leopold, why don't you help me set up in the Capitol?\",\n 'Can we hurry up, Gramps?',\n 'Yes! This cool old slip from 1916.',\n \"That's it!\",\n 'Ugh. Meetings are so boring.',\n 'Plus, my teacher said I could help you out for extra credit!',\n 'Hey!',\n \"I'll record this in my notebook.\",\n 'I should see what Gramps is up to!',\n 'Can I come, Gramps?',\n 'Find anything?',\n \"I get to go to Gramps's meeting!\",\n 'Just this old slip from 1916.',\n \"Meet me back in my office and we'll get started!\",\n 'A boring old shirt.',\n 'Hot Dog! I knew it!',\n \"I'll hurry back and then we can go exploring!\",\n \"Hmm. Button's still not working.\",\n 'Go ahead, take a peek at the shirt!',\n 'Hopefully you can find some clues!',\n 'Head over to the Basketball Center.',\n 'Do I have to?',\n 'This looks like a clue!',\n 'Better check back later.',\n 'I knew it!',\n 'Um... what did you want me to do again?',\n 'Gramps said to look for clues. Better look around.',\n \"I'll be at the Capitol. Let me know if you find anything!\",\n \"It's a women's basketball jersey!\",\n 'I suppose historians are boring, too?',\n 'Gramps is in trouble for losing papers?',\n '\\\\u00f0\\\\u0178\\\\u02dc\\\\u00b4',\n \"Well, that's good enough for me.\",\n 'Meetings are BORING!',\n 'Hooray, a boring old shirt.',\n \"The slip is from 1916 but the team didn't start until 1974!\",\n 'Can I take a closer look?',\n \"Hey Jo, let's take a look at the shirt!\",\n 'Found it!',\n 'Wells, finish up your report.',\n \"No way, Gramps. You're the best!\",\n 'I gotta run to my meeting!',\n 'Then do it for me!',\n 'Just talking to Teddy.',\n 'So? History is boring!',\n 'Have a look at the artifact!',\n \"Look at that! It's the bee's knees!\",\n 'Did you do all of them?',\n None,\n \"Wow, that's so cool, Gramps!\",\n 'See?',\n 'Our shirt is too old to be a basketball jersey!',\n \"I feel like I'm forgetting something.\",\n 'What a fascinating artifact!',\n \"Why don't you go play with your grampa?\",\n 'Gramps is the best historian ever!',\n \"Why don't you head to the Basketball Center and rustle up some clues?\",\n 'Will do, Boss.',\n \"Not Leopold here. He's been losing papers lately.\",\n# 'undefined',\n \"I'm not so sure that this is a basketball jersey.\",\n \"It's already all done!\",\n \"Why don't you go catch up with your grampa?\",\n 'Your teacher said you could help me for extra credit.']\n\nFEATURES_name_dict['text_features_2'] = [\"Why don't you take a look?\",\n 'Great! Thanks for the help!',\n 'I should help Gramps clean.',\n 'Theodora wearing the shirt!',\n 'Theodora Youmans? Is that who owned the shirt?',\n 'This button never works!',\n \"He's our expert record keeper.\",\n 'Theodora Youmans must be the owner!',\n 'Nice seeing you, Jolie!',\n \"Sorry, I'm too busy for kids right now.\",\n \"Okay. I'll find Teddy!\",\n 'Can you help me? I need to find the owner of this slip.',\n 'Can you help me tidy up?',\n 'Hi! How can I help you?',\n \"I'm sure you'll find Theodora in there somewhere!\",\n \"You're right, Gramps. Let's investigate!\",\n 'Now if only I could read this thing.',\n 'Thanks to them, Wisconsin was the first state to approve votes for women!',\n 'Welcome back, Jolie. Did you figure out the shirt?',\n 'Wells sabotaged Gramps!',\n \"Fine. Let's investigate!\",\n \"Calm down, kid. I haven't seen him.\",\n 'I found it on an old shirt.',\n \"I don't need that right now.\",\n \"I'm Leopold's grandkid!\",\n 'You could ask the archivist. He knows everybody!',\n 'I should go to the Capitol and tell everyone!',\n 'Your gramps is awesome! Always full of stories.',\n 'Now can I tell you what happened to Teddy?',\n 'What should I do first?',\n 'I love these photos of me and Teddy.',\n 'Ooh, nice decorations!',\n \"Please let me know if you do. It's important!\",\n \"I'm afraid not.\",\n 'Have you seen a badger around here?',\n 'Head over to the university.',\n \"Well, get on it. I'm counting on you and your gramps to figure this out!\",\n \"Guess it couldn't hurt to let you take a look.\",\n 'Ha! What do you call a pony with a sore throat?',\n 'Now I Just need to find all the cleaners from way back in 1916.',\n 'Oh my!',\n \"What's a taxidermist?\",\n '\\\\Taxidermy: the art of preparing, stuffing, and mounting the skins of animals.\\\\',\n 'Oh no... Teddy!',\n 'BUT WELLS STOLE TEDDY!',\n 'The archivist said I should look in the stacks.',\n 'Wells? I knew it!',\n \"Why didn't you say so?\",\n# 'undefined',\n \"Ha! You're funny.\",\n 'AND he stole Teddy!',\n 'Right outside the door.',\n \"Sorry, I'm in a hurry.\",\n 'Then we need evidence.',\n 'I found it!',\n 'Nice decorations.',\n \"Check out our microfiche. It's right through that door.\",\n 'Thanks for the help!',\n \"Hmmm... not sure. Why don't you try the library?\",\n '*cough cough*',\n 'They study clothes and fabric.',\n 'I have an idea.',\n \"Yup, that's him!\",\n 'I got here and the whole place was a mess!',\n \"It's a match!\",\n \"Teddy's scarf! Somebody must've taken him!\",\n \"It must've been Wells.\",\n 'Is this your coffee, Gramps?',\n \"Why don't you go upstairs and see the archivist?\",\n 'Did you figure out the shirt?',\n 'I should check that logbook to see who owned this slip...',\n 'Theodora Youmans? Of course!',\n 'Yes! I was wondering-',\n 'But what if Wells kidnapped Teddy?',\n '*COUGH COUGH COUGH*',\n \"I haven't quite figured it out just yet...\",\n 'Ugh. Fine.',\n 'Leopold, can you run back to the museum?',\n 'Um, are you okay?',\n 'Please?',\n 'Do you know anything about this slip?',\n \"And where's your grampa?\",\n \"And look! She's wearing the shirt!\",\n 'An old shirt? Try the university.',\n 'Yikes... this could take a while.',\n 'Wells! What was he doing here? I should ask the librarian.',\n 'Sorry for the delay, Boss.',\n 'Slow down, Jo.',\n \"Unless you're too busy horsing around.\",\n \"Wells! Where's Teddy? Is he okay?\",\n 'Wow! What is all this stuff?',\n 'One step at a time, Jo.',\n 'Ooh, thanks!',\n \"Well, I can't show our log books to just anybody.\",\n 'Now if only I could read this thing. Blasted tiny letters...',\n 'Are you okay?',\n 'Do you have any info on Theodora Youmans?',\n \"It's such a nice fall day.\",\n 'Head upstairs and talk to the archivist. He might be able to help!',\n 'I knew I could count on you, Jo!',\n 'Youmans was a suffragist here in Wisconsin.',\n \"Maybe there's a clue in this mess!\",\n 'Did you have a question?',\n 'Youmans was a suffragist!',\n 'Where are the Stacks?',\n 'Thanks. Did you figure out the shirt?',\n 'Here I am!',\n \"Oh, I'm fine! Just a little hoarse.\",\n \"Jolie! I was hoping you'd stop by. Any news on the shirt artifact?\",\n 'So much cleaning to do...',\n \"Ah, that's better!\",\n 'I should stay and look for clues!',\n 'Please let me know if you do.',\n 'I figured out that you kidnapped him!',\n \"And I'll figure out the shirt, too.\",\n 'Thanks.',\n 'Run along to the university.',\n 'Did you drop something, Dear?',\n 'He was looking for a taxidermist.',\n 'The libarian said I could find some information on Youmans in here...',\n 'Two missions, actually!',\n 'I knew you could do it, Jo!',\n 'Looks like a dry cleaning receipt.',\n 'I got that one from my Gramps!',\n \"I can't calm down. This is important!\",\n 'Nice work on the shirt, Jolie!',\n 'Badgers? No.',\n 'Wait a minute!',\n \"What's a textile expert?\",\n 'Well? What are you still doing here?',\n 'Yes!',\n 'What the-',\n \"Wait a sec. Women couldn't vote?!\",\n \"Sorry I'm late.\",\n 'Knew what?',\n 'Okay. Thanks anyway.',\n 'I need to find Wells right away! Do you know where he is?',\n 'Can you help me-',\n \"You haven't seen any badgers around here, have you?\",\n 'You better get to the capitol!',\n 'Hold your horses, Jo.',\n 'Oh, hello there!',\n 'Can you help me find Wells?',\n 'Hi, Mrs. M.',\n 'A little horse!',\n 'Who are you?',\n \"Did you drop something, Dear? There's a card on the floor.\",\n 'Who is Teddy?',\n 'Try not to panic, Jo.',\n \"I'm also looking for Theodora Youmans. Have you heard of her?\",\n \"Here's a call number to find more info in the Stacks.\",\n 'Hello there!',\n 'She helped get votes for women!',\n \"Hmm. Button's still not working.\",\n 'Please? This is really important.',\n 'Wow!',\n \"Nope, that's from Bean Town. I only drink Holdgers!\",\n \"It's our Norwegian Craft exhibit!\",\n 'She led marches and helped women get the right to vote!',\n \"Who could've done this?\",\n 'Better check back later.',\n \"And he messed up Gramps's office, too!\",\n 'Maybe he just got scared and ran off.',\n 'And you are?',\n \"You look like you're on a mission.\",\n \"I don't have time for kids.\",\n 'How can I help you?',\n 'I had some cleaning up to do in my office.',\n 'Hey, this is Youmans!',\n \"I wonder if there's a clue in those business cards...\",\n 'Yeah. Thanks anyway.',\n 'Hi! *cough*',\n 'Can you help-',\n 'Do you know who Theodora Youmans is?',\n 'You can talk to a textile expert there.',\n 'Where should I go again?',\n 'Take a look!',\n \"Can't believe I lost my reading glasses.\",\n 'Leo... you mean Leopold?',\n 'I hope you find your badger, kid.',\n \"Oh, that's from Bean Town.\",\n \"But I hear the museum's got one on the loose!\",\n \"I haven't seen him.\",\n 'Sounds good, Boss.',\n 'I should ask the librarian why Wells was here.',\n \"He's always trying to get you in trouble, and he doesn't like animals!\",\n 'I need to find Wells right away!! Do you know where he is?',\n \"You'll have to get started without me.\",\n 'You could try the archivist. Maybe he can help you find Wells!',\n 'Maybe I can help!',\n 'Now I just need to find all the cleaners from wayyyy back in 1916.',\n 'Can I give you the tour?',\n 'What happened here?!',\n 'I should find out if she can help me!',\n '*grumble grumble*',\n 'Easy, Jo.',\n 'I bet the archivist could use this!',\n 'What was Wells doing here?',\n 'I need your help!',\n \"He's wrong about old shirts and his name rhymes with \\\\smells\\\\...\",\n 'What are you still doing here,  Jolie?',\n 'Do you know what this slip is?',\n 'Ha! Good one.',\n 'He needs our help!',\n 'Huh?',\n \"Why don't you prove your case?\",\n \"It's for Grampa Leo. He's a historian!\",\n \"Weren't you going to check out our microfiche?\",\n 'Jo, meet me back at my office.',\n \"Sorry, can't help you.\",\n 'I used to have a magnifying glass around here\\\\u00e2\\\\u20ac\\\\u00a6',\n \"I've got a stack of business cards from my favorite cleaners.\",\n 'I ran into Wells there this morning.',\n 'Did you have a question or not?',\n 'I need to find Wells!!!',\n \"Don't worry, Gramps. I'll find Teddy!\",\n 'Not sure. Here, let me look it up.',\n 'Nope. But Youmans and other suffragists worked hard to change that.',\n 'Oh no!',\n 'Mrs. M, I think Wells kidnapped Teddy.',\n \"I think he's in trouble!\",\n 'Can you help me? I need to find Wells!',\n \"You're still here? I'm trying to work!\",\n 'I need to find the owner of this slip.',\n 'Yep.',\n 'What are you waiting for? The Stacks are right outside the door.',\n None,\n 'I got here and the whole place was ransacked!',\n 'AND I know who took Teddy!',\n 'But he never goes anywhere without his scarf!',\n 'Where did you get that coffee?',\n \"It'll be okay, Jo. We'll find Teddy!\",\n 'Could be. But we need evidence.',\n 'Go find your grampa and get to work!',\n \"Here's the log book.\",\n \"I don't know!\",\n 'This place was around in 1916! I can start there!',\n \"I'm afraid my papers have gone missing in this mess.\",\n \"Poor Gramps! I should make sure he's okay.\"]\n\nFEATURES_name_dict['text_features_3'] = [\"Don't worry, Teddy won't eat your lunch anymore!\",\n 'And you, Frank-',\n 'We just have to keep our eyes open!',\n 'Wait! What?! Really?',\n 'I told you!',\n 'Do you really think that symbol is a deer hoof?',\n 'Yeah. Thanks anyway.',\n 'I found the flag! Governor Nelson used it on the first Earth Day!',\n 'Teddy, here I come!',\n \"Maybe she'll let me take off the cup!\",\n 'Any ideas?',\n \"Come on, kid. Let's go.\",\n 'Whatever.',\n \"Come on, kid. You're slowing me down.\",\n '\\\\u00f0\\\\u0178\\\\u00a7\\\\u02dc',\n 'Hmm. You could try the Aldo Leopold Wildlife Center.',\n 'Your flag must have been part of a national movement!',\n 'Thanks for coming, Boss.',\n \"Let's go find him!\",\n 'I think I can help with your animal problem.',\n \"Why don't you go talk to her? I'll let her know you're coming.\",\n 'Wells, you already have a job to do.',\n 'Hey, this is Youmans!',\n \"Did you steal Gramps's paperwork too?!\",\n \"It's lucky we found her.\",\n 'Do you know where I can find a deer expert?',\n 'Teddy!!!',\n 'What now, kid?',\n \"Great Scott, you're right!\",\n \"Ha! I don't need your help.\",\n 'Ugh...',\n \"I'm investigating this symbol.\",\n 'A vexy-wha?',\n \"I'm telling you, Boss. Taxidermy is the way to go!\",\n 'Ooh... \\\\Ecology flag, by Ron Cobb.\\\\',\n 'What is it?',\n \"Let's go find Gramps!\",\n 'Though the archivist might be too busy to help...',\n 'Wells, meet Teddy.',\n 'Teddy! Did you really eat his lunch?',\n '\\\\Ecology flag, by Ron Cobb.\\\\',\n 'Wait a minute...',\n \"Oh, cool! I've never seen a badger in real life.\",\n 'Poor badger.',\n 'YOU?!',\n 'Sure! Give it a try.',\n \"Let's go help Gramps!\",\n \"And look! She's wearing the shirt!\",\n \"Come on, Teddy. Let's go help Gramps!\",\n \"It's for the flag display!\",\n \"You can't just steal Jolie's pet.\",\n \"It's locked!\",\n \"What's going on here?\",\n \"We'll need a key card.\",\n \"Hey! That's Governor Nelson in front of our flag!\",\n \"Jolie! I was hoping you'd stop by. Any news on the flag artifact?\",\n 'Your grampa is waiting for you in the collection room.',\n \"We're just looking for photos for the flag display.\",\n \"YOU'RE the new history detective everybody's talking about?\",\n 'Good luck!',\n 'Better check back later.',\n 'The boss is gonna love it!!!',\n 'Can you take a look?',\n \"Actually, badgers aren't rodents-\",\n \"Here's your scarf back!\",\n 'People sure drink a lot of coffee around here.',\n 'What is it, Teddy?',\n 'Whoever lost these glasses probably took Teddy!',\n 'Okay. Thanks anyway.',\n 'Ugh. Fine.',\n \"He's a badger!\",\n \"Are you going home now? Tomorrow's the big day!\",\n \"Actually, he's a badger.\",\n 'Do you know what this flag was used for?',\n 'FINE. That possum better not scratch my leather seats...',\n 'What should we do next?',\n 'Can Teddy and I help?',\n \"Let's follow those scratch marks!\",\n 'Poor foxes!',\n 'Nice seeing you, Jolie!',\n 'And we still need to figure out that flag!',\n \"I'm investigating this flag.\",\n 'I should go to the Capitol and tell everyone!',\n \"Teddy's helping too.\",\n \"I can't go with you. I need to take the artifact upstairs.\",\n \"I need to get her free. She won't hold still!\",\n 'Something to do with ecology and Wisconsin.',\n \"Check out the archives. They've got tons of old photos!\",\n 'It just means flag expert. How can I help?',\n 'You did it! Thanks, kid.',\n 'I love these photos of me and Teddy.',\n 'Well... it looks hand-stitched.',\n 'Besides, you just ate my last snack.',\n \"Oh no. If I don't impress the boss soon,  I'm gonna get fired!\",\n \"It's such a nice fall day.\",\n 'Hey, nice dog! What breed is he?',\n '\\\\u00f0\\\\u0178\\\\u02dc\\\\u009d',\n 'Gramps must be up in the collection room.',\n '\\\\u00f0\\\\u0178\\\\u02dc\\\\u0160',\n 'Make sure to get some old photos for the exhibit, like last time!',\n \"Fine, fine. Let's see...\",\n \"Hmm. Let's see...\",\n 'Those are the same glasses!',\n 'YEAH!',\n \"You again! Don't let him hurt me!\",\n 'I should ask the librarian where to go next.',\n 'You stole Teddy! How could you?!',\n 'Ugh... I think that lynx is looking at me funny.',\n \"I haven't quite figured it out just yet...\",\n 'Hey, look at those scratches!',\n 'Hey!',\n '\\\\u00f0\\\\u0178\\\\u2122\\\\u201e',\n \"I'm putting you in charge of the flag case.\",\n 'Hmm... those stripes remind me of the American flag.',\n \"He's. A. Badger.\",\n \"I think it's a flag! Pretty spiffy, eh?\",\n 'Hey, Wells...',\n 'Head over to the Wildlife Center!',\n 'GAH! And what is THAT doing out of its cage?!',\n 'Come on, Teddy.',\n 'Good idea. Thanks!',\n \"I need to take the artifact upstairs. Why don't you investigate those scratch marks?\",\n 'And my homework?!?!',\n 'Huh?',\n 'Are you sure? I know where you can find a real, live badger for the exhibit!',\n 'Nonsense. I want live animals at the exhibit, not stuffed ones.',\n 'Gadzooks! Poor critter.',\n \"Just please, don't let your badger eat them!\",\n \"You're becoming quite the detective, Jo.\",\n \"Yes, he has. I've seen him eating homework and important papers, too.\",\n 'Wells got in trouble for littering at the Wildlife Center.',\n \"It's really cool, Gramps. But I'm worried about Teddy.\",\n 'Go on, tell the boss what you found!',\n 'Ugh! Those cups are all over the place.',\n 'And how did that badger get free?',\n \"Looks like it's not a deer hoof.\",\n \"It's OK, girl! Look, I found you a cricket!\",\n 'Can I ride with you?',\n \"The archivist must've taken Teddy!\",\n 'I have to head over there and check out the animals.',\n \"You haven't seen any badgers around here, have you?\",\n \"You can't just steal Jolie's pet. Don't you know badgers are protected animals?\",\n \"Of course you do. You've got a rodent following you around.\",\n 'There should be some info about that symbol in my book.',\n \"No he hasn't!\",\n 'Now I just need some old photos, like last time.',\n 'I need to learn more about this flag!',\n 'Ugh. I have to head over there and check out the animals.',\n 'Yes!!!',\n 'I should check out that pair of glasses.',\n 'Teddy is still missing!',\n \"Jolie- keep your badger under control, or he'll have to go.\",\n \"You're right, Jo!\",\n \"She's right outside.\",\n \"That hoofprint doesn't match the flag!\",\n \"Yep. I'm a vexillophile!\",\n 'Look at all those activists!',\n \"Well, get on it. I'm counting on you to figure this out!\",\n 'The kidnapper probably took Teddy on the elevator!',\n \"Don't worry, he won't! (And he's a badger, by the way.)\",\n None,\n \"Ah, Jolie! I'm glad you're here.\",\n 'Luckily there are tons of insects around here...',\n \"But I hear the museum's got one on the loose!\",\n 'Yoga does sound nice.',\n \"He's been eating my lunch every day this week!\",\n \"I've seen him eating homework and important papers, too.\",\n 'I wonder whose glasses these are.',\n \"I'm sure they'll be able to help.\",\n \"Okay. I'll try.\",\n \"It's okay, Gramps. I'll go by myself.\",\n 'We need to calm her down, Teddy.',\n 'Thanks!',\n \"I don't have time for this, Gramps.\",\n \"Jo! I can't go with you. I need to take the artifact upstairs.\",\n 'A real, live ferret!',\n 'I love it!',\n 'He got a park named after him? Cool!',\n '\\\\u00f0\\\\u0178\\\\u02dc\\\\u00ad',\n \"Wait! Can't I do it?\",\n 'Head back to the museum. Your gramps is waiting for you.',\n \"I'll be in the collection room. Come find me when you're ready to check out the artifact.\",\n \"It's an ecology flag!\",\n \"Actually, we're just here for some photos.\",\n 'I should go to the Capitol and tell Mrs. M!',\n 'Not sure. Do I look like a deer expert to you?',\n 'What kind of photos do you need?',\n \"I'm here to rescue my friend!\",\n 'Oh! There was a staff directory in the entryway!',\n 'Wait- me?',\n 'You could try the archives.',\n \"I've got Wells's ID!\",\n 'This is perfect for the exhibit.',\n 'Good catch!',\n 'It could be an early design for the Wisconsin state flag!',\n \"We're looking for some photos.\",\n 'Want to look for more clues?',\n 'Great. Just great. Could this day get any worse?!',\n 'GRRRRRRR',\n \"He's still missing!\",\n 'Oh yeah, cranes eat insects!',\n 'It has something to do with ecology.',\n 'We still need to figure out that flag. Do you know anyone who could help?',\n 'Not sure.',\n 'Besides, he looks friendly to me.',\n \"Teddy! I'm sure glad to see you.\",\n \"Hang on. I'll get you out of there!\",\n '\\\\u00f0\\\\u0178\\\\u008d\\\\u00a9',\n \"There's a diagram of animal tracks over there.\",\n 'I found the key!',\n 'Jolie! Where have you been?',\n 'Oh no! What happened to that crane?',\n \"Cranes don't eat donuts!\",\n \"I'm not sure.\",\n 'How can I find out whose glasses these are?',\n 'My friend is a flag expert.',\n 'Notice any clues about this flag?',\n \"Here's a call number for the Stacks. Go find some photos.\",\n \"Yes! It's the key for Teddy's cage!\",\n 'And this place is dirty, and itchy, and-',\n '\\\\u00f0\\\\u0178\\\\u02dc\\\\u0090',\n \"Teddy! I'm glad to see you.\",\n \"That thing's a monster!\",\n 'What are you doing down here?',\n \"Hey, I've seen that symbol before! Check it out!\",\n \"So? What'd you find out?\",\n 'The boss is gonna love it!',\n 'Got one!',\n 'Alright, Jolie. Back to work.',\n \"Go check the microfiche. Maybe you'll find something!\",\n \"Why isn't the button working?\",\n \"What's a vexillophile? \",\n \"I think it's a flag! Pretty interesting, huh?\",\n \"No thanks. I don't need help from kids.\",\n '\\\\u00f0\\\\u0178\\\\u00a6\\\\u2014',\n 'I captured a badger in our museum!',\n 'Can I help you with anything?',\n 'The symbol on the flag looks sort of like a deer hoof.',\n 'Oh no... they got sick from polluted water?',\n 'He has??',\n 'Her beak is stuck in a coffee cup.',\n 'Actually, I went to school with somebody who LOVES old flags.',\n 'Go take a look!',\n 'Badgers? No.',\n 'Check out the next artifact!',\n 'Welcome back, Dear! How can I help you?',\n 'Jo!',\n 'I think I might be able to help you.',\n 'Okay. Thanks!',\n 'See?!',\n 'Wow! You figured it out!',\n \"I don't have time for this.\",\n \"I'll ride with you!\",\n 'Careful. That beak is sharp!',\n \"Come on, let's get out of here!\",\n \"We'll find Teddy.\",\n \"He says he'd be willing to help out.\",\n \"You've got a million flags here!\",\n \"If I were you, I'd go to the library and do some digging.\",\n '\\\\u00e2\\\\u009d\\\\u00a4\\\\u00ef\\\\u00b8\\\\u008f',\n 'Thanks for your help, kid!',\n 'Does it look like a deer hoof?',\n 'I had one, but Teddy chewed it up.',\n \"I'm a historian, not a zookeeper!\",\n \"Gah. I can't believe this.\",\n 'Guess so!',\n #'undefined',\n 'The exhibit opens tomorrow.',\n 'What are you doing here?',\n 'Wha?!',\n 'Aha! Good catch, Jo.',\n \"Why don't you go talk to the boss?\",\n 'The archivist had him locked up!',\n \"Oh, trust me. He'll make time.\",\n 'The Stacks are right outside the door. Go find some photos!',\n 'She should be able to help you out.',\n 'What?!',\n \"We'll find him, Jo.\",\n \"Yes!!! I'm saved!\",\n \"But cranes can't do yoga, Teddy!\",\n \"I'll go look at everyone's pictures!\",\n 'There are some old newspapers loaded up in the microfiche.',\n \"Fine. Then I guess you don't want a real, live badger for the exhibit.\",\n \"I can't believe this.\"]","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2024-02-01T10:27:20.196792Z","iopub.execute_input":"2024-02-01T10:27:20.199186Z","iopub.status.idle":"2024-02-01T10:27:20.318371Z","shell.execute_reply.started":"2024-02-01T10:27:20.199144Z","shell.execute_reply":"2024-02-01T10:27:20.316231Z"},"jupyter":{"source_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pickle\ncolumns = [\n    pl.col(\"page\").cast(pl.Float32),\n    (\n        (pl.col(\"elapsed_time\") - pl.col(\"elapsed_time\").shift(1))\n         .fill_null(0)\n         .over([\"session_id\", \"level_group\"])\n         .alias(\"elapsed_time_diff\")\n    ),\n    (\n        (pl.col(\"screen_coor_x\") - pl.col(\"screen_coor_x\").shift(1))\n         .abs()\n         .over([\"session_id\", \"level_group\"])\n    ),\n    (\n        (pl.col(\"screen_coor_y\") - pl.col(\"screen_coor_y\").shift(1))\n         .abs()\n         .over([\"session_id\", \"level_group\"])\n    ),\n    pl.col(\"fqid\").fill_null(\"fqid_None\"),\n    pl.col(\"text_fqid\").fill_null(\"text_fqid_None\")\n]\n\ncol2 = [(\n        (pl.col(\"room_coor_x\") + pl.col(\"room_coor_y\") +\n         pl.col(\"screen_coor_x\") + pl.col(\"screen_coor_y\"))\n        .fill_null(0)\n        .over([\"session_id\", \"level\"])\n        .alias(\"total_coor\") \n    )]","metadata":{"execution":{"iopub.status.busy":"2024-02-01T10:27:20.32544Z","iopub.execute_input":"2024-02-01T10:27:20.327871Z","iopub.status.idle":"2024-02-01T10:27:20.353945Z","shell.execute_reply.started":"2024-02-01T10:27:20.327819Z","shell.execute_reply":"2024-02-01T10:27:20.351483Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def feature_engineer(x,\n                     grp,\n                     use_extra,\n                     feature_suffix,\n                     LEVELS,\n                     level_groups,\n                     fqid_lists,\n                     text_lists,\n                     text_features):\n    aggs = [\n        pl.col(\"index\").count().alias(f\"session_number_{feature_suffix}\"),\n        \n        *[pl.col(\"elapsed_time_diff\").filter((pl.col(\"event_name\")==c)&(pl.col(\"level\")==d)).sum().alias(f\"{c}_{d}_time_sum\") for c in event_name_feature for d in LEVELS],\n        *[pl.col(\"elapsed_time_diff\").filter((pl.col(\"event_name\")==c)&(pl.col(\"name\")==d)).sum().alias(f\"{c}_{d}_time_sum\") for c in event_name_feature for d in name_feature],\n        *[pl.col(\"elapsed_time_diff\").filter((pl.col(\"event_name\")==c)&(pl.col(\"room_fqid\")==d)).sum().alias(f\"{c}_{d}_time_sum\") for c in event_name_feature for d in room_lists],\n        *[pl.col(\"elapsed_time_diff\").filter((pl.col(\"room_fqid\")==c)&(pl.col(\"name\")==d)).sum().alias(f\"{c}_{d}_time_sum\") for c in room_lists for d in name_feature],\n        *[pl.col(\"elapsed_time_diff\").filter((pl.col(\"room_fqid\")==c)&(pl.col(\"level\")==d)).sum().alias(f\"{c}_{d}_time_sum\") for c in room_lists for d in LEVELS],\n        *[pl.col(\"elapsed_time_diff\").filter((pl.col(\"level\")==c)&(pl.col(\"name\")==d)).sum().alias(f\"{c}_{d}_time_sum\") for c in LEVELS for d in name_feature],\n        \n        *[pl.col('index').filter(pl.col('text').str.contains(c)).count().alias(f'word_{c}') for c in DIALOGS],\n        *[pl.col(\"elapsed_time_diff\").filter((pl.col('text').str.contains(c))).mean().alias(f'word_mean_{c}') for c in\n         DIALOGS],\n        *[pl.col(\"elapsed_time_diff\").filter((pl.col('text').str.contains(c))).std().alias(f'word_std_{c}') for c in\n          DIALOGS],\n        *[pl.col(\"elapsed_time_diff\").filter((pl.col('text').str.contains(c))).max().alias(f'word_max_{c}') for c in\n          DIALOGS],\n        *[pl.col(\"elapsed_time_diff\").filter((pl.col('text').str.contains(c))).sum().alias(f'word_sum_{c}') for c in\n          DIALOGS],\n        *[pl.col(\"elapsed_time_diff\").filter((pl.col('text').str.contains(c))).median().alias(f'word_median_{c}') for c\n          in DIALOGS],\n        *[pl.col(\"elapsed_time_diff\").filter((pl.col('text').str.contains(c))).quantile(0.25).alias(f'word_25_{c}') for c\n          in DIALOGS],\n        *[pl.col(\"elapsed_time_diff\").filter((pl.col('text').str.contains(c))).quantile(0.75).alias(f'word_75_{c}') for c\n          in DIALOGS],\n        *[pl.col(\"elapsed_time_diff\").filter((pl.col('text').str.contains(c))).kurtosis().alias(f'word_Kurtosis_{c}') for c\n          in DIALOGS],\n        *[pl.col(\"elapsed_time_diff\").filter((pl.col('text').str.contains(c))).skew().alias(f'word_skew_{c}') for c\n          in DIALOGS],\n        \n        *[pl.col(c).drop_nulls().n_unique().alias(f\"{c}_unique_{feature_suffix}\") for c in CATS],\n\n        *[pl.col(c).mean().alias(f\"{c}_mean_{feature_suffix}\") for c in NUMS],\n        *[pl.col(c).std().alias(f\"{c}_std_{feature_suffix}\") for c in NUMS],\n        *[pl.col(c).min().alias(f\"{c}_min_{feature_suffix}\") for c in NUMS],\n        *[pl.col(c).max().alias(f\"{c}_max_{feature_suffix}\") for c in NUMS],\n        *[pl.col(c).sum().alias(f\"{c}_sum_{feature_suffix}\") for c in NUMS],\n\n        *[pl.col(\"fqid\").filter(pl.col(\"fqid\") == c).count().alias(f\"{c}_fqid_counts{feature_suffix}\")\n          for c in fqid_lists],\n        \n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"fqid\") == c).std().alias(f\"{c}_ET_std_{feature_suffix}\") for\n          c in fqid_lists],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"fqid\") == c).mean().alias(f\"{c}_ET_mean_{feature_suffix}\") for\n          c in fqid_lists],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"fqid\") == c).sum().alias(f\"{c}_ET_sum_{feature_suffix}\") for\n          c in fqid_lists],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"fqid\") == c).median().alias(f\"{c}_ET_median_{feature_suffix}\") for\n          c in fqid_lists],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"fqid\") == c).max().alias(f\"{c}_ET_max_{feature_suffix}\") for\n          c in fqid_lists],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"fqid\") == c).quantile(0.25).alias(f\"{c}_ET_25_{feature_suffix}\") for\n          c in fqid_lists],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"fqid\") == c).quantile(0.75).alias(f\"{c}_ET_75_{feature_suffix}\") for\n          c in fqid_lists],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"fqid\") == c).kurtosis().alias(f\"{c}_ET_kurtosis_{feature_suffix}\") for\n          c in fqid_lists],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"fqid\") == c).skew().alias(f\"{c}_ET_skew_{feature_suffix}\") for\n          c in fqid_lists],\n        \n        *[pl.col(\"total_coor\").filter(pl.col(\"fqid\") == c).std().alias(f\"{c}_ET_std_b{feature_suffix}\") for\n          c in fqid_lists],\n        *[pl.col(\"total_coor\").filter(pl.col(\"fqid\") == c).mean().alias(f\"{c}_ET_mean_b{feature_suffix}\") for\n          c in fqid_lists],\n        *[pl.col(\"total_coor\").filter(pl.col(\"fqid\") == c).sum().alias(f\"{c}_ET_sum_b{feature_suffix}\") for\n          c in fqid_lists],\n        *[pl.col(\"total_coor\").filter(pl.col(\"fqid\") == c).median().alias(f\"{c}_ET_median_b{feature_suffix}\") for\n          c in fqid_lists],\n        *[pl.col(\"total_coor\").filter(pl.col(\"fqid\") == c).max().alias(f\"{c}_ET_max_b{feature_suffix}\") for\n          c in fqid_lists],\n        *[pl.col(\"total_coor\").filter(pl.col(\"fqid\") == c).quantile(0.25).alias(f\"{c}_ET_25_b{feature_suffix}\") for\n          c in fqid_lists],\n        *[pl.col(\"total_coor\").filter(pl.col(\"fqid\") == c).quantile(0.75).alias(f\"{c}_ET_75_b{feature_suffix}\") for\n          c in fqid_lists],\n        *[pl.col(\"total_coor\").filter(pl.col(\"fqid\") == c).kurtosis().alias(f\"{c}_ET_kurtosis_b{feature_suffix}\") for\n          c in fqid_lists],\n        *[pl.col(\"total_coor\").filter(pl.col(\"fqid\") == c).skew().alias(f\"{c}_ET_skew_b{feature_suffix}\") for\n          c in fqid_lists],\n\n        *[pl.col(\"text_fqid\").filter(pl.col(\"text_fqid\") == c).count().alias(f\"{c}_text_fqid_counts{feature_suffix}\")\n          for\n          c in text_lists],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"text_fqid\") == c).std().alias(f\"{c}_ET_std_{feature_suffix}\") for\n          c in text_lists],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"text_fqid\") == c).mean().alias(f\"{c}_ET_mean_{feature_suffix}\") for\n          c in text_lists],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"text_fqid\") == c).sum().alias(f\"{c}_ET_sum_{feature_suffix}\") for\n          c in text_lists],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"text_fqid\") == c).median().alias(f\"{c}_ET_median_{feature_suffix}\")\n          for\n          c in text_lists],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"text_fqid\") == c).max().alias(f\"{c}_ET_max_{feature_suffix}\") for\n          c in text_lists],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"text_fqid\") == c).quantile(0.25).alias(f\"{c}_ET_25_{feature_suffix}\") for\n          c in text_lists],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"text_fqid\") == c).quantile(0.75).alias(f\"{c}_ET_75_{feature_suffix}\") for\n          c in text_lists],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"text_fqid\") == c).kurtosis().alias(f\"{c}_ET_kurtosis_{feature_suffix}\") for\n          c in text_lists],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"text_fqid\") == c).skew().alias(f\"{c}_ET_skew_{feature_suffix}\") for\n          c in text_lists],\n\n        *[pl.col(\"room_fqid\").filter(pl.col(\"room_fqid\") == c).count().alias(f\"{c}_room_fqid_counts{feature_suffix}\")\n          for c in room_lists],\n  #      *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"room_fqid\") == c).std().alias(f\"{c}_ET_std_{feature_suffix}\") for\n  #        c in room_lists],\n  #      *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"room_fqid\") == c).mean().alias(f\"{c}_ET_mean_{feature_suffix}\") for\n  #        c in room_lists],\n  #      *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"room_fqid\") == c).sum().alias(f\"{c}_ET_sum_{feature_suffix}\") for\n  #        c in room_lists],\n  #      *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"room_fqid\") == c).median().alias(f\"{c}_ET_median_{feature_suffix}\")\n  #        for\n  #        c in room_lists],\n  #      *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"room_fqid\") == c).max().alias(f\"{c}_ET_max_{feature_suffix}\") for\n  #        c in room_lists],\n  #      *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"room_fqid\") == c).quantile(0.25).alias(f\"{c}_ET_25_{feature_suffix}\") for\n  #        c in room_lists],\n  #      *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"room_fqid\") == c).quantile(0.75).alias(f\"{c}_ET_75_{feature_suffix}\") for\n  #        c in room_lists],\n  #      *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"room_fqid\") == c).kurtosis().alias(f\"{c}_ET_kurtosis_{feature_suffix}\") for\n  #        c in room_lists],\n  #      *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"room_fqid\") == c).skew().alias(f\"{c}_ET_skew_{feature_suffix}\") for\n  #        c in room_lists],\n\n        *[pl.col(\"event_name\").filter(pl.col(\"event_name\") == c).count().alias(f\"{c}_event_name_counts{feature_suffix}\")\n          for c in event_name_feature],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"event_name\") == c).std().alias(f\"{c}_ET_std_{feature_suffix}\") for\n          c in event_name_feature],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"event_name\") == c).mean().alias(f\"{c}_ET_mean_{feature_suffix}\")\n          for\n          c in event_name_feature],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"event_name\") == c).sum().alias(f\"{c}_ET_sum_{feature_suffix}\") for\n          c in event_name_feature],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"event_name\") == c).median().alias(\n            f\"{c}_ET_median_{feature_suffix}\") for\n          c in event_name_feature],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"event_name\") == c).max().alias(f\"{c}_ET_max_{feature_suffix}\") for\n          c in event_name_feature],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"event_name\") == c).quantile(0.25).alias(f\"{c}_ET_25_{feature_suffix}\") for\n          c in event_name_feature],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"event_name\") == c).quantile(0.75).alias(f\"{c}_ET_75_{feature_suffix}\") for\n          c in event_name_feature],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"event_name\") == c).kurtosis().alias(f\"{c}_ET_kurtosis_{feature_suffix}\") for\n          c in event_name_feature],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"event_name\") == c).skew().alias(f\"{c}_ET_skew_{feature_suffix}\") for\n          c in event_name_feature],\n\n        *[pl.col(\"name\").filter(pl.col(\"name\") == c).count().alias(f\"{c}_name_counts{feature_suffix}\") for c in\n          name_feature],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"name\") == c).std().alias(f\"{c}_ET_std_{feature_suffix}\") for c in\n          name_feature],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"name\") == c).mean().alias(f\"{c}_ET_mean_{feature_suffix}\") for c in\n          name_feature],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"name\") == c).sum().alias(f\"{c}_ET_sum_{feature_suffix}\") for c in\n          name_feature],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"name\") == c).median().alias(f\"{c}_ET_median_{feature_suffix}\") for\n          c in\n          name_feature],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"name\") == c).max().alias(f\"{c}_ET_max_{feature_suffix}\") for c in\n          name_feature],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"name\") == c).quantile(0.25).alias(f\"{c}_ET_25_{feature_suffix}\") for\n          c in name_feature],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"name\") == c).quantile(0.75).alias(f\"{c}_ET_75_{feature_suffix}\") for\n          c in name_feature],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"name\") == c).kurtosis().alias(f\"{c}_ET_kurtosis_{feature_suffix}\") for\n          c in name_feature],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"name\") == c).skew().alias(f\"{c}_ET_skew_{feature_suffix}\") for\n          c in name_feature],\n\n        *[pl.col(\"level\").filter(pl.col(\"level\") == c).count().alias(f\"{c}_LEVEL_count{feature_suffix}\") for c in\n          LEVELS],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"level\") == c).std().alias(f\"{c}_ET_std_{feature_suffix}\") for c in\n          LEVELS],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"level\") == c).mean().alias(f\"{c}_ET_mean_{feature_suffix}\") for c\n          in\n          LEVELS],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"level\") == c).sum().alias(f\"{c}_ET_sum_{feature_suffix}\") for c in\n          LEVELS],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"level\") == c).median().alias(f\"{c}_ET_median_{feature_suffix}\") for\n          c in\n          LEVELS],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"level\") == c).max().alias(f\"{c}_ET_max_{feature_suffix}\") for c in\n          LEVELS],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"level\") == c).quantile(0.25).alias(f\"{c}_ET_25_{feature_suffix}\") for\n          c in LEVELS],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"level\") == c).quantile(0.75).alias(f\"{c}_ET_75_{feature_suffix}\") for\n          c in LEVELS],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"level\") == c).kurtosis().alias(f\"{c}_ET_kurtosis_{feature_suffix}\") for\n          c in LEVELS],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"level\") == c).skew().alias(f\"{c}_ET_skew_{feature_suffix}\") for\n          c in LEVELS],\n\n        *[pl.col(\"day\").filter(pl.col(\"day\") == c).count().alias(f\"{c}_day_count{feature_suffix}\") for c in\n          day_lists],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"day\") == c).std().alias(f\"{c}_day_std_{feature_suffix}\") for c in\n          day_lists],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"day\") == c).mean().alias(f\"{c}_day_mean_{feature_suffix}\") for c\n          in\n          day_lists],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"day\") == c).sum().alias(f\"{c}_day_sum_{feature_suffix}\") for c in\n          day_lists],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"day\") == c).median().alias(f\"{c}_day_median_{feature_suffix}\") for\n          c in\n          day_lists],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"day\") == c).max().alias(f\"{c}_day_max_{feature_suffix}\") for c in\n          day_lists],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"day\") == c).quantile(0.25).alias(f\"{c}_day_25_{feature_suffix}\") for\n          c in day_lists],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"day\") == c).quantile(0.75).alias(f\"{c}_day_75_{feature_suffix}\") for\n          c in day_lists],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"day\") == c).kurtosis().alias(f\"{c}_day_kurtosis_{feature_suffix}\") for\n          c in day_lists],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"day\") == c).skew().alias(f\"{c}_day_skew_{feature_suffix}\") for\n          c in day_lists],\n        \n        \n        *[pl.col(\"total_coor\").filter(pl.col(\"name\") == c).std().alias(f\"{c}_ET_std_b{feature_suffix}\") for c in\n          name_feature],\n        *[pl.col(\"total_coor\").filter(pl.col(\"name\") == c).mean().alias(f\"{c}_ET_mean_b{feature_suffix}\") for c in\n          name_feature],\n        *[pl.col(\"total_coor\").filter(pl.col(\"name\") == c).sum().alias(f\"{c}_ET_sum_b{feature_suffix}\") for c in\n          name_feature],\n        *[pl.col(\"total_coor\").filter(pl.col(\"name\") == c).median().alias(f\"{c}_ET_median_b{feature_suffix}\") for\n          c in\n          name_feature],\n        *[pl.col(\"total_coor\").filter(pl.col(\"name\") == c).max().alias(f\"{c}_ET_max_b{feature_suffix}\") for c in\n          name_feature],\n        *[pl.col(\"total_coor\").filter(pl.col(\"name\") == c).quantile(0.25).alias(f\"{c}_ET_25_b{feature_suffix}\") for\n          c in name_feature],\n        *[pl.col(\"total_coor\").filter(pl.col(\"name\") == c).quantile(0.75).alias(f\"{c}_ET_75_b{feature_suffix}\") for\n          c in name_feature],\n        *[pl.col(\"total_coor\").filter(pl.col(\"name\") == c).kurtosis().alias(f\"{c}_ET_kurtosis_b{feature_suffix}\") for\n          c in name_feature],\n        *[pl.col(\"total_coor\").filter(pl.col(\"name\") == c).skew().alias(f\"{c}_ET_skew_b{feature_suffix}\") for\n          c in name_feature],\n        \n        *[pl.col(\"total_coor\").filter(pl.col(\"level_group\") == c).std().alias(f\"{c}_ET_std_b{feature_suffix}\") for\n          c in\n          level_groups],\n        *[pl.col(\"total_coor\").filter(pl.col(\"level_group\") == c).mean().alias(f\"{c}_ET_mean_b{feature_suffix}\")\n          for c in\n          level_groups],\n        *[pl.col(\"total_coor\").filter(pl.col(\"level_group\") == c).sum().alias(f\"{c}_ET_sum_b{feature_suffix}\") for\n          c in\n          level_groups],\n        *[pl.col(\"total_coor\").filter(pl.col(\"level_group\") == c).median().alias(\n            f\"{c}_ET_median_b{feature_suffix}\") for c in\n          level_groups],\n        *[pl.col(\"total_coor\").filter(pl.col(\"level_group\") == c).max().alias(f\"{c}_ET_max_b{feature_suffix}\") for\n          c in\n          level_groups],\n        *[pl.col(\"total_coor\").filter(pl.col(\"level_group\") == c).quantile(0.25).alias(f\"{c}_ET_25_b{feature_suffix}\") for\n          c in level_groups],\n        *[pl.col(\"total_coor\").filter(pl.col(\"level_group\") == c).quantile(0.75).alias(f\"{c}_ET_75_b{feature_suffix}\") for\n          c in level_groups],\n        *[pl.col(\"total_coor\").filter(pl.col(\"level_group\") == c).kurtosis().alias(f\"{c}_ET_kurtosis_b{feature_suffix}\") for\n          c in level_groups],\n        *[pl.col(\"total_coor\").filter(pl.col(\"level_group\") == c).skew().alias(f\"{c}_ET_skew_b{feature_suffix}\") for\n          c in level_groups],\n        \n        *[pl.col(\"elapsed_time_diff\").filter((pl.col(\"event_name\")==c)&(pl.col(\"level\")==d)).median()\n          .alias(f\"{c}_{d}_time_median\") for c in event_name_feature for d in LEVELS],\n        *[pl.col(\"elapsed_time_diff\").filter((pl.col(\"room_fqid\")==c)&(pl.col(\"name\")==d)).median()\n          .alias(f\"{c}_{d}_time_median\") for c in room_lists for d in name_feature],\n        \n        *[pl.col(\"elapsed_time_diff\").filter((pl.col(\"event_name\")==c)&(pl.col(\"level\")==d)).std()\n          .alias(f\"{c}_{d}_time_std\") for c in event_name_feature for d in LEVELS],\n        *[pl.col(\"elapsed_time_diff\").filter((pl.col(\"room_fqid\")==c)&(pl.col(\"name\")==d)).std()\n          .alias(f\"{c}_{d}_time_std\") for c in room_lists for d in name_feature],\n        \n        *[pl.col(\"elapsed_time_diff\").filter((pl.col(\"event_name\")==c)&(pl.col(\"level\")==d)).first()\n          .alias(f\"{c}_{d}_time_first\") for c in event_name_feature for d in LEVELS],\n        *[pl.col(\"elapsed_time_diff\").filter((pl.col(\"room_fqid\")==c)&(pl.col(\"name\")==d)).first()\n          .alias(f\"{c}_{d}_time_first\") for c in room_lists for d in name_feature],\n        \n        *[pl.col(\"elapsed_time_diff\").filter((pl.col(\"event_name\")==c)&(pl.col(\"level\")==d)).last()\n          .alias(f\"{c}_{d}_time_last\") for c in event_name_feature for d in LEVELS],\n        *[pl.col(\"elapsed_time_diff\").filter((pl.col(\"room_fqid\")==c)&(pl.col(\"name\")==d)).last()\n          .alias(f\"{c}_{d}_time_last\") for c in room_lists for d in name_feature],\n        \n        *[pl.col(\"elapsed_time_diff\").filter((pl.col(\"event_name\")==c)&(pl.col(\"level\")==d)).min()\n          .alias(f\"{c}_{d}_time_min\") for c in event_name_feature for d in LEVELS],\n        *[pl.col(\"elapsed_time_diff\").filter((pl.col(\"room_fqid\")==c)&(pl.col(\"name\")==d)).min()\n          .alias(f\"{c}_{d}_time_min\") for c in room_lists for d in name_feature],\n        \n        *[pl.col(\"elapsed_time_diff\").filter((pl.col(\"event_name\")==c)&(pl.col(\"level\")==d)).max()\n          .alias(f\"{c}_{d}_time_max\") for c in event_name_feature for d in LEVELS],\n        *[pl.col(\"elapsed_time_diff\").filter((pl.col(\"room_fqid\")==c)&(pl.col(\"name\")==d)).max()\n          .alias(f\"{c}_{d}_time_max\") for c in room_lists for d in name_feature],\n        \n        *[pl.col(\"total_coor\").filter((pl.col(\"event_name\")==c)&(pl.col(\"level\")==d)).sum().alias(f\"{c}_{d}_time_sum_b\") for c in event_name_feature for d in LEVELS],\n        *[pl.col(\"total_coor\").filter((pl.col(\"event_name\")==c)&(pl.col(\"name\")==d)).sum().alias(f\"{c}_{d}_time_sum_b\") for c in event_name_feature for d in name_feature],\n        *[pl.col(\"total_coor\").filter((pl.col(\"event_name\")==c)&(pl.col(\"room_fqid\")==d)).sum().alias(f\"{c}_{d}_time_sum_b\") for c in event_name_feature for d in room_lists],\n        *[pl.col(\"total_coor\").filter((pl.col(\"room_fqid\")==c)&(pl.col(\"name\")==d)).sum().alias(f\"{c}_{d}_time_sum_b\") for c in room_lists for d in name_feature],\n        *[pl.col(\"total_coor\").filter((pl.col(\"room_fqid\")==c)&(pl.col(\"level\")==d)).sum().alias(f\"{c}_{d}_time_sum_b\") for c in room_lists for d in LEVELS],\n        *[pl.col(\"total_coor\").filter((pl.col(\"level\")==c)&(pl.col(\"name\")==d)).sum().alias(f\"{c}_{d}_time_sum_b\") for c in LEVELS for d in name_feature],\n\n        \n        *[pl.col(\"total_coor\").filter((pl.col(\"event_name\")==c)&(pl.col(\"level\")==d)).median()\n          .alias(f\"{c}_{d}_time_median_b\") for c in event_name_feature for d in LEVELS],\n        *[pl.col(\"total_coor\").filter((pl.col(\"room_fqid\")==c)&(pl.col(\"name\")==d)).median()\n          .alias(f\"{c}_{d}_time_median_b\") for c in room_lists for d in name_feature],\n        \n        *[pl.col(\"total_coor\").filter((pl.col(\"event_name\")==c)&(pl.col(\"level\")==d)).std()\n          .alias(f\"{c}_{d}_time_std_b\") for c in event_name_feature for d in LEVELS],\n        *[pl.col(\"total_coor\").filter((pl.col(\"room_fqid\")==c)&(pl.col(\"name\")==d)).std()\n          .alias(f\"{c}_{d}_time_std_b\") for c in room_lists for d in name_feature],\n        \n        *[pl.col(\"total_coor\").filter((pl.col(\"event_name\")==c)&(pl.col(\"level\")==d)).first()\n          .alias(f\"{c}_{d}_time_first_b\") for c in event_name_feature for d in LEVELS],\n        *[pl.col(\"total_coor\").filter((pl.col(\"room_fqid\")==c)&(pl.col(\"name\")==d)).first()\n          .alias(f\"{c}_{d}_time_first_b\") for c in room_lists for d in name_feature],\n        \n        *[pl.col(\"total_coor\").filter((pl.col(\"event_name\")==c)&(pl.col(\"level\")==d)).last()\n          .alias(f\"{c}_{d}_time_last_b\") for c in event_name_feature for d in LEVELS],\n        *[pl.col(\"total_coor\").filter((pl.col(\"room_fqid\")==c)&(pl.col(\"name\")==d)).last()\n         .alias(f\"{c}_{d}_time_last_b\") for c in room_lists for d in name_feature],\n        \n        *[pl.col(\"total_coor\").filter((pl.col(\"event_name\")==c)&(pl.col(\"level\")==d)).min()\n          .alias(f\"{c}_{d}_time_min_b\") for c in event_name_feature for d in LEVELS],\n        *[pl.col(\"total_coor\").filter((pl.col(\"room_fqid\")==c)&(pl.col(\"name\")==d)).min()\n          .alias(f\"{c}_{d}_time_min_b\") for c in room_lists for d in name_feature],\n        \n        *[pl.col(\"total_coor\").filter((pl.col(\"event_name\")==c)&(pl.col(\"level\")==d)).max()\n          .alias(f\"{c}_{d}_time_max_b\") for c in event_name_feature for d in LEVELS],\n        *[pl.col(\"total_coor\").filter((pl.col(\"room_fqid\")==c)&(pl.col(\"name\")==d)).max()\n          .alias(f\"{c}_{d}_time_max_b\") for c in room_lists for d in name_feature],\n        \n        *[pl.col(\"text\").filter(pl.col(\"text\") == c).count().alias(f\"{c}_event_name_counts{feature_suffix}\")\n          for c in text_features],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"text\") == c).std().alias(f\"{c}_ET_std_{feature_suffix}\") for\n          c in text_features],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"text\") == c).mean().alias(f\"{c}_ET_mean_{feature_suffix}\")\n          for\n          c in text_features],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"text\") == c).sum().alias(f\"{c}_ET_sum_{feature_suffix}\") for\n          c in text_features],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"text\") == c).median().alias(\n            f\"{c}_ET_median_{feature_suffix}\") for\n          c in text_features],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"text\") == c).max().alias(f\"{c}_ET_max_{feature_suffix}\") for\n          c in text_features],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"text\") == c).quantile(0.25).alias(f\"{c}_ET_25_{feature_suffix}\") for\n          c in text_features],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"text\") == c).quantile(0.75).alias(f\"{c}_ET_75_{feature_suffix}\") for\n          c in text_features],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"text\") == c).kurtosis().alias(f\"{c}_ET_kurtosis_{feature_suffix}\") for\n          c in text_features],\n        *[pl.col(\"elapsed_time_diff\").filter(pl.col(\"text\") == c).skew().alias(f\"{c}_ET_skew_{feature_suffix}\") for\n          c in text_features],\n    ]\n    \n    df = x.groupby(['session_id'], maintain_order=True).agg(aggs).sort(\"session_id\")\n\n    if use_extra:\n        if grp == '5-12':\n            aggs = [\n                pl.col(\"elapsed_time\").filter((pl.col(\"text\") == \"Here's the log book.\")\n                                              | (pl.col(\"fqid\") == 'logbook.page.bingo'))\n                    .apply(lambda s: s.max() - s.min()).alias(\"logbook_bingo_duration\"),\n                pl.col(\"index\").filter(\n                    (pl.col(\"text\") == \"Here's the log book.\") | (pl.col(\"fqid\") == 'logbook.page.bingo')).apply(\n                    lambda s: s.max() - s.min()).alias(\"logbook_bingo_indexCount\"),\n                pl.col(\"elapsed_time\").filter(\n                    ((pl.col(\"event_name\") == 'navigate_click') & (pl.col(\"fqid\") == 'reader')) | (\n                            pl.col(\"fqid\") == \"reader.paper2.bingo\")).apply(lambda s: s.max() - s.min()).alias(\n                    \"reader_bingo_duration\"),\n                pl.col(\"index\").filter(((pl.col(\"event_name\") == 'navigate_click') & (pl.col(\"fqid\") == 'reader')) | (\n                        pl.col(\"fqid\") == \"reader.paper2.bingo\")).apply(lambda s: s.max() - s.min()).alias(\n                    \"reader_bingo_indexCount\"),\n                pl.col(\"elapsed_time\").filter(\n                    ((pl.col(\"event_name\") == 'navigate_click') & (pl.col(\"fqid\") == 'journals')) | (\n                            pl.col(\"fqid\") == \"journals.pic_2.bingo\")).apply(lambda s: s.max() - s.min()).alias(\n                    \"journals_bingo_duration\"),\n                pl.col(\"index\").filter(((pl.col(\"event_name\") == 'navigate_click') & (pl.col(\"fqid\") == 'journals')) | (\n                        pl.col(\"fqid\") == \"journals.pic_2.bingo\")).apply(lambda s: s.max() - s.min()).alias(\n                    \"journals_bingo_indexCount\"),\n            ]\n            tmp = x.groupby([\"session_id\"], maintain_order=True).agg(aggs).sort(\"session_id\")\n            df = df.join(tmp, on=\"session_id\", how='left')\n\n        if grp == '13-22':\n            aggs = [\n                pl.col(\"elapsed_time\").filter(\n                    ((pl.col(\"event_name\") == 'navigate_click') & (pl.col(\"fqid\") == 'reader_flag')) | (\n                            pl.col(\"fqid\") == \"tunic.library.microfiche.reader_flag.paper2.bingo\")).apply(\n                    lambda s: s.max() - s.min() if s.len() > 0 else 0).alias(\"reader_flag_duration\"),\n                pl.col(\"index\").filter(\n                    ((pl.col(\"event_name\") == 'navigate_click') & (pl.col(\"fqid\") == 'reader_flag')) | (\n                            pl.col(\"fqid\") == \"tunic.library.microfiche.reader_flag.paper2.bingo\")).apply(\n                    lambda s: s.max() - s.min() if s.len() > 0 else 0).alias(\"reader_flag_indexCount\"),\n                pl.col(\"elapsed_time\").filter(\n                    ((pl.col(\"event_name\") == 'navigate_click') & (pl.col(\"fqid\") == 'journals_flag')) | (\n                            pl.col(\"fqid\") == \"journals_flag.pic_0.bingo_b\")).apply(\n                    lambda s: s.max() - s.min() if s.len() > 0 else 0).alias(\"journalsFlag_bingo_duration\"),\n                pl.col(\"index\").filter(\n                    ((pl.col(\"event_name\") == 'navigate_click') & (pl.col(\"fqid\") == 'journals_flag')) | (\n                            pl.col(\"fqid\") == \"journals_flag.pic_0.bingo\")).apply(\n                    lambda s: s.max() - s.min() if s.len() > 0 else 0).alias(\"journalsFlag_bingo_indexCount\"),\n            ]\n            tmp = x.groupby([\"session_id\"], maintain_order=True).agg(aggs).sort(\"session_id\")\n            df = df.join(tmp, on=\"session_id\", how='left')\n\n    return df.to_pandas()","metadata":{"execution":{"iopub.status.busy":"2024-02-01T10:27:20.360872Z","iopub.execute_input":"2024-02-01T10:27:20.363023Z","iopub.status.idle":"2024-02-01T10:27:20.643648Z","shell.execute_reply.started":"2024-02-01T10:27:20.362984Z","shell.execute_reply":"2024-02-01T10:27:20.642801Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def make_plus_feature(train,\n                      LEVELS,\n                      level_groups,\n                      fqid_lists,\n                      text_lists,\n                      text_features):\n    \n    for c in fqid_lists:\n        train[f'{c}_ET_cov_'] = train[f'{c}_ET_std_'] / train[f'{c}_ET_mean_']\n#    for c in DIALOGS:\n#        train[f'{c}_ET_cov_'] = train[f'word_std_{c}'] / train[f'word_mean_{c}']\n    for c in name_feature:\n        train[f'{c}_ET_cov_'] = train[f'{c}_ET_std_'] / train[f'{c}_ET_mean_']\n    for c in event_name_feature:\n        train[f'{c}_ET_cov_'] = train[f'{c}_ET_std_'] / train[f'{c}_ET_mean_']\n    for c in text_lists:\n        train[f'{c}_ET_cov_'] = train[f'{c}_ET_std_'] / train[f'{c}_ET_mean_']\n #   for c in room_lists:\n #       train[f'{c}_ET_cov_'] = train[f'{c}_ET_std_'] / train[f'{c}_ET_mean_']\n    for c in LEVELS:\n        train[f'{c}_ET_cov_'] = train[f'{c}_ET_std_'] / train[f'{c}_ET_mean_']\n    for c in day_lists:\n        train[f'{c}_day_cov_'] = train[f'{c}_day_std_'] / train[f'{c}_day_mean_']\n    for c in text_features:\n        train[f'{c}_ET_cov_'] = train[f'{c}_ET_std_'] / train[f'{c}_ET_mean_']\n\n    for c in fqid_lists:\n        train[f'{c}_ET_cov_b'] = train[f'{c}_ET_std_b'] / train[f'{c}_ET_mean_b']\n    for c in name_feature:\n        train[f'{c}_ET_cov_b'] = train[f'{c}_ET_std_b'] / train[f'{c}_ET_mean_b']\n    for c in level_groups:\n        train[f'{c}_ET_cov_b'] = train[f'{c}_ET_std_b'] / train[f'{c}_ET_mean_b']\n        \n    train[\"year\"] = train[\"session_id\"].apply(lambda x: int(str(x)[:2])).astype(np.uint8)\n    train[\"month\"] = train[\"session_id\"].apply(lambda x: int(str(x)[2:4])+1).astype(np.uint8)\n    train[\"day\"] = train[\"session_id\"].apply(lambda x: int(str(x)[4:6])).astype(np.uint8)\n    train[\"hour\"] = train[\"session_id\"].apply(lambda x: int(str(x)[6:8])).astype(np.uint8)\n    train[\"minute\"] = train[\"session_id\"].apply(lambda x: int(str(x)[8:10])).astype(np.uint8)\n    train[\"second\"] = train[\"session_id\"].apply(lambda x: int(str(x)[10:12])).astype(np.uint8)\n    \n    return train\n\ndef test_day(train):\n    train[\"day\"] = train[\"session_id\"].apply(lambda x: int(str(x)[4:6])).astype(np.uint8)\n    return train","metadata":{"execution":{"iopub.status.busy":"2024-02-01T10:27:20.648007Z","iopub.execute_input":"2024-02-01T10:27:20.650165Z","iopub.status.idle":"2024-02-01T10:27:20.666904Z","shell.execute_reply.started":"2024-02-01T10:27:20.650126Z","shell.execute_reply":"2024-02-01T10:27:20.665976Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model_path = '/kaggle/input/psp-xgb-cv7013-model'\n\nxgb_list = [[pickle.load(open(f\"{model_path}/fold{fold}_q{q}.pickle\", \"rb\"))\n                            for fold in range(5)] for q in [1, 3,4, 5, 6, 7, 8, 9, 10, 11,14, 15, 16, 17]]\n\nxgb_dict = {}\nfor idx,q in enumerate([1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 14, 15, 16, 17]):\n    xgb_dict[q] = xgb_list[idx]\n\nf_read = open(f'{model_path}/importance_dict.pkl', 'rb')\nimportance_dict = pickle.load(f_read)\nf_read.close()\n\nf_read = open(f'{model_path}/rename_1.pkl', 'rb')\nrename_dict_1 = pickle.load(f_read)\nf_read.close()\n\nf_read = open(f'{model_path}/rename_2.pkl', 'rb')\nrename_dict_2 = pickle.load(f_read)\nf_read.close()","metadata":{"execution":{"iopub.status.busy":"2024-02-01T10:27:20.66844Z","iopub.execute_input":"2024-02-01T10:27:20.669129Z","iopub.status.idle":"2024-02-01T10:27:22.757369Z","shell.execute_reply.started":"2024-02-01T10:27:20.66909Z","shell.execute_reply":"2024-02-01T10:27:22.756309Z"},"_kg_hide-output":true,"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import jo_wilder\n\ntry:\n    jo_wilder.make_env.__called__ = False\n    env.__called__ = False\n    type(env)._state = type(type(env)._state).__dict__['INIT']\nexcept:\n    pass\n\nenv = jo_wilder.make_env()\niter_test = env.iter_test()   ","metadata":{"execution":{"iopub.status.busy":"2024-02-01T10:33:38.915161Z","iopub.execute_input":"2024-02-01T10:33:38.916087Z","iopub.status.idle":"2024-02-01T10:33:38.921182Z","shell.execute_reply.started":"2024-02-01T10:33:38.91605Z","shell.execute_reply":"2024-02-01T10:33:38.920323Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"list_q = {'0-4':[1, 3], '5-12':[4, 5, 6, 7, 8, 9, 10, 11], '13-22':[14, 15, 16, 17]}\nlist_q_df = {'0-4':1, '5-12':2, '13-22':3}\nthreshold = 0.62\n\nfor (test, sample_submission) in iter_test:\n    sample_submission['question'] = [int(label.split('_')[1][1:]) for label in sample_submission['session_id']] \n    test = test.sort_values(by = 'elapsed_time')\n    grp = test.level_group.values[0]\n    session_id = test.session_id.values[0]\n    \n    test = test_day(test)\n    df = (pl.from_pandas(test)\n          .drop([\"fullscreen\", \"hq\", \"music\"])\n          .with_columns(columns))\n    df = df.with_columns(col2)\n    \n    df = feature_engineer(df, grp, use_extra=True, feature_suffix='',\n                          LEVELS=FEATURES_name_dict[f'LEVELS_{list_q_df[grp]}'],\n                          level_groups=FEATURES_name_dict[f'level_groups_{list_q_df[grp]}'],\n                          fqid_lists=FEATURES_name_dict[f'fqid_list_{list_q_df[grp]}'],\n                          text_lists=FEATURES_name_dict[f'text_list_{list_q_df[grp]}'],\n                          text_features=FEATURES_name_dict[f'text_features_{list_q_df[grp]}']\n                         )\n    df = make_plus_feature(df,\n                           LEVELS=FEATURES_name_dict[f'LEVELS_{list_q_df[grp]}'],\n                           level_groups=FEATURES_name_dict[f'level_groups_{list_q_df[grp]}'],\n                           fqid_lists=FEATURES_name_dict[f'fqid_list_{list_q_df[grp]}'],\n                           text_lists=FEATURES_name_dict[f'text_list_{list_q_df[grp]}'],\n                           text_features=FEATURES_name_dict[f'text_features_{list_q_df[grp]}']\n                          )\n    \n    if grp == \"5-12\":\n        df = pd.concat([df,df1],axis=1)\n    elif grp == \"13-22\":\n        df = pd.concat([df,df2],axis=1)\n    \n    sample_submission['correct'] = 1\n    sample_submission.loc[sample_submission.question.isin([5, 8, 10, 13, 15]), 'correct'] = 0  \n    \n    preds = []\n    for t in list_q[grp]:\n        pred_list = []\n        for fold in range(5):\n            xgb_model = xgb_dict[t][fold]\n            FEATURES = importance_dict[f'{t}_{fold}']\n            pred_list.append(xgb_model.predict_proba(df[FEATURES].astype('float32'))[:,1])\n\n        pred = np.mean(pred_list)\n\n        mask = sample_submission.session_id.str.contains(f'q{t}')\n        sample_submission.loc[mask,'correct'] = int(pred.item()>threshold)\n            \n    sample_submission = sample_submission[['session_id', 'correct']] \n    \n    if grp == \"0-4\":\n        df.rename(columns=rename_dict_1, inplace=True)\n        df1 = df.copy()\n    elif grp == \"5-12\":\n        df.rename(columns=rename_dict_2, inplace=True)\n        df2 = df.copy()\n    \n    env.predict(sample_submission)","metadata":{"execution":{"iopub.status.busy":"2024-02-01T10:33:39.33979Z","iopub.execute_input":"2024-02-01T10:33:39.340824Z","iopub.status.idle":"2024-02-01T10:33:55.456899Z","shell.execute_reply.started":"2024-02-01T10:33:39.340783Z","shell.execute_reply":"2024-02-01T10:33:55.456079Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub = pd.read_csv('/kaggle/working/submission.csv')\nprint(sub.shape, sub.correct.mean())\nsub.head()","metadata":{"execution":{"iopub.status.busy":"2024-02-01T10:34:09.032573Z","iopub.execute_input":"2024-02-01T10:34:09.032975Z","iopub.status.idle":"2024-02-01T10:34:09.051051Z","shell.execute_reply.started":"2024-02-01T10:34:09.032943Z","shell.execute_reply":"2024-02-01T10:34:09.049899Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}