{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.11.11","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":103436,"databundleVersionId":12476472,"sourceType":"competition"}],"dockerImageVersionId":31040,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2025-06-15T13:55:13.556266Z","iopub.execute_input":"2025-06-15T13:55:13.556577Z","iopub.status.idle":"2025-06-15T13:55:13.566511Z","shell.execute_reply.started":"2025-06-15T13:55:13.556556Z","shell.execute_reply":"2025-06-15T13:55:13.565384Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_not_delay_7_9 = pd.read_csv('/kaggle/input/ds-108-p-21-assigment-06/not_delay_7_9_CONDITION_PRODUCT_SUPPLIER.csv')\ndf_delay_7_9 = pd.read_csv('/kaggle/input/ds-108-p-21-assigment-06/delay_7_9_CONDITION_PRODUCT_SUPPLIER.csv')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T13:55:13.568064Z","iopub.execute_input":"2025-06-15T13:55:13.568383Z","iopub.status.idle":"2025-06-15T13:55:19.404364Z","shell.execute_reply.started":"2025-06-15T13:55:13.568361Z","shell.execute_reply":"2025-06-15T13:55:19.403446Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_train = pd.concat([df_not_delay_7_9, df_delay_7_9], axis=0).drop_duplicates().reset_index(drop=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T13:55:19.421490Z","iopub.execute_input":"2025-06-15T13:55:19.421762Z","iopub.status.idle":"2025-06-15T13:55:23.010482Z","shell.execute_reply.started":"2025-06-15T13:55:19.421743Z","shell.execute_reply":"2025-06-15T13:55:23.009715Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_train.columns","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T13:55:23.011397Z","iopub.execute_input":"2025-06-15T13:55:23.011714Z","iopub.status.idle":"2025-06-15T13:55:23.017914Z","shell.execute_reply.started":"2025-06-15T13:55:23.011686Z","shell.execute_reply":"2025-06-15T13:55:23.017074Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_test = pd.read_csv('/kaggle/input/ds-108-p-21-assigment-06/PILOT_10.csv')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T13:55:23.019781Z","iopub.execute_input":"2025-06-15T13:55:23.020027Z","iopub.status.idle":"2025-06-15T13:55:23.527058Z","shell.execute_reply.started":"2025-06-15T13:55:23.020009Z","shell.execute_reply":"2025-06-15T13:55:23.526180Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_train.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T13:55:23.528019Z","iopub.execute_input":"2025-06-15T13:55:23.528354Z","iopub.status.idle":"2025-06-15T13:55:23.547424Z","shell.execute_reply.started":"2025-06-15T13:55:23.528325Z","shell.execute_reply":"2025-06-15T13:55:23.546333Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_train['OTHER AREA SHIP DIV'] = data_train['OTHER AREA SHIP DIV'].replace(' ', -1)\ndata_test['OTHER AREA SHIP DIV'] = data_test['OTHER AREA SHIP DIV'].replace(' ', -1)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T13:55:23.548300Z","iopub.execute_input":"2025-06-15T13:55:23.548576Z","iopub.status.idle":"2025-06-15T13:55:23.570824Z","shell.execute_reply.started":"2025-06-15T13:55:23.548557Z","shell.execute_reply":"2025-06-15T13:55:23.569743Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_train['OTHER AREA SHIP DIV'] = data_train['OTHER AREA SHIP DIV'].fillna(-1)\ndata_train['SUPPLIER_DIV'] = data_train['SUPPLIER_DIV'].fillna(-1)\ndata_train['REASON_CD'] = data_train['REASON_CD'].fillna(-1)\ndata_train['VSD'] = data_train['VSD'].fillna(-1)\ndata_train['Ship Mode'] = data_train['Ship Mode'].fillna(-1)\ndata_train['SHIP DECISION NO'] = data_train['OTHER AREA SHIP DIV'].fillna(-1)\ndata_train['Order date'] = data_train['Order date'].fillna(-1)\n\ndata_test['OTHER AREA SHIP DIV'] = data_test['OTHER AREA SHIP DIV'].fillna(-1)\ndata_test['SUPPLIER_DIV'] = data_test['SUPPLIER_DIV'].fillna(-1)\ndata_test['REASON_CD'] = data_test['REASON_CD'].fillna(-1)\ndata_test['VSD'] = data_test['VSD'].fillna(-1)\ndata_test['Ship Mode'] = data_test['Ship Mode'].fillna(-1)\ndata_test['SHIP DECISION NO'] = data_test['OTHER AREA SHIP DIV'].fillna(-1)\ndata_test['Order date'] = data_test['Order date'].fillna(-1)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T13:55:23.571909Z","iopub.execute_input":"2025-06-15T13:55:23.572912Z","iopub.status.idle":"2025-06-15T13:55:23.849148Z","shell.execute_reply.started":"2025-06-15T13:55:23.572889Z","shell.execute_reply":"2025-06-15T13:55:23.848172Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"remove_features = ['SUBSIDIARY_CD', 'GLOBAL_NO', 'BRAND_CD', 'Sales order line number', \n                   'Stock class', 'ALLOCATION QTY', 'SPECIAL DIV', 'LOGICAL PLANT', \n                   'PURCHASE AMOUNT', 'DIRECT SHIP FLG', 'SHIP DECISION NO', 'PACK QTY', \n                   'SUPPLIER_DIV', 'SPECIAL_DIV', 'SO_DAY_OF_MONTH', 'SO_DAY_OF_WEEK', \n                    'SO_TIME', 'QTUF_RCV_NO', 'SOUF_RCV_NO', 'REASON_CD']\nfor col in data_train.columns:\n    if col in remove_features:\n        data_train.drop(col, axis=1, inplace=True)\n    else: \n        continue\n\nfor col in data_test.columns:\n    if col in remove_features:\n        data_test.drop(col, axis=1, inplace=True)\n    else: \n        continue","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T13:55:23.850317Z","iopub.execute_input":"2025-06-15T13:55:23.850594Z","iopub.status.idle":"2025-06-15T13:55:27.469252Z","shell.execute_reply.started":"2025-06-15T13:55:23.850574Z","shell.execute_reply":"2025-06-15T13:55:27.468397Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_train['Consider count hodiday Saturday'] = data_train['Consider count hodiday Saturday'].replace(' ', '-1', inplace=True)\ndata_train['Consider count hodiday Saturday'] = data_train['Consider count hodiday Saturday'].fillna(-1)\ndata_train['Consider count hodiday Saturday'] = data_train['Consider count hodiday Saturday'].astype('int')\n\ndata_test['Consider count hodiday Saturday'] = data_test['Consider count hodiday Saturday'].replace(' ', '-1', inplace=True)\ndata_test['Consider count hodiday Saturday'] = data_test['Consider count hodiday Saturday'].fillna(-1)\ndata_test['Consider count hodiday Saturday'] = data_test['Consider count hodiday Saturday'].astype('int')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T13:55:27.469977Z","iopub.execute_input":"2025-06-15T13:55:27.470253Z","iopub.status.idle":"2025-06-15T13:55:27.733762Z","shell.execute_reply.started":"2025-06-15T13:55:27.470232Z","shell.execute_reply":"2025-06-15T13:55:27.732885Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_train.columns","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T13:55:27.736924Z","iopub.execute_input":"2025-06-15T13:55:27.737223Z","iopub.status.idle":"2025-06-15T13:55:27.743558Z","shell.execute_reply.started":"2025-06-15T13:55:27.737202Z","shell.execute_reply":"2025-06-15T13:55:27.742421Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_train['OTHER AREA SHIP DIV'] = data_train['OTHER AREA SHIP DIV'].astype('int')\n\ndata_test['OTHER AREA SHIP DIV'] = data_test['OTHER AREA SHIP DIV'].astype('int')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T13:55:27.744714Z","iopub.execute_input":"2025-06-15T13:55:27.744987Z","iopub.status.idle":"2025-06-15T13:55:27.773242Z","shell.execute_reply.started":"2025-06-15T13:55:27.744968Z","shell.execute_reply":"2025-06-15T13:55:27.772296Z"},"_kg_hide-input":true,"_kg_hide-output":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_train","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T13:55:27.774130Z","iopub.execute_input":"2025-06-15T13:55:27.774584Z","iopub.status.idle":"2025-06-15T13:55:27.794273Z","shell.execute_reply.started":"2025-06-15T13:55:27.774563Z","shell.execute_reply":"2025-06-15T13:55:27.793368Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!pip install unidecode","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T13:55:27.795312Z","iopub.execute_input":"2025-06-15T13:55:27.795636Z","iopub.status.idle":"2025-06-15T13:55:31.378429Z","shell.execute_reply.started":"2025-06-15T13:55:27.795605Z","shell.execute_reply":"2025-06-15T13:55:31.377229Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nfrom sklearn.preprocessing import MinMaxScaler\nfrom collections import Counter\nimport unidecode","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T13:55:31.379972Z","iopub.execute_input":"2025-06-15T13:55:31.380991Z","iopub.status.idle":"2025-06-15T13:55:31.385641Z","shell.execute_reply.started":"2025-06-15T13:55:31.380958Z","shell.execute_reply":"2025-06-15T13:55:31.384752Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"categorical_cols = ['Ship Mode', 'PRODUCT ATTRIBUTION', 'PRODUCT_CD', 'PACKING RANK'\n                    , 'OTHER AREA SHIP DIV', 'Consider count hodiday Saturday', 'SUPPLIER_CD',\n                   'INNER_CD', 'CUST_CD', 'DELI_DIV', 'CLASSIFY_CD']\n\nfor col in categorical_cols:\n    # Lowercase + deunicode\n    data_train[col] = data_train[col].astype(str).str.lower().apply(unidecode.unidecode)\n    data_test[col] = data_test[col].astype(str).str.lower().apply(unidecode.unidecode)\n\n    # Count Encoding\n    counts = data_train[col].value_counts().to_dict()\n    data_train[col] = data_train[col].map(counts)\n    data_test[col] = data_test[col].map(counts)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T13:55:31.386629Z","iopub.execute_input":"2025-06-15T13:55:31.386854Z","iopub.status.idle":"2025-06-15T13:55:44.063978Z","shell.execute_reply.started":"2025-06-15T13:55:31.386837Z","shell.execute_reply":"2025-06-15T13:55:44.063176Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_train['WEIGHT'] = data_train['SO QTY'] * data_train['WEIGHT PER PIECE']\ndata_test['WEIGHT'] = data_test['SO QTY'] * data_test['WEIGHT PER PIECE']\n\ndata_train.drop(columns=['SO QTY', 'WEIGHT PER PIECE'], inplace=True)\ndata_test.drop(columns=['SO QTY', 'WEIGHT PER PIECE'], inplace=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T13:55:44.064863Z","iopub.execute_input":"2025-06-15T13:55:44.065074Z","iopub.status.idle":"2025-06-15T13:55:44.191035Z","shell.execute_reply.started":"2025-06-15T13:55:44.065058Z","shell.execute_reply":"2025-06-15T13:55:44.190359Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"numerical_cols = ['WEIGHT', 'SUPPLIER INV AMOUNT']\n\n# Thay thế missing bằng -1\ndata_train[numerical_cols] = data_train[numerical_cols].fillna(-1)\ndata_test[numerical_cols] = data_test[numerical_cols].fillna(-1)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T13:55:44.192027Z","iopub.execute_input":"2025-06-15T13:55:44.192384Z","iopub.status.idle":"2025-06-15T13:55:44.218994Z","shell.execute_reply.started":"2025-06-15T13:55:44.192361Z","shell.execute_reply":"2025-06-15T13:55:44.218301Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def remove_outliers_iqr(df, cols):\n    df_cleaned = df.copy()\n    for col in cols:\n        Q1 = df_cleaned[col].quantile(0.25)\n        Q3 = df_cleaned[col].quantile(0.75)\n        IQR = Q3 - Q1\n        lower_bound = Q1 - 1.5 * IQR\n        upper_bound = Q3 + 1.5 * IQR\n        # Giữ lại các hàng không phải outlier\n        df_cleaned = df_cleaned[(df_cleaned[col] >= lower_bound) & (df_cleaned[col] <= upper_bound)]\n    return df_cleaned\n\n# Áp dụng loại bỏ outlier\ndata_train= remove_outliers_iqr(data_train, numerical_cols)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T13:55:44.220164Z","iopub.execute_input":"2025-06-15T13:55:44.220425Z","iopub.status.idle":"2025-06-15T13:55:44.639473Z","shell.execute_reply.started":"2025-06-15T13:55:44.220406Z","shell.execute_reply":"2025-06-15T13:55:44.638578Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"for col in numerical_cols:\n    col_min = data_train[col].min()\n    col_max = data_train[col].max()  \n\n    # Min-Max normalization\n    data_train[col] = (data_train[col] - col_min) / (col_max - col_min)\n    data_test[col] = (data_test[col] - col_min) / (col_max - col_min)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T13:55:44.640352Z","iopub.execute_input":"2025-06-15T13:55:44.640580Z","iopub.status.idle":"2025-06-15T13:55:44.660515Z","shell.execute_reply.started":"2025-06-15T13:55:44.640563Z","shell.execute_reply":"2025-06-15T13:55:44.659760Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Chuyển đổi sang datetime\ndata_train['Order date'] = pd.to_datetime(data_train['Order date'], errors='coerce')\ndata_train['VSD'] = pd.to_datetime(data_train['VSD'], errors='coerce')\n\ndata_test['Order date'] = pd.to_datetime(data_test['Order date'], errors='coerce')\ndata_test['VSD'] = pd.to_datetime(data_test['VSD'], errors='coerce')\n\n# Tạo cột isWeekday\ndata_train['isWeekday'] = data_train['Order date'].dt.weekday < 5\ndata_test['isWeekday'] = data_test['Order date'].dt.weekday < 5","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T13:55:44.661432Z","iopub.execute_input":"2025-06-15T13:55:44.661705Z","iopub.status.idle":"2025-06-15T13:55:45.103310Z","shell.execute_reply.started":"2025-06-15T13:55:44.661686Z","shell.execute_reply":"2025-06-15T13:55:45.102605Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Tạo thuộc tính day_range\ndata_train['day_range'] = (data_train['VSD'] - data_train['Order date']).dt.days\ndata_test['day_range'] = (data_test['VSD'] - data_test['Order date']).dt.days\n\n# Loại bỏ hai cột gốc\ndata_train.drop(columns=['Order date', 'VSD'], inplace=True)\ndata_test.drop(columns=['Order date', 'VSD'], inplace=True)\n\ndata_train['delivery_weekday'] = (data_train['day_range'] < 0).astype(int)\ndata_test['delivery_weekday'] = (data_test['day_range'] < 0).astype(int)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T13:55:45.104072Z","iopub.execute_input":"2025-06-15T13:55:45.104393Z","iopub.status.idle":"2025-06-15T13:55:45.185553Z","shell.execute_reply.started":"2025-06-15T13:55:45.104374Z","shell.execute_reply":"2025-06-15T13:55:45.184610Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"supplier_mean = data_train.groupby('SUPPLIER_CD')['SUPPLIER INV AMOUNT'].mean().to_dict()\ndata_train['SUPPLIER_AVG_AMT'] = data_train['SUPPLIER_CD'].map(supplier_mean)\ndata_test['SUPPLIER_AVG_AMT'] = data_test['SUPPLIER_CD'].map(supplier_mean)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T13:55:45.186410Z","iopub.execute_input":"2025-06-15T13:55:45.186703Z","iopub.status.idle":"2025-06-15T13:55:45.248397Z","shell.execute_reply.started":"2025-06-15T13:55:45.186675Z","shell.execute_reply":"2025-06-15T13:55:45.247500Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.utils import resample\n\n# Undersampling trên tập train\ndf = data_train.copy()\n\n# Tách các lớp\ndf_delay = df[df['label'] == 1]        # delay\ndf_not_delay = df[df['label'] == 0]    # not_delay\n\n# Undersample not_delay để đạt tỉ lệ 1:20\nn_delay = len(df_delay)\nn_not_delay_target = n_delay * 20\ndf_not_delay_downsampled = resample(\n    df_not_delay,\n    replace=False, \n    n_samples=n_not_delay_target,\n    random_state=42\n)\n\n# Kết hợp lại\ndf_balanced = pd.concat([df_delay, df_not_delay_downsampled]).sample(frac=1, random_state=42).reset_index(drop=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T13:55:45.249388Z","iopub.execute_input":"2025-06-15T13:55:45.249644Z","iopub.status.idle":"2025-06-15T13:55:45.585455Z","shell.execute_reply.started":"2025-06-15T13:55:45.249625Z","shell.execute_reply":"2025-06-15T13:55:45.584296Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.model_selection import train_test_split\n\nX_train = df_balanced.drop('label', axis=1)\ny_train = df_balanced['label']\n\nfrom sklearn.model_selection import train_test_split\n\nX_train_split, X_valid_split, y_train_split, y_valid_split = train_test_split(\n    X_train, y_train, test_size=0.2, random_state=42, stratify=y_train\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T14:53:12.214468Z","iopub.execute_input":"2025-06-15T14:53:12.214816Z","iopub.status.idle":"2025-06-15T14:53:12.357641Z","shell.execute_reply.started":"2025-06-15T14:53:12.214792Z","shell.execute_reply":"2025-06-15T14:53:12.356597Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"X_test = data_test","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T13:55:45.608921Z","iopub.execute_input":"2025-06-15T13:55:45.609162Z","iopub.status.idle":"2025-06-15T13:55:45.613464Z","shell.execute_reply.started":"2025-06-15T13:55:45.609137Z","shell.execute_reply":"2025-06-15T13:55:45.612642Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import optuna\nfrom sklearn.metrics import f1_score\nfrom catboost import CatBoostClassifier\n\ndef objective_catboost(trial):\n    params = {\n        'iterations': 100,\n        'learning_rate': trial.suggest_float('learning_rate', 0.01, 0.3),\n        'depth': trial.suggest_int('depth', 4, 10),\n        'l2_leaf_reg': trial.suggest_float('l2_leaf_reg', 1e-3, 10.0),\n        'random_strength': trial.suggest_float('random_strength', 0.1, 1.0),\n        'border_count': trial.suggest_int('border_count', 32, 255),\n        'eval_metric': 'F1',\n        'use_best_model': True,\n        'verbose': 0,\n        'random_seed': 42\n    }\n\n    model = CatBoostClassifier(**params)\n    model.fit(\n        X_train_split, y_train_split,\n        eval_set=(X_valid_split, y_valid_split)\n    )\n    preds = model.predict(X_valid_split)\n    return f1_score(y_valid_split, preds, average='macro')\n\nstudy_cat = optuna.create_study(direction='maximize')\nstudy_cat.optimize(objective_catboost, n_trials=100) \n    \nbest_cat = CatBoostClassifier(\n    **study_cat.best_params,\n    iterations=1000,\n    eval_metric='F1',\n    use_best_model=True,\n    verbose=100,\n    random_seed=42\n)\n\nbest_cat.fit(\n    X_train, y_train,\n    eval_set=(X_valid_split, y_valid_split)\n)\ncat_preds = best_cat.predict(X_test)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T15:23:41.195847Z","iopub.execute_input":"2025-06-15T15:23:41.196206Z","iopub.status.idle":"2025-06-15T15:23:46.141296Z","shell.execute_reply.started":"2025-06-15T15:23:41.196183Z","shell.execute_reply":"2025-06-15T15:23:46.139904Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import pandas as pd\n\nsubmission = pd.DataFrame({\n    'ID': range(1, len(cat_preds) + 1),\n    'label': cat_preds\n})\n\nsubmission.to_csv('submission.csv', index=False)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T15:08:44.967733Z","iopub.execute_input":"2025-06-15T15:08:44.968043Z","iopub.status.idle":"2025-06-15T15:08:45.081483Z","shell.execute_reply.started":"2025-06-15T15:08:44.968021Z","shell.execute_reply":"2025-06-15T15:08:45.080149Z"}},"outputs":[],"execution_count":null}]}