{"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":"gpu","dataSources":[{"sourceType":"competition","sourceId":132009,"databundleVersionId":15879574}],"dockerImageVersionId":31287,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import pandas as pd\nfrom catboost import CatBoostClassifier\nfrom sklearn.model_selection import train_test_split","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2026-03-04T09:32:39.403120Z","iopub.execute_input":"2026-03-04T09:32:39.403658Z","iopub.status.idle":"2026-03-04T09:32:39.407213Z","shell.execute_reply.started":"2026-03-04T09:32:39.403626Z","shell.execute_reply":"2026-03-04T09:32:39.406418Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train = pd.read_parquet('/kaggle/input/competitions/SBOR_VSOSH_SREZ_2/train.parquet').drop_duplicates(subset=['id'])\ntest = pd.read_parquet('/kaggle/input/competitions/SBOR_VSOSH_SREZ_2/test.parquet').drop_duplicates(subset=['id'])\ntarget_train = pd.read_csv('/kaggle/input/competitions/SBOR_VSOSH_SREZ_2/target_train.csv')\nsample_subm = pd.read_csv('/kaggle/input/competitions/SBOR_VSOSH_SREZ_2/sample_submission_vsosh.csv')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-04T09:36:19.048808Z","iopub.execute_input":"2026-03-04T09:36:19.049413Z","iopub.status.idle":"2026-03-04T09:36:22.608871Z","shell.execute_reply.started":"2026-03-04T09:36:19.049387Z","shell.execute_reply":"2026-03-04T09:36:22.608074Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"target_train['flag'].value_counts()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-04T09:32:42.999404Z","iopub.execute_input":"2026-03-04T09:32:42.999789Z","iopub.status.idle":"2026-03-04T09:32:43.010743Z","shell.execute_reply.started":"2026-03-04T09:32:42.999757Z","shell.execute_reply":"2026-03-04T09:32:43.010018Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-04T09:32:43.011752Z","iopub.execute_input":"2026-03-04T09:32:43.012036Z","iopub.status.idle":"2026-03-04T09:32:43.057279Z","shell.execute_reply.started":"2026-03-04T09:32:43.012009Z","shell.execute_reply":"2026-03-04T09:32:43.056708Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print(len(train), len(target_train), len(train) - len(target_train))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-04T09:32:43.059147Z","iopub.execute_input":"2026-03-04T09:32:43.059453Z","iopub.status.idle":"2026-03-04T09:32:43.063286Z","shell.execute_reply.started":"2026-03-04T09:32:43.059430Z","shell.execute_reply":"2026-03-04T09:32:43.062640Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-04T09:32:43.064104Z","iopub.execute_input":"2026-03-04T09:32:43.064377Z","iopub.status.idle":"2026-03-04T09:32:43.204315Z","shell.execute_reply.started":"2026-03-04T09:32:43.064351Z","shell.execute_reply":"2026-03-04T09:32:43.203533Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train.columns","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-04T09:32:43.205349Z","iopub.execute_input":"2026-03-04T09:32:43.205906Z","iopub.status.idle":"2026-03-04T09:32:43.210592Z","shell.execute_reply.started":"2026-03-04T09:32:43.205873Z","shell.execute_reply":"2026-03-04T09:32:43.209913Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"cat_features = []\nfor i in train.columns:\n    print(i, train[i].unique())\n    if train[i].dtype == 'object' or len(train[i].unique()) < 10:\n        cat_features.append(i)\ncat_features","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-04T09:32:43.211432Z","iopub.execute_input":"2026-03-04T09:32:43.211684Z","iopub.status.idle":"2026-03-04T09:32:43.966368Z","shell.execute_reply.started":"2026-03-04T09:32:43.211664Z","shell.execute_reply":"2026-03-04T09:32:43.965800Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"X, y = train.drop(columns=['id']), target_train['flag']\nprint(len(X), len(y))\nX_test, X_val, y_test, y_val = train_test_split(X, y, stratify=y)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-04T09:32:43.967143Z","iopub.execute_input":"2026-03-04T09:32:43.967385Z","iopub.status.idle":"2026-03-04T09:32:45.010720Z","shell.execute_reply.started":"2026-03-04T09:32:43.967362Z","shell.execute_reply":"2026-03-04T09:32:45.009911Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model = CatBoostClassifier(cat_features=cat_features, loss_function='Logloss',\n    eval_metric='AUC', verbose=100, task_type='GPU', iterations=3000)\nmodel.fit(X_test, y_test, eval_set=(X_val, y_val))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-04T09:40:35.306648Z","iopub.execute_input":"2026-03-04T09:40:35.306999Z","iopub.status.idle":"2026-03-04T09:47:33.924074Z","shell.execute_reply.started":"2026-03-04T09:40:35.306971Z","shell.execute_reply":"2026-03-04T09:47:33.923342Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"preds = model.predict_proba(test.drop(columns=['id']))[:, 1]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-04T09:35:58.378004Z","iopub.execute_input":"2026-03-04T09:35:58.378611Z","iopub.status.idle":"2026-03-04T09:36:01.837775Z","shell.execute_reply.started":"2026-03-04T09:35:58.378578Z","shell.execute_reply":"2026-03-04T09:36:01.837156Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"preds","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-04T09:36:03.890499Z","iopub.execute_input":"2026-03-04T09:36:03.891245Z","iopub.status.idle":"2026-03-04T09:36:03.896228Z","shell.execute_reply.started":"2026-03-04T09:36:03.891216Z","shell.execute_reply":"2026-03-04T09:36:03.895606Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print(len(preds) - len(test))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-04T09:36:04.780072Z","iopub.execute_input":"2026-03-04T09:36:04.780753Z","iopub.status.idle":"2026-03-04T09:36:04.784556Z","shell.execute_reply.started":"2026-03-04T09:36:04.780725Z","shell.execute_reply":"2026-03-04T09:36:04.783783Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"sample_subm['flag'] = preds\nsample_subm.to_csv('subm_vsos2.csv', index=False)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-04T09:36:33.223820Z","iopub.execute_input":"2026-03-04T09:36:33.224109Z","iopub.status.idle":"2026-03-04T09:36:33.700683Z","shell.execute_reply.started":"2026-03-04T09:36:33.224084Z","shell.execute_reply":"2026-03-04T09:36:33.699731Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"sample_subm","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}