{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.12.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceType":"competition","sourceId":132009,"databundleVersionId":15879574}],"dockerImageVersionId":31286,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nfrom sklearn.metrics import  roc_auc_score\nfrom sklearn.model_selection import StratifiedKFold\nimport gc\nfrom sklearn.ensemble import RandomForestClassifier\nimport os","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2026-03-01T14:49:20.123889Z","iopub.execute_input":"2026-03-01T14:49:20.124283Z","iopub.status.idle":"2026-03-01T14:49:20.132678Z","shell.execute_reply.started":"2026-03-01T14:49:20.124243Z","shell.execute_reply":"2026-03-01T14:49:20.129909Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train = pd.read_parquet('/kaggle/input/competitions/SBOR_VSOSH_SREZ_2/train.parquet')\ntest = pd.read_parquet('/kaggle/input/competitions/SBOR_VSOSH_SREZ_2/test.parquet')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-01T14:49:23.239485Z","iopub.execute_input":"2026-03-01T14:49:23.240549Z","iopub.status.idle":"2026-03-01T14:49:33.616327Z","shell.execute_reply.started":"2026-03-01T14:49:23.240498Z","shell.execute_reply":"2026-03-01T14:49:33.615281Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ltr = len(train['id'].unique())\nltr","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-01T14:50:21.012709Z","iopub.execute_input":"2026-03-01T14:50:21.013071Z","iopub.status.idle":"2026-03-01T14:50:21.021385Z","shell.execute_reply.started":"2026-03-01T14:50:21.013032Z","shell.execute_reply":"2026-03-01T14:50:21.020005Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"target_data = pd.read_csv('/kaggle/input/competitions/SBOR_VSOSH_SREZ_2/target_train.csv')\nsample_submission = pd.read_csv('/kaggle/input/competitions/SBOR_VSOSH_SREZ_2/sample_submission_vsosh.csv')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-01T14:49:33.718640Z","iopub.execute_input":"2026-03-01T14:49:33.719036Z","iopub.status.idle":"2026-03-01T14:49:34.011256Z","shell.execute_reply.started":"2026-03-01T14:49:33.718994Z","shell.execute_reply":"2026-03-01T14:49:34.009821Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data = pd.concat([train, test]).reset_index(drop = True)\n\ndel train, test\ngc.collect()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-01T14:49:34.013361Z","iopub.execute_input":"2026-03-01T14:49:34.013865Z","iopub.status.idle":"2026-03-01T14:49:46.169078Z","shell.execute_reply.started":"2026-03-01T14:49:34.013712Z","shell.execute_reply":"2026-03-01T14:49:46.167640Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_data = data.sort_values(['id', 'rn']).drop_duplicates('id', keep = 'last')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-01T14:49:46.171091Z","iopub.execute_input":"2026-03-01T14:49:46.171480Z","iopub.status.idle":"2026-03-01T14:49:52.351108Z","shell.execute_reply.started":"2026-03-01T14:49:46.171430Z","shell.execute_reply":"2026-03-01T14:49:52.349676Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_data['target'] = train_data['id'].map(target_data.set_index('id')['flag'])","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-01T14:49:52.352492Z","iopub.execute_input":"2026-03-01T14:49:52.352861Z","iopub.status.idle":"2026-03-01T14:49:52.413440Z","shell.execute_reply.started":"2026-03-01T14:49:52.352818Z","shell.execute_reply":"2026-03-01T14:49:52.412434Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"target = 'target'\ntrain_cols = [x for x in train_data.columns if x not in [target]]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-01T14:49:52.415324Z","iopub.execute_input":"2026-03-01T14:49:52.415700Z","iopub.status.idle":"2026-03-01T14:49:52.420565Z","shell.execute_reply.started":"2026-03-01T14:49:52.415661Z","shell.execute_reply":"2026-03-01T14:49:52.419525Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_data[target].values[:ltr].shape","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-01T14:50:11.301486Z","iopub.execute_input":"2026-03-01T14:50:11.301822Z","iopub.status.idle":"2026-03-01T14:50:11.308022Z","shell.execute_reply.started":"2026-03-01T14:50:11.301795Z","shell.execute_reply":"2026-03-01T14:50:11.307125Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"rf = RandomForestClassifier(n_estimators = 100)\nrf.fit(train_data[train_cols].values[:ltr][::3], train_data[target].values[:ltr][::3])\npredict = rf.predict_proba(train_data[train_cols].values[ltr:])[:, 1]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-01T14:49:59.914128Z","iopub.execute_input":"2026-03-01T14:49:59.914541Z","iopub.status.idle":"2026-03-01T14:50:00.191916Z","shell.execute_reply.started":"2026-03-01T14:49:59.914509Z","shell.execute_reply":"2026-03-01T14:50:00.190518Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"sample_submission['flag'] = predict\nsample_submission.to_csv('baseline.csv', index = None)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-01T14:41:24.789157Z","iopub.execute_input":"2026-03-01T14:41:24.789596Z","iopub.status.idle":"2026-03-01T14:41:25.131154Z","shell.execute_reply.started":"2026-03-01T14:41:24.789560Z","shell.execute_reply":"2026-03-01T14:41:25.129982Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}