{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.11.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"nvidiaTeslaT4","dataSources":[{"sourceId":20270,"databundleVersionId":1222630,"sourceType":"competition"},{"sourceId":39944301,"sourceType":"kernelVersion"}],"dockerImageVersionId":31090,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"!pip install xgboost\n\nimport numpy as np\nimport pandas as pd\n\nimport xgboost as xgb\nfrom sklearn.metrics import accuracy_score","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2025-08-24T07:34:45.719376Z","iopub.execute_input":"2025-08-24T07:34:45.719598Z","iopub.status.idle":"2025-08-24T07:34:51.331937Z","shell.execute_reply.started":"2025-08-24T07:34:45.71958Z","shell.execute_reply":"2025-08-24T07:34:51.331343Z"},"trusted":true},"outputs":[{"name":"stdout","text":"Requirement already satisfied: xgboost in /usr/local/lib/python3.11/dist-packages (2.0.3)\nRequirement already satisfied: numpy in /usr/local/lib/python3.11/dist-packages (from xgboost) (1.26.4)\nRequirement already satisfied: scipy in /usr/local/lib/python3.11/dist-packages (from xgboost) (1.15.3)\nRequirement already satisfied: mkl_fft in /usr/local/lib/python3.11/dist-packages (from numpy->xgboost) (1.3.8)\nRequirement already satisfied: mkl_random in /usr/local/lib/python3.11/dist-packages (from numpy->xgboost) (1.2.4)\nRequirement already satisfied: mkl_umath in /usr/local/lib/python3.11/dist-packages (from numpy->xgboost) (0.1.1)\nRequirement already satisfied: mkl in /usr/local/lib/python3.11/dist-packages (from numpy->xgboost) (2025.2.0)\nRequirement already satisfied: tbb4py in /usr/local/lib/python3.11/dist-packages (from numpy->xgboost) (2022.2.0)\nRequirement already satisfied: mkl-service in /usr/local/lib/python3.11/dist-packages (from numpy->xgboost) (2.4.1)\nRequirement already satisfied: intel-openmp<2026,>=2024 in /usr/local/lib/python3.11/dist-packages (from mkl->numpy->xgboost) (2024.2.0)\nRequirement already satisfied: tbb==2022.* in /usr/local/lib/python3.11/dist-packages (from mkl->numpy->xgboost) (2022.2.0)\nRequirement already satisfied: tcmlib==1.* in /usr/local/lib/python3.11/dist-packages (from tbb==2022.*->mkl->numpy->xgboost) (1.4.0)\nRequirement already satisfied: intel-cmplr-lib-rt in /usr/local/lib/python3.11/dist-packages (from mkl_umath->numpy->xgboost) (2024.2.0)\nRequirement already satisfied: intel-cmplr-lib-ur==2024.2.0 in /usr/local/lib/python3.11/dist-packages (from intel-openmp<2026,>=2024->mkl->numpy->xgboost) (2024.2.0)\n","output_type":"stream"}],"execution_count":1},{"cell_type":"code","source":"train= pd.read_csv('../input/siim-isic-melanoma-classification/train.csv')\ntest= pd.read_csv('../input/siim-isic-melanoma-classification/test.csv')\nsub   = pd.read_csv('../input/siim-isic-melanoma-classification/sample_submission.csv')\n# train.head()\n\n# train.target.value_counts()","metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","execution":{"iopub.status.busy":"2025-08-24T07:34:51.332688Z","iopub.execute_input":"2025-08-24T07:34:51.332964Z","iopub.status.idle":"2025-08-24T07:34:51.452435Z","shell.execute_reply.started":"2025-08-24T07:34:51.332946Z","shell.execute_reply":"2025-08-24T07:34:51.451795Z"},"trusted":true},"outputs":[],"execution_count":2},{"cell_type":"code","source":"train","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-08-24T07:34:51.454236Z","iopub.execute_input":"2025-08-24T07:34:51.454485Z","iopub.status.idle":"2025-08-24T07:34:51.48278Z","shell.execute_reply.started":"2025-08-24T07:34:51.454459Z","shell.execute_reply":"2025-08-24T07:34:51.48203Z"}},"outputs":[{"execution_count":3,"output_type":"execute_result","data":{"text/plain":"         image_name  patient_id     sex  age_approx  \\\n0      ISIC_2637011  IP_7279968    male        45.0   \n1      ISIC_0015719  IP_3075186  female        45.0   \n2      ISIC_0052212  IP_2842074  female        50.0   \n3      ISIC_0068279  IP_6890425  female        45.0   \n4      ISIC_0074268  IP_8723313  female        55.0   \n...             ...         ...     ...         ...   \n33121  ISIC_9999134  IP_6526534    male        50.0   \n33122  ISIC_9999320  IP_3650745    male        65.0   \n33123  ISIC_9999515  IP_2026598    male        20.0   \n33124  ISIC_9999666  IP_7702038    male        50.0   \n33125  ISIC_9999806  IP_0046310    male        45.0   \n\n      anatom_site_general_challenge diagnosis benign_malignant  target  \n0                         head/neck   unknown           benign       0  \n1                   upper extremity   unknown           benign       0  \n2                   lower extremity     nevus           benign       0  \n3                         head/neck   unknown           benign       0  \n4                   upper extremity   unknown           benign       0  \n...                             ...       ...              ...     ...  \n33121                         torso   unknown           benign       0  \n33122                         torso   unknown           benign       0  \n33123               lower extremity   unknown           benign       0  \n33124               lower extremity   unknown           benign       0  \n33125                         torso     nevus           benign       0  \n\n[33126 rows x 8 columns]","text/html":"<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>image_name</th>\n      <th>patient_id</th>\n      <th>sex</th>\n      <th>age_approx</th>\n      <th>anatom_site_general_challenge</th>\n      <th>diagnosis</th>\n      <th>benign_malignant</th>\n      <th>target</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>ISIC_2637011</td>\n      <td>IP_7279968</td>\n      <td>male</td>\n      <td>45.0</td>\n      <td>head/neck</td>\n      <td>unknown</td>\n      <td>benign</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>ISIC_0015719</td>\n      <td>IP_3075186</td>\n      <td>female</td>\n      <td>45.0</td>\n      <td>upper extremity</td>\n      <td>unknown</td>\n      <td>benign</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>ISIC_0052212</td>\n      <td>IP_2842074</td>\n      <td>female</td>\n      <td>50.0</td>\n      <td>lower extremity</td>\n      <td>nevus</td>\n      <td>benign</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>ISIC_0068279</td>\n      <td>IP_6890425</td>\n      <td>female</td>\n      <td>45.0</td>\n      <td>head/neck</td>\n      <td>unknown</td>\n      <td>benign</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>ISIC_0074268</td>\n      <td>IP_8723313</td>\n      <td>female</td>\n      <td>55.0</td>\n      <td>upper extremity</td>\n      <td>unknown</td>\n      <td>benign</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>33121</th>\n      <td>ISIC_9999134</td>\n      <td>IP_6526534</td>\n      <td>male</td>\n      <td>50.0</td>\n      <td>torso</td>\n      <td>unknown</td>\n      <td>benign</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>33122</th>\n      <td>ISIC_9999320</td>\n      <td>IP_3650745</td>\n      <td>male</td>\n      <td>65.0</td>\n      <td>torso</td>\n      <td>unknown</td>\n      <td>benign</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>33123</th>\n      <td>ISIC_9999515</td>\n      <td>IP_2026598</td>\n      <td>male</td>\n      <td>20.0</td>\n      <td>lower extremity</td>\n      <td>unknown</td>\n      <td>benign</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>33124</th>\n      <td>ISIC_9999666</td>\n      <td>IP_7702038</td>\n      <td>male</td>\n      <td>50.0</td>\n      <td>lower extremity</td>\n      <td>unknown</td>\n      <td>benign</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>33125</th>\n      <td>ISIC_9999806</td>\n      <td>IP_0046310</td>\n      <td>male</td>\n      <td>45.0</td>\n      <td>torso</td>\n      <td>nevus</td>\n      <td>benign</td>\n      <td>0</td>\n    </tr>\n  </tbody>\n</table>\n<p>33126 rows × 8 columns</p>\n</div>"},"metadata":{}}],"execution_count":3},{"cell_type":"code","source":"train['sex'] = train['sex'].fillna('na')\ntrain['age_approx'] = train['age_approx'].fillna(0)\ntrain['anatom_site_general_challenge'] = train['anatom_site_general_challenge'].fillna('na')\n\ntest['sex'] = test['sex'].fillna('na')\ntest['age_approx'] = test['age_approx'].fillna(0)\ntest['anatom_site_general_challenge'] = test['anatom_site_general_challenge'].fillna('na')","metadata":{"execution":{"iopub.status.busy":"2025-08-24T07:34:51.48361Z","iopub.execute_input":"2025-08-24T07:34:51.484429Z","iopub.status.idle":"2025-08-24T07:34:51.497049Z","shell.execute_reply.started":"2025-08-24T07:34:51.484366Z","shell.execute_reply":"2025-08-24T07:34:51.496639Z"},"trusted":true},"outputs":[],"execution_count":4},{"cell_type":"code","source":"train['anatom_site_general_challenge'].unique()","metadata":{"execution":{"iopub.status.busy":"2025-08-24T07:34:51.498074Z","iopub.execute_input":"2025-08-24T07:34:51.498381Z","iopub.status.idle":"2025-08-24T07:34:51.514897Z","shell.execute_reply.started":"2025-08-24T07:34:51.498339Z","shell.execute_reply":"2025-08-24T07:34:51.514149Z"},"trusted":true},"outputs":[{"execution_count":5,"output_type":"execute_result","data":{"text/plain":"array(['head/neck', 'upper extremity', 'lower extremity', 'torso', 'na',\n       'palms/soles', 'oral/genital'], dtype=object)"},"metadata":{}}],"execution_count":5},{"cell_type":"code","source":"train['sex'] = train['sex'].astype(\"category\").cat.codes +1\ntrain['anatom_site_general_challenge'] = train['anatom_site_general_challenge'].astype(\"category\").cat.codes +1\ntrain.head()","metadata":{"execution":{"iopub.status.busy":"2025-08-24T07:34:51.515638Z","iopub.execute_input":"2025-08-24T07:34:51.515832Z","iopub.status.idle":"2025-08-24T07:34:51.540581Z","shell.execute_reply.started":"2025-08-24T07:34:51.515809Z","shell.execute_reply":"2025-08-24T07:34:51.53987Z"},"trusted":true},"outputs":[{"execution_count":6,"output_type":"execute_result","data":{"text/plain":"     image_name  patient_id  sex  age_approx  anatom_site_general_challenge  \\\n0  ISIC_2637011  IP_7279968    2        45.0                              1   \n1  ISIC_0015719  IP_3075186    1        45.0                              7   \n2  ISIC_0052212  IP_2842074    1        50.0                              2   \n3  ISIC_0068279  IP_6890425    1        45.0                              1   \n4  ISIC_0074268  IP_8723313    1        55.0                              7   \n\n  diagnosis benign_malignant  target  \n0   unknown           benign       0  \n1   unknown           benign       0  \n2     nevus           benign       0  \n3   unknown           benign       0  \n4   unknown           benign       0  ","text/html":"<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>image_name</th>\n      <th>patient_id</th>\n      <th>sex</th>\n      <th>age_approx</th>\n      <th>anatom_site_general_challenge</th>\n      <th>diagnosis</th>\n      <th>benign_malignant</th>\n      <th>target</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>ISIC_2637011</td>\n      <td>IP_7279968</td>\n      <td>2</td>\n      <td>45.0</td>\n      <td>1</td>\n      <td>unknown</td>\n      <td>benign</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>ISIC_0015719</td>\n      <td>IP_3075186</td>\n      <td>1</td>\n      <td>45.0</td>\n      <td>7</td>\n      <td>unknown</td>\n      <td>benign</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>ISIC_0052212</td>\n      <td>IP_2842074</td>\n      <td>1</td>\n      <td>50.0</td>\n      <td>2</td>\n      <td>nevus</td>\n      <td>benign</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>ISIC_0068279</td>\n      <td>IP_6890425</td>\n      <td>1</td>\n      <td>45.0</td>\n      <td>1</td>\n      <td>unknown</td>\n      <td>benign</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>ISIC_0074268</td>\n      <td>IP_8723313</td>\n      <td>1</td>\n      <td>55.0</td>\n      <td>7</td>\n      <td>unknown</td>\n      <td>benign</td>\n      <td>0</td>\n    </tr>\n  </tbody>\n</table>\n</div>"},"metadata":{}}],"execution_count":6},{"cell_type":"code","source":"test['sex'] = test['sex'].astype(\"category\").cat.codes +1\ntest['anatom_site_general_challenge'] = test['anatom_site_general_challenge'].astype(\"category\").cat.codes +1\ntest.head()","metadata":{"execution":{"iopub.status.busy":"2025-08-24T07:34:51.541448Z","iopub.execute_input":"2025-08-24T07:34:51.541693Z","iopub.status.idle":"2025-08-24T07:34:51.552482Z","shell.execute_reply.started":"2025-08-24T07:34:51.54167Z","shell.execute_reply":"2025-08-24T07:34:51.551831Z"},"trusted":true},"outputs":[{"execution_count":7,"output_type":"execute_result","data":{"text/plain":"     image_name  patient_id  sex  age_approx  anatom_site_general_challenge\n0  ISIC_0052060  IP_3579794    2        70.0                              3\n1  ISIC_0052349  IP_7782715    2        40.0                              2\n2  ISIC_0058510  IP_7960270    1        55.0                              6\n3  ISIC_0073313  IP_6375035    1        50.0                              6\n4  ISIC_0073502  IP_0589375    1        45.0                              2","text/html":"<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>image_name</th>\n      <th>patient_id</th>\n      <th>sex</th>\n      <th>age_approx</th>\n      <th>anatom_site_general_challenge</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>ISIC_0052060</td>\n      <td>IP_3579794</td>\n      <td>2</td>\n      <td>70.0</td>\n      <td>3</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>ISIC_0052349</td>\n      <td>IP_7782715</td>\n      <td>2</td>\n      <td>40.0</td>\n      <td>2</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>ISIC_0058510</td>\n      <td>IP_7960270</td>\n      <td>1</td>\n      <td>55.0</td>\n      <td>6</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>ISIC_0073313</td>\n      <td>IP_6375035</td>\n      <td>1</td>\n      <td>50.0</td>\n      <td>6</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>ISIC_0073502</td>\n      <td>IP_0589375</td>\n      <td>1</td>\n      <td>45.0</td>\n      <td>2</td>\n    </tr>\n  </tbody>\n</table>\n</div>"},"metadata":{}}],"execution_count":7},{"cell_type":"code","source":"x_train = train[['sex', 'age_approx','anatom_site_general_challenge']]\ny_train = train['target']\n\n\nx_test = test[['sex', 'age_approx','anatom_site_general_challenge']]\n# y_train = test['target']\n\n\ntrain_DMatrix = xgb.DMatrix(x_train, label= y_train)\ntest_DMatrix = xgb.DMatrix(x_test)","metadata":{"execution":{"iopub.status.busy":"2025-08-24T07:34:51.553143Z","iopub.execute_input":"2025-08-24T07:34:51.5534Z","iopub.status.idle":"2025-08-24T07:34:51.675182Z","shell.execute_reply.started":"2025-08-24T07:34:51.553377Z","shell.execute_reply":"2025-08-24T07:34:51.674623Z"},"trusted":true},"outputs":[],"execution_count":8},{"cell_type":"code","source":"param = {\n    'booster':'gbtree', \n    'eta': 0.3,\n    'num_class': 2,\n    'max_depth': 8\n}\n\nepochs = 100","metadata":{"execution":{"iopub.status.busy":"2025-08-24T07:34:51.677821Z","iopub.execute_input":"2025-08-24T07:34:51.678403Z","iopub.status.idle":"2025-08-24T07:34:51.6824Z","shell.execute_reply.started":"2025-08-24T07:34:51.678379Z","shell.execute_reply":"2025-08-24T07:34:51.68149Z"},"trusted":true},"outputs":[],"execution_count":9},{"cell_type":"code","source":"clf = xgb.XGBClassifier(n_estimators=1000, \n                        max_depth=8, \n                        objective='multi:softprob',\n                        seed=0,  \n                        nthread=-1, \n                        learning_rate=0.015,\n                        num_class = 2, \n                        scale_pos_weight = (32542/584))","metadata":{"execution":{"iopub.status.busy":"2025-08-24T07:34:51.683389Z","iopub.execute_input":"2025-08-24T07:34:51.683734Z","iopub.status.idle":"2025-08-24T07:34:51.696215Z","shell.execute_reply.started":"2025-08-24T07:34:51.683648Z","shell.execute_reply":"2025-08-24T07:34:51.695488Z"},"trusted":true},"outputs":[],"execution_count":10},{"cell_type":"code","source":"clf.fit(x_train, y_train)","metadata":{"execution":{"iopub.status.busy":"2025-08-24T07:34:51.697019Z","iopub.execute_input":"2025-08-24T07:34:51.697246Z","iopub.status.idle":"2025-08-24T07:34:56.961967Z","shell.execute_reply.started":"2025-08-24T07:34:51.697207Z","shell.execute_reply":"2025-08-24T07:34:56.961134Z"},"trusted":true},"outputs":[{"name":"stderr","text":"/usr/local/lib/python3.11/dist-packages/xgboost/core.py:160: UserWarning: [07:34:51] WARNING: /workspace/src/learner.cc:742: \nParameters: { \"scale_pos_weight\" } are not used.\n\n  warnings.warn(smsg, UserWarning)\n","output_type":"stream"},{"execution_count":11,"output_type":"execute_result","data":{"text/plain":"XGBClassifier(base_score=None, booster=None, callbacks=None,\n              colsample_bylevel=None, colsample_bynode=None,\n              colsample_bytree=None, device=None, early_stopping_rounds=None,\n              enable_categorical=False, eval_metric=None, feature_types=None,\n              gamma=None, grow_policy=None, importance_type=None,\n              interaction_constraints=None, learning_rate=0.015, max_bin=None,\n              max_cat_threshold=None, max_cat_to_onehot=None,\n              max_delta_step=None, max_depth=8, max_leaves=None,\n              min_child_weight=None, missing=nan, monotone_constraints=None,\n              multi_strategy=None, n_estimators=1000, n_jobs=None, nthread=-1,\n              num_class=2, ...)","text/html":"<style>#sk-container-id-1 {color: black;background-color: white;}#sk-container-id-1 pre{padding: 0;}#sk-container-id-1 div.sk-toggleable {background-color: white;}#sk-container-id-1 label.sk-toggleable__label {cursor: pointer;display: block;width: 100%;margin-bottom: 0;padding: 0.3em;box-sizing: border-box;text-align: center;}#sk-container-id-1 label.sk-toggleable__label-arrow:before {content: \"▸\";float: left;margin-right: 0.25em;color: #696969;}#sk-container-id-1 label.sk-toggleable__label-arrow:hover:before {color: black;}#sk-container-id-1 div.sk-estimator:hover label.sk-toggleable__label-arrow:before {color: black;}#sk-container-id-1 div.sk-toggleable__content {max-height: 0;max-width: 0;overflow: hidden;text-align: left;background-color: #f0f8ff;}#sk-container-id-1 div.sk-toggleable__content pre {margin: 0.2em;color: black;border-radius: 0.25em;background-color: #f0f8ff;}#sk-container-id-1 input.sk-toggleable__control:checked~div.sk-toggleable__content {max-height: 200px;max-width: 100%;overflow: auto;}#sk-container-id-1 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {content: \"▾\";}#sk-container-id-1 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-1 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-1 input.sk-hidden--visually {border: 0;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);height: 1px;margin: -1px;overflow: hidden;padding: 0;position: absolute;width: 1px;}#sk-container-id-1 div.sk-estimator {font-family: monospace;background-color: #f0f8ff;border: 1px dotted black;border-radius: 0.25em;box-sizing: border-box;margin-bottom: 0.5em;}#sk-container-id-1 div.sk-estimator:hover {background-color: #d4ebff;}#sk-container-id-1 div.sk-parallel-item::after {content: \"\";width: 100%;border-bottom: 1px solid gray;flex-grow: 1;}#sk-container-id-1 div.sk-label:hover label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-1 div.sk-serial::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: 0;}#sk-container-id-1 div.sk-serial {display: flex;flex-direction: column;align-items: center;background-color: white;padding-right: 0.2em;padding-left: 0.2em;position: relative;}#sk-container-id-1 div.sk-item {position: relative;z-index: 1;}#sk-container-id-1 div.sk-parallel {display: flex;align-items: stretch;justify-content: center;background-color: white;position: relative;}#sk-container-id-1 div.sk-item::before, #sk-container-id-1 div.sk-parallel-item::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: -1;}#sk-container-id-1 div.sk-parallel-item {display: flex;flex-direction: column;z-index: 1;position: relative;background-color: white;}#sk-container-id-1 div.sk-parallel-item:first-child::after {align-self: flex-end;width: 50%;}#sk-container-id-1 div.sk-parallel-item:last-child::after {align-self: flex-start;width: 50%;}#sk-container-id-1 div.sk-parallel-item:only-child::after {width: 0;}#sk-container-id-1 div.sk-dashed-wrapped {border: 1px dashed gray;margin: 0 0.4em 0.5em 0.4em;box-sizing: border-box;padding-bottom: 0.4em;background-color: white;}#sk-container-id-1 div.sk-label label {font-family: monospace;font-weight: bold;display: inline-block;line-height: 1.2em;}#sk-container-id-1 div.sk-label-container {text-align: center;}#sk-container-id-1 div.sk-container {/* jupyter's `normalize.less` sets `[hidden] { display: none; }` but bootstrap.min.css set `[hidden] { display: none !important; }` so we also need the `!important` here to be able to override the default hidden behavior on the sphinx rendered scikit-learn.org. See: https://github.com/scikit-learn/scikit-learn/issues/21755 */display: inline-block !important;position: relative;}#sk-container-id-1 div.sk-text-repr-fallback {display: none;}</style><div id=\"sk-container-id-1\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>XGBClassifier(base_score=None, booster=None, callbacks=None,\n              colsample_bylevel=None, colsample_bynode=None,\n              colsample_bytree=None, device=None, early_stopping_rounds=None,\n              enable_categorical=False, eval_metric=None, feature_types=None,\n              gamma=None, grow_policy=None, importance_type=None,\n              interaction_constraints=None, learning_rate=0.015, max_bin=None,\n              max_cat_threshold=None, max_cat_to_onehot=None,\n              max_delta_step=None, max_depth=8, max_leaves=None,\n              min_child_weight=None, missing=nan, monotone_constraints=None,\n              multi_strategy=None, n_estimators=1000, n_jobs=None, nthread=-1,\n              num_class=2, ...)</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item\"><div class=\"sk-estimator sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-1\" type=\"checkbox\" checked><label for=\"sk-estimator-id-1\" class=\"sk-toggleable__label sk-toggleable__label-arrow\">XGBClassifier</label><div class=\"sk-toggleable__content\"><pre>XGBClassifier(base_score=None, booster=None, callbacks=None,\n              colsample_bylevel=None, colsample_bynode=None,\n              colsample_bytree=None, device=None, early_stopping_rounds=None,\n              enable_categorical=False, eval_metric=None, feature_types=None,\n              gamma=None, grow_policy=None, importance_type=None,\n              interaction_constraints=None, learning_rate=0.015, max_bin=None,\n              max_cat_threshold=None, max_cat_to_onehot=None,\n              max_delta_step=None, max_depth=8, max_leaves=None,\n              min_child_weight=None, missing=nan, monotone_constraints=None,\n              multi_strategy=None, n_estimators=1000, n_jobs=None, nthread=-1,\n              num_class=2, ...)</pre></div></div></div></div></div>"},"metadata":{}}],"execution_count":11},{"cell_type":"code","source":"pred_train = clf.predict(x_train)\ny_pred = (pred_train[:, 1] >= 0.5).astype(int)\n","metadata":{"execution":{"iopub.status.busy":"2025-08-24T07:34:56.962873Z","iopub.execute_input":"2025-08-24T07:34:56.963232Z","iopub.status.idle":"2025-08-24T07:34:57.694273Z","shell.execute_reply.started":"2025-08-24T07:34:56.963205Z","shell.execute_reply":"2025-08-24T07:34:57.693717Z"},"trusted":true},"outputs":[],"execution_count":12},{"cell_type":"code","source":"y_pred.shape","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-08-24T07:34:57.694774Z","iopub.execute_input":"2025-08-24T07:34:57.694959Z","iopub.status.idle":"2025-08-24T07:34:57.700241Z","shell.execute_reply.started":"2025-08-24T07:34:57.694942Z","shell.execute_reply":"2025-08-24T07:34:57.698959Z"}},"outputs":[{"execution_count":13,"output_type":"execute_result","data":{"text/plain":"(33126,)"},"metadata":{}}],"execution_count":13},{"cell_type":"code","source":"y_train.shape","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-08-24T07:34:57.701078Z","iopub.execute_input":"2025-08-24T07:34:57.701642Z","iopub.status.idle":"2025-08-24T07:34:57.718054Z","shell.execute_reply.started":"2025-08-24T07:34:57.701623Z","shell.execute_reply":"2025-08-24T07:34:57.717469Z"}},"outputs":[{"execution_count":14,"output_type":"execute_result","data":{"text/plain":"(33126,)"},"metadata":{}}],"execution_count":14},{"cell_type":"code","source":"accuracy_score(y_pred, y_train)","metadata":{"execution":{"iopub.status.busy":"2025-08-24T07:34:57.718752Z","iopub.execute_input":"2025-08-24T07:34:57.718992Z","iopub.status.idle":"2025-08-24T07:34:57.753639Z","shell.execute_reply.started":"2025-08-24T07:34:57.718975Z","shell.execute_reply":"2025-08-24T07:34:57.753027Z"},"trusted":true},"outputs":[{"execution_count":15,"output_type":"execute_result","data":{"text/plain":"0.9825212823763811"},"metadata":{}}],"execution_count":15},{"cell_type":"code","source":"# proba = model.predict_proba(test_DMatrix) \n# clf.predict_proba(x_test)[:,1]\n# clf.predict(x_test)\nsub.target = clf.predict_proba(x_test)[:,1]\nsub_tabular = sub.copy()","metadata":{"execution":{"iopub.status.busy":"2025-08-24T07:34:57.754192Z","iopub.execute_input":"2025-08-24T07:34:57.754392Z","iopub.status.idle":"2025-08-24T07:34:57.993786Z","shell.execute_reply.started":"2025-08-24T07:34:57.754371Z","shell.execute_reply":"2025-08-24T07:34:57.993239Z"},"trusted":true},"outputs":[],"execution_count":16},{"cell_type":"code","source":"sub_public_merge = pd.read_csv('/kaggle/input/incredible-tpus-finetune-effnetb0-b6-at-once/submission_models_blended.csv')","metadata":{"execution":{"iopub.status.busy":"2025-08-24T07:34:57.99423Z","iopub.execute_input":"2025-08-24T07:34:57.994421Z","iopub.status.idle":"2025-08-24T07:34:58.013141Z","shell.execute_reply.started":"2025-08-24T07:34:57.994405Z","shell.execute_reply":"2025-08-24T07:34:58.012473Z"},"trusted":true},"outputs":[],"execution_count":17},{"cell_type":"code","source":"sub.target = sub_public_merge.target *0.80 + sub_tabular.target *0.20","metadata":{"execution":{"iopub.status.busy":"2025-08-24T07:34:58.01391Z","iopub.execute_input":"2025-08-24T07:34:58.014776Z","iopub.status.idle":"2025-08-24T07:34:58.019127Z","shell.execute_reply.started":"2025-08-24T07:34:58.014751Z","shell.execute_reply":"2025-08-24T07:34:58.018612Z"},"trusted":true},"outputs":[],"execution_count":18},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}