{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.13.15","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[],"dockerImageVersionId":28755,"isInternetEnabled":false,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"<div>\n    <h1 style=\"text-align: left\">\n        <strong>Introduction</strong>\n    </h1>\n</div>\n\n---\n\n<div>\n    <p style=\"text-align: justify\">\nThis notebook is my first submission to the <b>American Express - Default Prediction</b>\ncompetition on Kaggle. The goal is to predict the probability that a customer will default\non their credit card balance, based on their monthly statement history.\n    </p style=\"text-align: justify\">\n    <p style=\"text-align: justify\">\nThe dataset has multiple rows per customer (one per statement), with anonymized and\nnormalized features grouped into categories such as delinquency, spending, payment,\nbalance, and risk. Since the target is defined at the customer level, the code in this\nnotebook summarizes each customer's history into a single row: the <b>median</b> for\nnumeric variables and the <b>mode</b> (followed by one-hot encoding) for categorical ones.\n    </p>\n    <p style=\"text-align: justify\">\nThe summarized data is then used to train a model, which is validated with the\ncompetition's metric (the mean of the normalized Gini coefficient and the default rate\ncaptured at 4%) and used to generate the final <code>submission.csv</code>.\n    </p>\n</div>","metadata":{}},{"cell_type":"code","source":"import re\nimport warnings\n\nimport polars as pl\nimport polars.selectors as cs\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.preprocessing import OneHotEncoder\nfrom xgboost import XGBClassifier\n\nwarnings.filterwarnings(\"ignore\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-15T18:50:35.569765Z","iopub.execute_input":"2026-10-15T18:50:35.570011Z","iopub.status.idle":"2026-10-15T18:50:40.342261Z","shell.execute_reply.started":"2026-10-15T18:50:35.569987Z","shell.execute_reply":"2026-10-15T18:50:40.341418Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"X_train_path = \"/kaggle/input/competitions/amex-default-prediction/train_data.csv\"\ny_train_path = \"/kaggle/input/competitions/amex-default-prediction/train_labels.csv\"\n\npl.scan_csv(X_train_path).sink_parquet(\"train_data.parquet\")\npl.scan_csv(y_train_path).sink_parquet(\"train_labels.parquet\")\n\nX_train = pl.read_parquet(\"/kaggle/working/train_data.parquet\")\ny_train = pl.read_parquet(\"/kaggle/working/train_labels.parquet\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-10-15T18:51:07.949072Z","iopub.execute_input":"2026-10-15T18:51:07.949465Z"}},"outputs":[],"execution_count":null}]}