{"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 pandas as pd, numpy as np, gc\n\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\n\nfrom sklearn.model_selection import StratifiedKFold\nfrom sklearn.preprocessing import OrdinalEncoder\nfrom sklearn.preprocessing import LabelEncoder\nfrom sklearn.metrics import roc_auc_score\nfrom sklearn.model_selection import train_test_split\n\nfrom sklearn.metrics import confusion_matrix, accuracy_score, precision_score, recall_score, f1_score\nfrom sklearn.metrics import roc_auc_score\n\n\nfrom catboost import CatBoostClassifier, Pool\n\n\nfrom matplotlib import ticker\nimport time\nimport warnings\nwarnings.filterwarnings('ignore')\n\n\nfrom sklearn.model_selection import KFold, GroupKFold\nfrom sklearn.metrics import f1_score\nimport gc\nimport random","metadata":{"execution":{"iopub.status.busy":"2023-04-30T09:13:09.954040Z","iopub.execute_input":"2023-04-30T09:13:09.955019Z","iopub.status.idle":"2023-04-30T09:13:11.840980Z","shell.execute_reply.started":"2023-04-30T09:13:09.954899Z","shell.execute_reply":"2023-04-30T09:13:11.839913Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# # READ USER ID ONLY\ntype_dic = {'session_id': 'category',\n          'elapsed_time': np.int32,\n          'event_name': 'category',\n          'name': 'category',\n          'level': np.uint8,\n          'page': 'category',\n          'room_coor_x': np.float32,\n          'room_coor_y': np.float32,\n          'screen_coor_x': np.float32,\n          'screen_coor_y': np.float32,\n          'hover_duration': np.float32,\n          'text': 'category',\n          'fqid': 'category',\n          'room_fqid': 'category',\n          'text_fqid': 'category',\n          'fullscreen': np.int8,\n          'hq': np.int8,\n          'music': np.int8,\n          'level_group': 'category'}\n# 本番はちゃんとnrowsを消す！\ntrain_df = pd.read_csv(\"/kaggle/input/predict-student-performance-from-game-play/train.csv\", dtype=type_dic)\ntrain_df.head(10)\n","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2023-04-30T09:13:11.847323Z","iopub.execute_input":"2023-04-30T09:13:11.849012Z","iopub.status.idle":"2023-04-30T09:15:32.886705Z","shell.execute_reply.started":"2023-04-30T09:13:11.848967Z","shell.execute_reply":"2023-04-30T09:15:32.885603Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# 以下テスト\n* models, best_thresholdが必要","metadata":{}},{"cell_type":"code","source":"import jo_wilder\nenv = jo_wilder.make_env()\niter_test = env.iter_test()","metadata":{"execution":{"iopub.status.busy":"2023-04-30T09:15:32.888488Z","iopub.execute_input":"2023-04-30T09:15:32.888832Z","iopub.status.idle":"2023-04-30T09:15:32.913633Z","shell.execute_reply.started":"2023-04-30T09:15:32.888801Z","shell.execute_reply":"2023-04-30T09:15:32.912724Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"counter = 0\n# The API will deliver two dataframes in this specific order,\n# for every session+level grouping (one group per session for each checkpoint)\nfor (test, sample_submission) in iter_test:\n    if counter == 0:\n        print(sample_submission.head())\n        print(test.head())\n        print(test.shape)\n    \n    x = random.randint(0, 1)\n    print(x)\n    ## users make predictions here using the test data\n    sample_submission['correct'] = x\n    \n    ## env.predict appends the session+level sample_submission to the overall\n    ## submission\n    env.predict(sample_submission)\n    counter += 1","metadata":{"execution":{"iopub.status.busy":"2023-04-30T09:15:32.915666Z","iopub.execute_input":"2023-04-30T09:15:32.916220Z","iopub.status.idle":"2023-04-30T09:15:32.997265Z","shell.execute_reply.started":"2023-04-30T09:15:32.916186Z","shell.execute_reply":"2023-04-30T09:15:32.995921Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"## the end result is a submission file containing all test session predictions\n! head submission.csv","metadata":{"execution":{"iopub.status.busy":"2023-04-30T09:15:32.998858Z","iopub.execute_input":"2023-04-30T09:15:32.999307Z","iopub.status.idle":"2023-04-30T09:15:34.141652Z","shell.execute_reply.started":"2023-04-30T09:15:32.999273Z","shell.execute_reply":"2023-04-30T09:15:34.139985Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}