{"metadata":{"kernelspec":{"name":"python3","display_name":"Python 3","language":"python"},"language_info":{"name":"python","version":"3.10.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":81933,"databundleVersionId":9643020,"sourceType":"competition"},{"sourceId":10320203,"sourceType":"datasetVersion","datasetId":6389522},{"sourceId":10320212,"sourceType":"datasetVersion","datasetId":6389546}],"isInternetEnabled":false,"language":"python","sourceType":"notebook","isGpuEnabled":false},"papermill":{"default_parameters":{},"duration":13.887202,"end_time":"2024-12-15T13:29:18.659245","environment_variables":{},"exception":null,"input_path":"__notebook__.ipynb","output_path":"__notebook__.ipynb","parameters":{},"start_time":"2024-12-15T13:29:04.772043","version":"2.6.0"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"!cp -r /kaggle/input/cmi2-pipeline/* /kaggle/working/","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-28T15:49:34.769959Z","iopub.execute_input":"2024-12-28T15:49:34.770322Z","iopub.status.idle":"2024-12-28T15:49:34.941146Z","shell.execute_reply.started":"2024-12-28T15:49:34.770296Z","shell.execute_reply":"2024-12-28T15:49:34.939891Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"exp_names = []","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-28T15:49:34.942899Z","iopub.execute_input":"2024-12-28T15:49:34.943343Z","iopub.status.idle":"2024-12-28T15:49:34.948431Z","shell.execute_reply.started":"2024-12-28T15:49:34.943290Z","shell.execute_reply":"2024-12-28T15:49:34.947231Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"exp_name = \"lgbm_regressor\"\n\n!python3 inference.py \\\n    model_name=CustomLGBMRegressor \\\n    data_dir=/kaggle/input/child-mind-institute-problematic-internet-use \\\n    output_dir=/kaggle/working/{exp_name} \\\n    exp_name={exp_name} \\\n    model_path=/kaggle/input/cmi2-pipeline-results/results/{exp_name}/total_models.pkl \\\n    phase=test\n\nexp_names.append(exp_name)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-28T15:49:34.950514Z","iopub.execute_input":"2024-12-28T15:49:34.950851Z","iopub.status.idle":"2024-12-28T15:49:51.866757Z","shell.execute_reply.started":"2024-12-28T15:49:34.950817Z","shell.execute_reply":"2024-12-28T15:49:51.865464Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"exp_name = \"lgbm_classifier\"\n\n!python3 inference.py \\\n    model_name=CustomLGBMClassifier \\\n    data_dir=/kaggle/input/child-mind-institute-problematic-internet-use \\\n    output_dir=/kaggle/working/{exp_name} \\\n    exp_name={exp_name} \\\n    model_path=/kaggle/input/cmi2-pipeline-results/results/{exp_name}/total_models.pkl \\\n    phase=test\n\nexp_names.append(exp_name)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-28T15:49:51.868633Z","iopub.execute_input":"2024-12-28T15:49:51.868922Z","iopub.status.idle":"2024-12-28T15:50:06.790900Z","shell.execute_reply.started":"2024-12-28T15:49:51.868899Z","shell.execute_reply":"2024-12-28T15:50:06.789691Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"exp_name = \"xgb_regressor\"\n\n!python3 inference.py \\\n    model_name=CustomXGBRegressor \\\n    data_dir=/kaggle/input/child-mind-institute-problematic-internet-use \\\n    output_dir=/kaggle/working/{exp_name} \\\n    exp_name={exp_name} \\\n    model_path=/kaggle/input/cmi2-pipeline-results/results/{exp_name}/total_models.pkl \\\n    phase=test\n\nexp_names.append(exp_name)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-28T15:50:06.792121Z","iopub.execute_input":"2024-12-28T15:50:06.792503Z","iopub.status.idle":"2024-12-28T15:50:18.606228Z","shell.execute_reply.started":"2024-12-28T15:50:06.792474Z","shell.execute_reply":"2024-12-28T15:50:18.605116Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"exp_name = \"xgb_classifier\"\n\n!python3 inference.py \\\n    model_name=CustomXGBClassifier \\\n    data_dir=/kaggle/input/child-mind-institute-problematic-internet-use \\\n    output_dir=/kaggle/working/{exp_name} \\\n    exp_name={exp_name} \\\n    model_path=/kaggle/input/cmi2-pipeline-results/results/{exp_name}/total_models.pkl \\\n    phase=test\n\nexp_names.append(exp_name)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-28T15:50:18.607493Z","iopub.execute_input":"2024-12-28T15:50:18.607893Z","iopub.status.idle":"2024-12-28T15:50:34.737550Z","shell.execute_reply.started":"2024-12-28T15:50:18.607864Z","shell.execute_reply":"2024-12-28T15:50:34.736410Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from scipy import stats\nimport pandas as pd\nimport numpy as np","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-28T15:50:34.738694Z","iopub.execute_input":"2024-12-28T15:50:34.738977Z","iopub.status.idle":"2024-12-28T15:50:35.518230Z","shell.execute_reply.started":"2024-12-28T15:50:34.738943Z","shell.execute_reply":"2024-12-28T15:50:35.517189Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def voting(array_2d):\n    # axis=0で各列について最頻値を計算\n    # mode関数は(最頻値, 出現回数)のタプルを返すため[0]で最頻値のみを取得\n    return stats.mode(array_2d, axis=0)[0]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-28T15:50:35.521336Z","iopub.execute_input":"2024-12-28T15:50:35.521904Z","iopub.status.idle":"2024-12-28T15:50:35.526085Z","shell.execute_reply.started":"2024-12-28T15:50:35.521872Z","shell.execute_reply":"2024-12-28T15:50:35.525125Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_subm = pd.read_csv(\"/kaggle/input/child-mind-institute-problematic-internet-use/sample_submission.csv\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-28T15:50:35.527492Z","iopub.execute_input":"2024-12-28T15:50:35.527792Z","iopub.status.idle":"2024-12-28T15:50:35.547885Z","shell.execute_reply.started":"2024-12-28T15:50:35.527766Z","shell.execute_reply":"2024-12-28T15:50:35.546875Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_preds = []\nfor exp_name in exp_names:\n    test_pred = np.load(f'/kaggle/working/{exp_name}/submission.npy')\n    test_preds.extend(test_pred)\ntest_preds = np.array(test_preds)\ntest_preds.shape","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-28T15:50:35.548915Z","iopub.execute_input":"2024-12-28T15:50:35.549166Z","iopub.status.idle":"2024-12-28T15:50:35.563195Z","shell.execute_reply.started":"2024-12-28T15:50:35.549136Z","shell.execute_reply":"2024-12-28T15:50:35.562118Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_pred = voting(test_preds)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-28T15:50:35.564145Z","iopub.execute_input":"2024-12-28T15:50:35.564528Z","iopub.status.idle":"2024-12-28T15:50:35.576508Z","shell.execute_reply.started":"2024-12-28T15:50:35.564499Z","shell.execute_reply":"2024-12-28T15:50:35.575541Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!rm -rf /kaggle/working/*","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-28T15:50:35.577657Z","iopub.execute_input":"2024-12-28T15:50:35.578018Z","iopub.status.idle":"2024-12-28T15:50:35.715546Z","shell.execute_reply.started":"2024-12-28T15:50:35.577982Z","shell.execute_reply":"2024-12-28T15:50:35.714194Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_subm[\"sii\"] = test_pred.reshape(-1)\ndf_subm.to_csv(\"submission.csv\", index=False)","metadata":{"papermill":{"duration":0.0176,"end_time":"2024-12-15T13:29:17.69542","exception":false,"start_time":"2024-12-15T13:29:17.67782","status":"completed"},"tags":[],"trusted":true,"execution":{"iopub.status.busy":"2024-12-28T15:50:35.716811Z","iopub.execute_input":"2024-12-28T15:50:35.717119Z","iopub.status.idle":"2024-12-28T15:50:35.726794Z","shell.execute_reply.started":"2024-12-28T15:50:35.717094Z","shell.execute_reply":"2024-12-28T15:50:35.725700Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_subm","metadata":{"papermill":{"duration":0.023608,"end_time":"2024-12-15T13:29:17.724185","exception":false,"start_time":"2024-12-15T13:29:17.700577","status":"completed"},"tags":[],"trusted":true,"execution":{"iopub.status.busy":"2024-12-28T15:50:35.727898Z","iopub.execute_input":"2024-12-28T15:50:35.728235Z","iopub.status.idle":"2024-12-28T15:50:35.757089Z","shell.execute_reply.started":"2024-12-28T15:50:35.728211Z","shell.execute_reply":"2024-12-28T15:50:35.756118Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"papermill":{"duration":0.004317,"end_time":"2024-12-15T13:29:17.733205","exception":false,"start_time":"2024-12-15T13:29:17.728888","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null}]}