{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"gpu","dataSources":[{"sourceId":50160,"databundleVersionId":7921029,"sourceType":"competition"}],"dockerImageVersionId":30648,"isInternetEnabled":false,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"I appreciate comments and ideas for improvement of the callback\n\nMost of the code taken from these great notebooks\n- https://www.kaggle.com/code/greysky/home-credit-baseline  \n- https://www.kaggle.com/code/dksdms4/lb-0-565-improved-baseline-notebook\n- https://www.kaggle.com/code/peizhengwang/0-495-lb-deep-neural-network-starter\n- https://www.kaggle.com/code/benjenkins96/deep-learning-techniques-for-credit-risk-stability\n- https://www.kaggle.com/code/faeqsu10/lgbm-feature-importance-top10-data-analysis#max_credit_bureau_a_1_residualamount_856A","metadata":{}},{"cell_type":"code","source":"import os\nimport gc\nfrom glob import glob\nfrom pathlib import Path\nfrom datetime import datetime\n\nimport numpy as np\nimport pandas as pd\nimport polars as pl\n\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\nfrom sklearn.model_selection import StratifiedGroupKFold\nfrom sklearn.base import BaseEstimator, ClassifierMixin\nfrom sklearn.metrics import roc_auc_score\n\n# import lightgbm as lgb\nimport tensorflow as tf\nimport tensorflow_probability as tfp\n\nimport warnings\nwarnings.simplefilter(action='ignore', category=FutureWarning)","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2024-04-14T17:34:05.499827Z","iopub.execute_input":"2024-04-14T17:34:05.500676Z","iopub.status.idle":"2024-04-14T17:34:05.507081Z","shell.execute_reply.started":"2024-04-14T17:34:05.500644Z","shell.execute_reply":"2024-04-14T17:34:05.506090Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Pre-Fitted Voting Model","metadata":{}},{"cell_type":"code","source":"class VotingModel(BaseEstimator, ClassifierMixin):\n    def __init__(self, estimators):\n        super().__init__()\n        self.estimators = estimators\n        \n    def fit(self, X, y=None):\n        return self\n    \n    def predict(self, X):\n        y_preds = [estimator.predict(X) for estimator in self.estimators]\n        return np.mean(y_preds, axis=0)\n    \n    def predict_proba(self, X):\n        y_preds = [estimator.predict_proba(X) for estimator in self.estimators]\n        return np.mean(y_preds, axis=0)","metadata":{"execution":{"iopub.status.busy":"2024-04-14T17:34:05.508647Z","iopub.execute_input":"2024-04-14T17:34:05.508970Z","iopub.status.idle":"2024-04-14T17:34:05.520100Z","shell.execute_reply.started":"2024-04-14T17:34:05.508938Z","shell.execute_reply":"2024-04-14T17:34:05.519204Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Pipeline","metadata":{}},{"cell_type":"code","source":"class Pipeline:\n    @staticmethod\n    def set_table_dtypes(df):\n        for col in df.columns:\n            if col in [\"case_id\", \"WEEK_NUM\", \"num_group1\", \"num_group2\"]:\n                df = df.with_columns(pl.col(col).cast(pl.Int32))\n            elif col in [\"date_decision\"]:\n                df = df.with_columns(pl.col(col).cast(pl.Date))\n            elif col[-1] in (\"P\", \"A\"):\n                df = df.with_columns(pl.col(col).cast(pl.Float64))\n            elif col[-1] in (\"M\",):\n                df = df.with_columns(pl.col(col).cast(pl.String))\n            elif col[-1] in (\"D\",):\n                df = df.with_columns(pl.col(col).cast(pl.Date))            \n\n        return df\n    \n    @staticmethod\n    def handle_dates(df):\n        for col in df.columns:\n            if col[-1] in (\"D\",):\n                df = df.with_columns(pl.col(col) - pl.col(\"date_decision\"))\n                df = df.with_columns(pl.col(col).dt.total_days())\n                df = df.with_columns(pl.col(col).cast(pl.Float32))\n                \n        df = df.drop(\"date_decision\", \"MONTH\")\n\n        return df\n    \n    @staticmethod\n    def filter_cols(df, cols_drop):\n        for col in df.columns:\n            if col not in [\"target\", \"case_id\", \"WEEK_NUM\"]:\n                isnull = df[col].is_null().mean()\n\n                # TODO: Revisar el sentido de este filtro         \n                if col[-1]=='M':\n                    specific_value_ratio = df.filter(pl.col(col) == \"a55475b1\").height / df.height\n                    if specific_value_ratio > 0.95:\n                        df = df.drop(col)\n                        \n                if isnull > 0.95:\n                    df = df.drop(col)\n                    \n        for col in df.columns:\n            if (col not in [\"target\", \"case_id\", \"WEEK_NUM\"]) & (df[col].dtype == pl.String):\n                freq = df[col].n_unique()\n\n                if (freq == 1) | (freq > 200):\n                    df = df.drop(col)\n        \n        for col in cols_drop:\n            if col in df.columns:\n                df = df.drop(col)\n            \n        return df\n\n    \n    # Añadidos los 3 siguientes metodos\n    @staticmethod\n    def reduce_memory_usage_pl(df):\n        \"\"\" Reduce memory usage by polars dataframe {df} with name {name} by changing its data types.\n            Original pandas version of this function: https://www.kaggle.com/code/arjanso/reducing-dataframe-memory-size-by-65 \n        \"\"\"\n        print(f\"Memory usage of dataframe is {round(df.estimated_size('mb'), 2)} MB\")\n        \n        Numeric_Int_types = [pl.Int8, pl.Int16, pl.Int32, pl.Int64]\n        Numeric_Float_types = [pl.Float32, pl.Float64]    \n        \n        for col in df.columns:\n            if col == 'case_id': \n                continue\n            try:\n                col_type = df[col].dtype\n                \n                if col_type == pl.Categorical:\n                    continue\n                    \n                c_min = df[col].min()\n                c_max = df[col].max()\n                \n                if col_type in Numeric_Int_types:\n                    if c_min > np.iinfo(np.int8).min and c_max < np.iinfo(np.int8).max:\n                        df = df.with_columns(df[col].cast(pl.Int8))\n                    elif c_min > np.iinfo(np.int16).min and c_max < np.iinfo(np.int16).max:\n                        df = df.with_columns(df[col].cast(pl.Int16))\n                    elif c_min > np.iinfo(np.int32).min and c_max < np.iinfo(np.int32).max:\n                        df = df.with_columns(df[col].cast(pl.Int32))\n                    elif c_min > np.iinfo(np.int64).min and c_max < np.iinfo(np.int64).max:\n                        df = df.with_columns(df[col].cast(pl.Int64))\n                \n                elif col_type in Numeric_Float_types:\n                    if c_min > np.finfo(np.float32).min and c_max < np.finfo(np.float32).max:\n                        df = df.with_columns(df[col].cast(pl.Float32))\n                    else:\n                        pass\n                # elif col_type == pl.Utf8:\n                #     df = df.with_columns(df[col].cast(pl.Categorical))\n                else:\n                    pass\n            except:\n                pass\n        print(f\"Memory usage of dataframe became {round(df.estimated_size('mb'), 2)} MB\")\n        return df\n    \n    @staticmethod\n    def convert_to_prob(value):\n        if pd.isnull(value):\n            return np.nan  \n        low, high = value.replace('%', '').split(' - ')\n        return (float(low) + float(high)) / 200 \n    \n    @staticmethod\n    def cb_preprocessing(df, cols):\n        df = df.to_pandas()\n        \n        for key in cols.keys():\n            if key[0]=='T':\n                df['riskassesment_302T'] = df['riskassesment_302T'].apply(Pipeline.convert_to_prob)\n                scaler = MinMaxScaler()\n                df[['riskassesment_940T']] = scaler.fit_transform(df[['riskassesment_940T']])\n            elif key[0]=='M':\n                df = df.drop(columns=cols['M_cols'][0])\n            else:\n                for col_list in cols[key]:\n                    print(col_list)\n                    col_name = col_list[0].split(\"_\")[0]\n                    df[col_name] = df.apply(lambda row: row[col_list].dropna().mean(), axis=1)\n                    df = df.drop(columns=col_list)\n        df = pl.from_pandas(df)\n        return df\n    \n    @staticmethod\n    def fill_missing_values(df):\n        for col in df.columns:\n            if df[col].dtype.is_numeric():\n                df = df.with_columns(pl.col(col).fill_null(0).alias(col))\n            else:\n                df = df.with_columns(pl.col(col).fill_null(\"Missing\").alias(col))\n        return df","metadata":{"execution":{"iopub.status.busy":"2024-04-14T17:34:05.521355Z","iopub.execute_input":"2024-04-14T17:34:05.521652Z","iopub.status.idle":"2024-04-14T17:34:05.792554Z","shell.execute_reply.started":"2024-04-14T17:34:05.521620Z","shell.execute_reply":"2024-04-14T17:34:05.791391Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Automatic Aggregation","metadata":{}},{"cell_type":"code","source":"class Aggregator:\n    @staticmethod\n    def num_expr(df):\n        cols = [col for col in df.columns if col[-1] in (\"P\", \"A\")]\n\n        expr_max = [pl.max(col).alias(f\"max_{col}\") for col in cols]\n\n        return expr_max\n\n    @staticmethod\n    def date_expr(df):\n        cols = [col for col in df.columns if col[-1] in (\"D\",)]\n\n        expr_max = [pl.max(col).alias(f\"max_{col}\") for col in cols]\n\n        return expr_max\n\n    @staticmethod\n    def str_expr(df):\n        cols = [col for col in df.columns if col[-1] in (\"M\",)]\n        \n        expr_max = [pl.max(col).alias(f\"max_{col}\") for col in cols]\n\n        return expr_max\n\n    @staticmethod\n    def other_expr(df):\n        cols = [col for col in df.columns if col[-1] in (\"T\", \"L\")]\n        \n        expr_max = [pl.max(col).alias(f\"max_{col}\") for col in cols]\n\n        return expr_max\n    \n    @staticmethod\n    def count_expr(df):\n        cols = [col for col in df.columns if \"num_group\" in col]\n\n        expr_max = [pl.max(col).alias(f\"max_{col}\") for col in cols]\n\n        return expr_max\n\n    @staticmethod\n    def get_exprs(df):\n        exprs = Aggregator.num_expr(df) + \\\n                Aggregator.date_expr(df) + \\\n                Aggregator.str_expr(df) + \\\n                Aggregator.other_expr(df) + \\\n                Aggregator.count_expr(df)\n\n        return exprs","metadata":{"execution":{"iopub.status.busy":"2024-04-14T17:34:05.794652Z","iopub.execute_input":"2024-04-14T17:34:05.794973Z","iopub.status.idle":"2024-04-14T17:34:05.807603Z","shell.execute_reply.started":"2024-04-14T17:34:05.794945Z","shell.execute_reply":"2024-04-14T17:34:05.806714Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### File I/O","metadata":{}},{"cell_type":"code","source":"def read_file(path, depth=None):\n    df = pl.read_parquet(path)\n    df = df.pipe(Pipeline.set_table_dtypes)\n    \n    if depth in [1, 2]:\n        df = df.group_by(\"case_id\").agg(Aggregator.get_exprs(df))\n        \n    df = df.pipe(Pipeline.reduce_memory_usage_pl)\n    return df\n\ndef read_files(regex_path, depth=None):\n    chunks = []\n    for path in glob(str(regex_path)):\n        df = pl.read_parquet(path)\n        df = df.pipe(Pipeline.set_table_dtypes)\n        \n        if depth in [1, 2]:\n            df = df.group_by(\"case_id\").agg(Aggregator.get_exprs(df))\n        \n        chunks.append(df)\n        \n    df = pl.concat(chunks, how=\"vertical_relaxed\")\n    df = df.unique(subset=[\"case_id\"])\n    \n    df = df.pipe(Pipeline.reduce_memory_usage_pl)\n    \n    return df","metadata":{"execution":{"iopub.status.busy":"2024-04-14T17:34:05.808685Z","iopub.execute_input":"2024-04-14T17:34:05.808969Z","iopub.status.idle":"2024-04-14T17:34:05.821538Z","shell.execute_reply.started":"2024-04-14T17:34:05.808945Z","shell.execute_reply":"2024-04-14T17:34:05.820766Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Feature Engineering","metadata":{}},{"cell_type":"code","source":"def feature_eng(df_base, depth_0, depth_1, depth_2):\n    df_base = (\n        df_base\n        .with_columns(\n            month_decision = pl.col(\"date_decision\").dt.month(),\n            weekday_decision = pl.col(\"date_decision\").dt.weekday(),\n        )\n    )\n        \n    for i, df in enumerate(depth_0 + depth_1 + depth_2):\n        df_base = df_base.join(df, how=\"left\", on=\"case_id\", suffix=f\"_{i}\")\n        \n    df_base = df_base.pipe(Pipeline.handle_dates)\n    df_base = df_base.pipe(Pipeline.fill_missing_values)\n    \n    return df_base","metadata":{"execution":{"iopub.status.busy":"2024-04-14T17:34:05.822568Z","iopub.execute_input":"2024-04-14T17:34:05.822836Z","iopub.status.idle":"2024-04-14T17:34:05.833955Z","shell.execute_reply.started":"2024-04-14T17:34:05.822813Z","shell.execute_reply":"2024-04-14T17:34:05.832981Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def to_pandas(df_data, cat_cols=None):\n    df_data = df_data.to_pandas()\n    \n    if cat_cols is None:\n        cat_cols = list(df_data.select_dtypes(\"object\").columns)\n    \n    df_data[cat_cols] = df_data[cat_cols].astype(\"category\")\n    \n    return df_data, cat_cols","metadata":{"execution":{"iopub.status.busy":"2024-04-14T17:34:05.835102Z","iopub.execute_input":"2024-04-14T17:34:05.835415Z","iopub.status.idle":"2024-04-14T17:34:05.842965Z","shell.execute_reply.started":"2024-04-14T17:34:05.835382Z","shell.execute_reply":"2024-04-14T17:34:05.842049Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Configuration","metadata":{}},{"cell_type":"code","source":"ROOT            = Path(\"/kaggle/input/home-credit-credit-risk-model-stability\")\nTRAIN_DIR       = ROOT / \"parquet_files\" / \"train\"\nTEST_DIR        = ROOT / \"parquet_files\" / \"test\"","metadata":{"execution":{"iopub.status.busy":"2024-04-14T17:34:05.844274Z","iopub.execute_input":"2024-04-14T17:34:05.844606Z","iopub.status.idle":"2024-04-14T17:34:05.851183Z","shell.execute_reply.started":"2024-04-14T17:34:05.844576Z","shell.execute_reply":"2024-04-14T17:34:05.850459Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Train Files Read & Feature Engineering","metadata":{}},{"cell_type":"code","source":"data_store = {\n    \"df_base\": read_file(TRAIN_DIR / \"train_base.parquet\"),\n    \"depth_0\": [\n        read_file(TRAIN_DIR / \"train_static_cb_0.parquet\"),\n        read_files(TRAIN_DIR / \"train_static_0_*.parquet\"),\n    ],\n    \"depth_1\": [\n        read_files(TRAIN_DIR / \"train_applprev_1_*.parquet\", 1),\n        read_file(TRAIN_DIR / \"train_tax_registry_a_1.parquet\", 1),\n        read_file(TRAIN_DIR / \"train_tax_registry_b_1.parquet\", 1),\n        read_file(TRAIN_DIR / \"train_tax_registry_c_1.parquet\", 1),\n        read_files(TRAIN_DIR / \"train_credit_bureau_a_1_*.parquet\", 1),\n        read_file(TRAIN_DIR / \"train_credit_bureau_b_1.parquet\", 1),\n        read_file(TRAIN_DIR / \"train_other_1.parquet\", 1),\n        read_file(TRAIN_DIR / \"train_person_1.parquet\", 1),\n        read_file(TRAIN_DIR / \"train_deposit_1.parquet\", 1),\n        read_file(TRAIN_DIR / \"train_debitcard_1.parquet\", 1),\n    ],\n    \"depth_2\": [\n        read_file(TRAIN_DIR / \"train_credit_bureau_b_2.parquet\", 2),\n        read_files(TRAIN_DIR / \"train_credit_bureau_a_2_*.parquet\", 2),\n    ]\n}","metadata":{"execution":{"iopub.status.busy":"2024-04-14T17:34:05.855195Z","iopub.execute_input":"2024-04-14T17:34:05.855586Z","iopub.status.idle":"2024-04-14T17:36:32.489151Z","shell.execute_reply.started":"2024-04-14T17:34:05.855555Z","shell.execute_reply":"2024-04-14T17:36:32.488237Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train = feature_eng(**data_store)\n\nprint(\"train data shape:\\t\", df_train.shape)","metadata":{"execution":{"iopub.status.busy":"2024-04-14T17:36:32.490758Z","iopub.execute_input":"2024-04-14T17:36:32.491292Z","iopub.status.idle":"2024-04-14T17:36:56.138702Z","shell.execute_reply.started":"2024-04-14T17:36:32.491257Z","shell.execute_reply":"2024-04-14T17:36:56.137775Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Test Files Read & Feature Engineering","metadata":{}},{"cell_type":"code","source":"data_store = {\n    \"df_base\": read_file(TEST_DIR / \"test_base.parquet\"),\n    \"depth_0\": [\n        read_file(TEST_DIR / \"test_static_cb_0.parquet\"),\n        read_files(TEST_DIR / \"test_static_0_*.parquet\"),\n    ],\n    \"depth_1\": [\n        read_files(TEST_DIR / \"test_applprev_1_*.parquet\", 1),\n        read_file(TEST_DIR / \"test_tax_registry_a_1.parquet\", 1),\n        read_file(TEST_DIR / \"test_tax_registry_b_1.parquet\", 1),\n        read_file(TEST_DIR / \"test_tax_registry_c_1.parquet\", 1),\n        read_files(TEST_DIR / \"test_credit_bureau_a_1_*.parquet\", 1),\n        read_file(TEST_DIR / \"test_credit_bureau_b_1.parquet\", 1),\n        read_file(TEST_DIR / \"test_other_1.parquet\", 1),\n        read_file(TEST_DIR / \"test_person_1.parquet\", 1),\n        read_file(TEST_DIR / \"test_deposit_1.parquet\", 1),\n        read_file(TEST_DIR / \"test_debitcard_1.parquet\", 1),\n    ],\n    \"depth_2\": [\n        read_file(TEST_DIR / \"test_credit_bureau_b_2.parquet\", 2),\n        read_files(TEST_DIR / \"test_credit_bureau_a_2_*.parquet\", 2),\n    ]\n}","metadata":{"execution":{"iopub.status.busy":"2024-04-14T17:36:56.140116Z","iopub.execute_input":"2024-04-14T17:36:56.140555Z","iopub.status.idle":"2024-04-14T17:36:56.724322Z","shell.execute_reply.started":"2024-04-14T17:36:56.140522Z","shell.execute_reply":"2024-04-14T17:36:56.723426Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_test = feature_eng(**data_store)\n\nprint(\"test data shape:\\t\", df_test.shape)","metadata":{"execution":{"iopub.status.busy":"2024-04-14T17:36:56.725596Z","iopub.execute_input":"2024-04-14T17:36:56.725951Z","iopub.status.idle":"2024-04-14T17:36:56.899642Z","shell.execute_reply.started":"2024-04-14T17:36:56.725919Z","shell.execute_reply":"2024-04-14T17:36:56.898719Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Feature Elimination","metadata":{}},{"cell_type":"code","source":"cols_drop = [\n    'max_applprev1_cancelreason_3545846M', 'last_applprev1_cancelreason_3545846M', 'max_applprev1_district_544M', 'last_applprev1_district_544M', 'max_applprev1_isbidproduct_390L', 'last_applprev1_isbidproduct_390L', 'max_applprev1_isdebitcard_527L', 'last_applprev1_isdebitcard_527L', 'max_applprev1_profession_152M', 'last_applprev1_profession_152M', 'last_applprev1_revolvingaccount_394A', 'last_applprev2_credacc_cards_status_52L', 'last_credit_bureau_a_1_annualeffectiverate_199L', 'last_credit_bureau_a_1_annualeffectiverate_63L', 'max_credit_bureau_a_1_classificationofcontr_400M', 'last_credit_bureau_a_1_classificationofcontr_400M', 'max_credit_bureau_a_1_contractst_964M', 'last_credit_bureau_a_1_contractst_964M', 'last_credit_bureau_a_1_contractsum_5085717L', 'last_credit_bureau_a_1_credlmt_230A', 'last_credit_bureau_a_1_credlmt_935A', 'last_credit_bureau_a_1_debtoutstand_525A', 'last_credit_bureau_a_1_debtoverdue_47A', 'last_credit_bureau_a_1_dpdmax_139P', 'last_credit_bureau_a_1_dpdmax_757P', 'last_credit_bureau_a_1_dpdmaxdatemonth_442T', 'last_credit_bureau_a_1_dpdmaxdatemonth_89T', 'last_credit_bureau_a_1_dpdmaxdateyear_596T', 'last_credit_bureau_a_1_dpdmaxdateyear_896T', 'max_credit_bureau_a_1_financialinstitution_382M', 'last_credit_bureau_a_1_financialinstitution_382M', 'max_credit_bureau_a_1_financialinstitution_591M', 'last_credit_bureau_a_1_instlamount_768A', 'last_credit_bureau_a_1_instlamount_852A', 'max_credit_bureau_a_1_interestrate_508L', 'last_credit_bureau_a_1_interestrate_508L', 'last_credit_bureau_a_1_monthlyinstlamount_332A', 'last_credit_bureau_a_1_monthlyinstlamount_674A', 'last_credit_bureau_a_1_nominalrate_281L', 'last_credit_bureau_a_1_nominalrate_498L', 'last_credit_bureau_a_1_numberofcontrsvalue_258L', 'last_credit_bureau_a_1_numberofcontrsvalue_358L', 'last_credit_bureau_a_1_numberofinstls_229L', 'last_credit_bureau_a_1_numberofinstls_320L', 'last_credit_bureau_a_1_numberofoutstandinstls_520L', 'last_credit_bureau_a_1_numberofoutstandinstls_59L', 'last_credit_bureau_a_1_numberofoverdueinstlmax_1039L', 'last_credit_bureau_a_1_numberofoverdueinstlmax_1151L', 'last_credit_bureau_a_1_numberofoverdueinstls_725L', 'last_credit_bureau_a_1_numberofoverdueinstls_834L', 'last_credit_bureau_a_1_outstandingamount_354A', 'last_credit_bureau_a_1_outstandingamount_362A', 'last_credit_bureau_a_1_overdueamount_31A', 'last_credit_bureau_a_1_overdueamount_659A', 'last_credit_bureau_a_1_overdueamountmax2_14A', 'last_credit_bureau_a_1_overdueamountmax2_398A', 'last_credit_bureau_a_1_overdueamountmax_155A', 'last_credit_bureau_a_1_overdueamountmax_35A', 'last_credit_bureau_a_1_overdueamountmaxdatemonth_284T', 'last_credit_bureau_a_1_overdueamountmaxdatemonth_365T', 'last_credit_bureau_a_1_overdueamountmaxdateyear_2T', 'last_credit_bureau_a_1_overdueamountmaxdateyear_994T', 'last_credit_bureau_a_1_periodicityofpmts_1102L', 'last_credit_bureau_a_1_periodicityofpmts_837L', 'last_credit_bureau_a_1_prolongationcount_1120L', 'max_credit_bureau_a_1_prolongationcount_599L', 'last_credit_bureau_a_1_prolongationcount_599L', 'last_credit_bureau_a_1_residualamount_488A', 'last_credit_bureau_a_1_residualamount_856A', 'last_credit_bureau_a_1_subjectrole_182M', 'last_credit_bureau_a_1_totalamount_6A', 'last_credit_bureau_a_1_totalamount_996A', 'last_credit_bureau_a_1_totaldebtoverduevalue_178A', 'last_credit_bureau_a_1_totaldebtoverduevalue_718A', 'last_credit_bureau_a_1_totaloutstanddebtvalue_39A', 'last_credit_bureau_a_1_totaloutstanddebtvalue_668A', 'max_collater_typofvalofguarant_298M', 'last_collater_typofvalofguarant_298M', 'std_collater_typofvalofguarant_298M', 'max_pmts_month_158T', 'last_pmts_month_158T', 'std_pmts_month_158T', 'max_pmts_month_706T', 'last_pmts_month_706T', 'std_pmts_month_706T', 'max_bureau_b_1_amount_1115A', 'last_bureau_b_1_amount_1115A', 'max_bureau_b_1_classificationofcontr_1114M', 'last_bureau_b_1_classificationofcontr_1114M', 'max_bureau_b_1_contractst_516M', 'last_bureau_b_1_contractst_516M', 'max_bureau_b_1_contracttype_653M', 'last_bureau_b_1_contracttype_653M', 'max_bureau_b_1_credlmt_1052A', 'last_bureau_b_1_credlmt_1052A', 'max_bureau_b_1_credlmt_228A', 'last_bureau_b_1_credlmt_228A', 'max_bureau_b_1_credlmt_3940954A', 'last_bureau_b_1_credlmt_3940954A', 'max_bureau_b_1_credor_3940957M', 'last_bureau_b_1_credor_3940957M', 'max_bureau_b_1_credquantity_1099L', 'last_bureau_b_1_credquantity_1099L', 'max_bureau_b_1_credquantity_984L', 'last_bureau_b_1_credquantity_984L', 'max_bureau_b_1_debtpastduevalue_732A', 'last_bureau_b_1_debtpastduevalue_732A', 'max_bureau_b_1_debtvalue_227A', 'last_bureau_b_1_debtvalue_227A', 'max_bureau_b_1_dpd_550P', 'last_bureau_b_1_dpd_550P', 'max_bureau_b_1_dpd_733P', 'last_bureau_b_1_dpd_733P', 'max_bureau_b_1_dpdmax_851P', 'last_bureau_b_1_dpdmax_851P', 'max_bureau_b_1_dpdmaxdatemonth_804T', 'last_bureau_b_1_dpdmaxdatemonth_804T', 'max_bureau_b_1_dpdmaxdateyear_742T', 'last_bureau_b_1_dpdmaxdateyear_742T', 'max_bureau_b_1_installmentamount_644A', 'last_bureau_b_1_installmentamount_644A', 'max_bureau_b_1_installmentamount_833A', 'last_bureau_b_1_installmentamount_833A', 'max_bureau_b_1_instlamount_892A', 'last_bureau_b_1_instlamount_892A', 'max_bureau_b_1_interesteffectiverate_369L', 'last_bureau_b_1_interesteffectiverate_369L', 'max_bureau_b_1_interestrateyearly_538L', 'last_bureau_b_1_interestrateyearly_538L', 'max_bureau_b_1_maxdebtpduevalodued_3940955A', 'last_bureau_b_1_maxdebtpduevalodued_3940955A', 'max_bureau_b_1_num_group1', 'last_bureau_b_1_num_group1', 'max_bureau_b_1_numberofinstls_810L', 'last_bureau_b_1_numberofinstls_810L', 'max_bureau_b_1_overdueamountmax_950A', 'last_bureau_b_1_overdueamountmax_950A', 'max_bureau_b_1_overdueamountmaxdatemonth_494T', 'last_bureau_b_1_overdueamountmaxdatemonth_494T', 'max_bureau_b_1_overdueamountmaxdateyear_432T', 'last_bureau_b_1_overdueamountmaxdateyear_432T', 'max_bureau_b_1_periodicityofpmts_997L', 'last_bureau_b_1_periodicityofpmts_997L', 'max_bureau_b_1_periodicityofpmts_997M', 'last_bureau_b_1_periodicityofpmts_997M', 'max_bureau_b_1_pmtdaysoverdue_1135P', 'last_bureau_b_1_pmtdaysoverdue_1135P', 'max_bureau_b_1_pmtmethod_731M', 'last_bureau_b_1_pmtmethod_731M', 'max_bureau_b_1_pmtnumpending_403L', 'last_bureau_b_1_pmtnumpending_403L', 'max_bureau_b_1_purposeofcred_722M', 'last_bureau_b_1_purposeofcred_722M', 'max_bureau_b_1_residualamount_1093A', 'last_bureau_b_1_residualamount_1093A', 'max_bureau_b_1_residualamount_127A', 'last_bureau_b_1_residualamount_127A', 'max_bureau_b_1_residualamount_3940956A', 'last_bureau_b_1_residualamount_3940956A', 'max_bureau_b_1_subjectrole_326M', 'last_bureau_b_1_subjectrole_326M', 'max_bureau_b_1_subjectrole_43M', 'last_bureau_b_1_subjectrole_43M', 'max_bureau_b_1_totalamount_503A', 'last_bureau_b_1_totalamount_503A', 'max_bureau_b_1_totalamount_881A', 'last_bureau_b_1_totalamount_881A', 'max_bureau_b_2_num_group1', 'last_bureau_b_2_num_group1', 'max_bureau_b_2_num_group2', 'last_bureau_b_2_num_group2', 'max_bureau_b_2_pmts_dpdvalue_108P', 'last_bureau_b_2_pmts_dpdvalue_108P', 'max_bureau_b_2_pmts_pmtsoverdue_635A', 'last_bureau_b_2_pmts_pmtsoverdue_635A', 'max_debitcard_last180dayaveragebalance_704A', 'last_debitcard_last180dayaveragebalance_704A', 'max_debitcard_last180dayturnover_1134A', 'last_debitcard_last180dayturnover_1134A', 'max_debitcard_last30dayturnover_651A', 'last_debitcard_last30dayturnover_651A', 'max_other_amtdebitincoming_4809443A', 'last_other_amtdebitincoming_4809443A', 'max_other_amtdebitoutgoing_4809440A', 'last_other_amtdebitoutgoing_4809440A', 'max_other_amtdepositbalance_4809441A', 'last_other_amtdepositbalance_4809441A', 'max_other_amtdepositincoming_4809444A', 'last_other_amtdepositincoming_4809444A', 'max_other_amtdepositoutgoing_4809442A', 'last_other_amtdepositoutgoing_4809442A', 'max_other_num_group1', 'last_other_num_group1', 'max_person1_childnum_185L', 'last_person1_childnum_185L', 'max_person1_contaddr_district_15M', 'last_person1_contaddr_district_15M', 'max_person1_contaddr_matchlist_1032L', 'last_person1_contaddr_matchlist_1032L', 'last_person1_contaddr_smempladdr_334L', 'max_person1_contaddr_zipcode_807M', 'last_person1_contaddr_zipcode_807M', 'last_person1_empl_employedtotal_800L', 'last_person1_empl_industry_691L', 'last_person1_empladdr_district_926M', 'last_person1_empladdr_zipcode_114M', 'last_person1_familystate_447L', 'max_person1_gender_992L', 'last_person1_gender_992L', 'last_person1_housetype_905L', 'max_person1_housingtype_772L', 'last_person1_housingtype_772L', 'max_person1_isreference_387L', 'last_person1_isreference_387L', 'max_person1_maritalst_703L', 'last_person1_maritalst_703L', 'max_person1_registaddr_district_1083M', 'last_person1_registaddr_district_1083M', 'max_person1_registaddr_zipcode_184M', 'last_person1_registaddr_zipcode_184M', 'max_person1_remitter_829L', 'last_person1_remitter_829L', 'max_person1_role_993L', 'last_person1_role_993L', 'last_person1_safeguarantyflag_411L', 'last_person1_sex_738L', 'max_person2_addres_district_368M', 'last_person2_addres_district_368M', 'max_person2_addres_role_871L', 'last_person2_addres_role_871L', 'max_person2_addres_zip_823M', 'last_person2_addres_zip_823M', 'max_person2_empls_employer_name_740M', 'last_person2_empls_employer_name_740M', 'max_person2_relatedpersons_role_762T', 'last_person2_relatedpersons_role_762T', 'amtinstpaidbefduel24m_4187115A', 'avgdbddpdlast3m_4187120P', 'avgdbdtollast24m_4525197P', 'avglnamtstart24m_4525187A', 'avgoutstandbalancel6m_4187114A', 'avgpmtlast12m_4525200A', 'bankacctype_710L', 'cardtype_51L', 'clientscnt_136L', 'commnoinclast6m_3546845L', 'deferredmnthsnum_166L', 'equalitydataagreement_891L', 'equalityempfrom_62L', 'interestrategrace_34L', 'isbidproductrequest_292L', 'isdebitcard_729L', 'lastapprcommoditytypec_5251766M', 'lastcancelreason_561M', 'lastdependentsnum_448L', 'lastotherinc_902A', 'lastotherlnsexpense_631A', 'lastrejectcommodtypec_5251769M', 'mastercontrelectronic_519L', 'mastercontrexist_109L', 'maxannuity_4075009A', \n    'maxdbddpdtollast6m_4187119P', 'maxlnamtstart6m_4525199A', 'maxoutstandbalancel12m_4187113A', 'maxpmtlast3m_4525190A', 'mindbdtollast24m_4525191P', 'numinstlswithdpd5_4187116L', 'numinstmatpaidtearly2d_4499204L', 'numinstpaid_4499208L', 'numinstpaidearly3dest_4493216L', 'numinstpaidearly5dest_4493211L', 'numinstpaidearly5dobd_4499205L', 'numinstpaidearlyest_4493214L', 'numinstpaidlastcontr_4325080L', 'numinstregularpaidest_4493210L', 'numinsttopaygrest_4493213L', 'numinstunpaidmaxest_4493212L', 'opencred_647L', 'paytype1st_925L', 'paytype_783L', 'previouscontdistrict_112M', 'sumoutstandtotalest_4493215A', 'totinstallast1m_4525188A', 'typesuite_864L', 'max_static_cb_contractssum_5085716L', 'last_static_cb_contractssum_5085716L', 'max_static_cb_description_5085714M', 'last_static_cb_description_5085714M', 'max_static_cb_for3years_128L', 'last_static_cb_for3years_128L', 'max_static_cb_for3years_504L', 'last_static_cb_for3years_504L', 'max_static_cb_for3years_584L', 'last_static_cb_for3years_584L', 'max_static_cb_formonth_118L', 'last_static_cb_formonth_118L', 'max_static_cb_formonth_206L', 'last_static_cb_formonth_206L', 'max_static_cb_formonth_535L', 'last_static_cb_formonth_535L', 'max_static_cb_forquarter_1017L', 'last_static_cb_forquarter_1017L', 'max_static_cb_forquarter_462L', 'last_static_cb_forquarter_462L', 'max_static_cb_forquarter_634L', 'last_static_cb_forquarter_634L', 'max_static_cb_fortoday_1092L', 'last_static_cb_fortoday_1092L', 'max_static_cb_forweek_1077L', 'last_static_cb_forweek_1077L', 'max_static_cb_forweek_528L', 'last_static_cb_forweek_528L', 'max_static_cb_forweek_601L', 'last_static_cb_forweek_601L', 'max_static_cb_foryear_618L', 'last_static_cb_foryear_618L', 'max_static_cb_foryear_818L', 'last_static_cb_foryear_818L', 'max_static_cb_foryear_850L', 'last_static_cb_foryear_850L', 'max_static_cb_pmtaverage_4527227A', 'last_static_cb_pmtaverage_4527227A', 'max_static_cb_pmtaverage_4955615A', 'last_static_cb_pmtaverage_4955615A', 'max_static_cb_pmtcount_4955617L', 'last_static_cb_pmtcount_4955617L', 'max_static_cb_riskassesment_302T', 'last_static_cb_riskassesment_302T', 'max_static_cb_riskassesment_940T', 'last_static_cb_riskassesment_940T', 'max_tax_a_name_4527232M', 'last_tax_a_name_4527232M', 'max_tax_b_name_4917606M', 'last_tax_b_name_4917606M', 'max_tax_c_employername_160M', 'last_tax_c_employername_160M', 'last_credit_bureau_a_1_dateofcredend_289D', 'last_credit_bureau_a_1_dateofcredend_353D', 'last_credit_bureau_a_1_dateofcredstart_181D', 'last_credit_bureau_a_1_dateofcredstart_739D', 'last_credit_bureau_a_1_dateofrealrepmt_138D', 'last_credit_bureau_a_1_lastupdate_1112D', 'last_credit_bureau_a_1_lastupdate_388D', 'last_credit_bureau_a_1_numberofoverdueinstlmaxdat_148D', 'last_credit_bureau_a_1_numberofoverdueinstlmaxdat_641D', 'last_credit_bureau_a_1_overdueamountmax2date_1002D', 'last_credit_bureau_a_1_overdueamountmax2date_1142D', 'max_bureau_b_1_contractdate_551D', 'last_bureau_b_1_contractdate_551D', 'max_bureau_b_1_contractmaturitydate_151D', 'last_bureau_b_1_contractmaturitydate_151D', 'max_bureau_b_1_lastupdate_260D', 'last_bureau_b_1_lastupdate_260D', 'max_bureau_b_2_pmts_date_1107D', 'last_bureau_b_2_pmts_date_1107D', 'max_deposit_contractenddate_991D', 'last_deposit_contractenddate_991D', 'max_person1_birthdate_87D', 'last_person1_birthdate_87D', 'last_person1_empl_employedfrom_271D', 'max_person2_empls_employedfrom_796D', 'last_person2_empls_employedfrom_796D', 'lastrepayingdate_696D', 'payvacationpostpone_4187118D', 'max_static_cb_assignmentdate_4955616D', 'last_static_cb_assignmentdate_4955616D', 'max_static_cb_dateofbirth_342D', 'last_static_cb_dateofbirth_342D', 'std_applprev1_cancelreason_3545846M', 'std_applprev1_credacc_actualbalance_314A', 'std_applprev1_credacc_maxhisbal_375A', 'std_applprev1_credacc_minhisbal_90A', 'std_applprev1_credacc_status_367L', 'std_applprev1_credacc_transactions_402L', 'std_applprev1_credtype_587L', 'std_applprev1_district_544M', 'std_applprev1_education_1138M', 'std_applprev1_familystate_726L', 'std_applprev1_inittransactioncode_279L', 'std_applprev1_isbidproduct_390L', 'std_applprev1_isdebitcard_527L', 'std_applprev1_postype_4733339M', 'std_applprev1_profession_152M', 'std_applprev1_rejectreason_755M', 'std_applprev1_rejectreasonclient_4145042M', 'std_applprev1_revolvingaccount_394A', 'std_applprev1_status_219L', 'std_applprev2_cacccardblochreas_147M', 'std_applprev2_conts_type_509L', 'std_applprev2_credacc_cards_status_52L', 'std_credit_bureau_a_1_annualeffectiverate_63L', 'std_credit_bureau_a_1_classificationofcontr_13M', 'std_credit_bureau_a_1_classificationofcontr_400M', 'std_credit_bureau_a_1_contractst_545M', 'std_credit_bureau_a_1_contractst_964M', 'std_credit_bureau_a_1_debtoutstand_525A', 'std_credit_bureau_a_1_debtoverdue_47A', 'std_credit_bureau_a_1_description_351M', 'std_credit_bureau_a_1_financialinstitution_382M', 'std_credit_bureau_a_1_financialinstitution_591M', 'std_credit_bureau_a_1_interestrate_508L', 'std_credit_bureau_a_1_numberofcontrsvalue_258L', 'std_credit_bureau_a_1_numberofcontrsvalue_358L', 'std_credit_bureau_a_1_prolongationcount_1120L', 'std_credit_bureau_a_1_prolongationcount_599L', 'std_credit_bureau_a_1_purposeofcred_426M', 'std_credit_bureau_a_1_purposeofcred_874M', 'std_credit_bureau_a_1_subjectrole_182M', 'std_credit_bureau_a_1_subjectrole_93M', 'std_credit_bureau_a_1_totaldebtoverduevalue_178A', 'std_credit_bureau_a_1_totaldebtoverduevalue_718A', 'std_credit_bureau_a_1_totaloutstanddebtvalue_39A', 'std_credit_bureau_a_1_totaloutstanddebtvalue_668A', 'std_bureau_b_1_amount_1115A', 'std_bureau_b_1_classificationofcontr_1114M', 'std_bureau_b_1_contractst_516M', 'std_bureau_b_1_contracttype_653M', 'std_bureau_b_1_credlmt_1052A', 'std_bureau_b_1_credlmt_228A', 'std_bureau_b_1_credlmt_3940954A', 'std_bureau_b_1_credor_3940957M', 'std_bureau_b_1_credquantity_1099L', 'std_bureau_b_1_credquantity_984L', 'std_bureau_b_1_debtpastduevalue_732A', 'std_bureau_b_1_debtvalue_227A', 'std_bureau_b_1_dpd_550P', 'std_bureau_b_1_dpd_733P', 'std_bureau_b_1_dpdmax_851P', 'std_bureau_b_1_dpdmaxdatemonth_804T', 'std_bureau_b_1_dpdmaxdateyear_742T', 'std_bureau_b_1_installmentamount_644A', 'std_bureau_b_1_installmentamount_833A', 'std_bureau_b_1_instlamount_892A', 'std_bureau_b_1_interesteffectiverate_369L', 'std_bureau_b_1_interestrateyearly_538L', 'std_bureau_b_1_maxdebtpduevalodued_3940955A', 'std_bureau_b_1_num_group1', 'std_bureau_b_1_numberofinstls_810L', 'std_bureau_b_1_overdueamountmax_950A', 'std_bureau_b_1_overdueamountmaxdatemonth_494T', 'std_bureau_b_1_overdueamountmaxdateyear_432T', 'std_bureau_b_1_periodicityofpmts_997L', 'std_bureau_b_1_periodicityofpmts_997M', 'std_bureau_b_1_pmtdaysoverdue_1135P', 'std_bureau_b_1_pmtmethod_731M', 'std_bureau_b_1_pmtnumpending_403L', 'std_bureau_b_1_purposeofcred_722M', 'std_bureau_b_1_residualamount_1093A', 'std_bureau_b_1_residualamount_127A', 'std_bureau_b_1_residualamount_3940956A', 'std_bureau_b_1_subjectrole_326M', 'std_bureau_b_1_subjectrole_43M', 'std_bureau_b_1_totalamount_503A', 'std_bureau_b_1_totalamount_881A', 'std_bureau_b_2_num_group1', 'std_bureau_b_2_num_group2', 'std_bureau_b_2_pmts_dpdvalue_108P', 'std_bureau_b_2_pmts_pmtsoverdue_635A', 'std_debitcard_last180dayaveragebalance_704A', 'std_debitcard_last180dayturnover_1134A', 'std_debitcard_last30dayturnover_651A', 'std_debitcard_num_group1', 'std_deposit_amount_416A', 'std_deposit_num_group1', 'std_other_amtdebitincoming_4809443A', 'std_other_amtdebitoutgoing_4809440A', 'std_other_amtdepositbalance_4809441A', 'std_other_amtdepositincoming_4809444A', 'std_other_amtdepositoutgoing_4809442A', 'std_other_num_group1', 'std_person1_childnum_185L', 'std_person1_contaddr_district_15M', 'std_person1_contaddr_matchlist_1032L', 'std_person1_contaddr_smempladdr_334L', 'std_person1_contaddr_zipcode_807M', 'std_person1_education_927M', 'std_person1_empl_employedtotal_800L', 'std_person1_empl_industry_691L', 'std_person1_empladdr_district_926M', 'std_person1_empladdr_zipcode_114M', 'std_person1_familystate_447L', 'std_person1_gender_992L', 'std_person1_housetype_905L', 'std_person1_housingtype_772L', 'std_person1_incometype_1044T', 'std_person1_isreference_387L', 'std_person1_language1_981M', 'std_person1_mainoccupationinc_384A', 'std_person1_maritalst_703L', 'std_person1_registaddr_district_1083M', 'std_person1_registaddr_zipcode_184M', 'std_person1_relationshiptoclient_415T', 'std_person1_relationshiptoclient_642T', 'std_person1_remitter_829L', 'std_person1_role_1084L', 'std_person1_role_993L', 'std_person1_safeguarantyflag_411L', 'std_person1_sex_738L', 'std_person1_type_25L', 'std_person2_addres_district_368M', 'std_person2_addres_role_871L', 'std_person2_addres_zip_823M', 'std_person2_conts_role_79M', 'std_person2_empls_economicalst_849M', 'std_person2_empls_employer_name_740M', 'std_person2_relatedpersons_role_762T', 'std_static_cb_contractssum_5085716L', 'std_static_cb_days120_123L', 'std_static_cb_days180_256L', 'std_static_cb_days30_165L', 'std_static_cb_days360_512L', 'std_static_cb_days90_310L', 'std_static_cb_description_5085714M', 'std_static_cb_education_1103M', 'std_static_cb_education_88M', 'std_static_cb_firstquarter_103L', 'std_static_cb_for3years_128L', 'std_static_cb_for3years_504L', 'std_static_cb_for3years_584L', 'std_static_cb_formonth_118L', 'std_static_cb_formonth_206L', 'std_static_cb_formonth_535L', 'std_static_cb_forquarter_1017L', 'std_static_cb_forquarter_462L', 'std_static_cb_forquarter_634L', 'std_static_cb_fortoday_1092L', 'std_static_cb_forweek_1077L', 'std_static_cb_forweek_528L', 'std_static_cb_forweek_601L', 'std_static_cb_foryear_618L', 'std_static_cb_foryear_818L', 'std_static_cb_foryear_850L', 'std_static_cb_fourthquarter_440L', 'std_static_cb_maritalst_385M', 'std_static_cb_maritalst_893M', 'std_static_cb_numberofqueries_373L', 'std_static_cb_pmtaverage_3A', 'std_static_cb_pmtaverage_4527227A', 'std_static_cb_pmtaverage_4955615A', 'std_static_cb_pmtcount_4527229L', 'std_static_cb_pmtcount_4955617L', \n    'std_static_cb_pmtcount_693L', 'std_static_cb_pmtscount_423L', 'std_static_cb_pmtssum_45A', 'std_static_cb_requesttype_4525192L', 'std_static_cb_riskassesment_302T', 'std_static_cb_riskassesment_940T', 'std_static_cb_secondquarter_766L', 'std_static_cb_thirdquarter_1082L', 'std_tax_a_name_4527232M', 'std_tax_b_name_4917606M', 'std_tax_c_employername_160M', 'std_applprev1_approvaldate_319D', 'std_applprev1_creationdate_885D', 'std_applprev1_dateactivated_425D', 'std_applprev1_dtlastpmt_581D', 'std_applprev1_dtlastpmtallstes_3545839D', 'std_applprev1_employedfrom_700D', 'std_applprev1_firstnonzeroinstldate_307D', 'std_credit_bureau_a_1_dateofcredend_289D', 'std_credit_bureau_a_1_dateofcredend_353D', 'std_credit_bureau_a_1_dateofcredstart_181D', 'std_credit_bureau_a_1_dateofcredstart_739D', 'std_credit_bureau_a_1_dateofrealrepmt_138D', 'std_credit_bureau_a_1_lastupdate_1112D', 'std_credit_bureau_a_1_lastupdate_388D', 'std_credit_bureau_a_1_numberofoverdueinstlmaxdat_148D', 'std_credit_bureau_a_1_numberofoverdueinstlmaxdat_641D', 'std_credit_bureau_a_1_overdueamountmax2date_1002D', 'std_credit_bureau_a_1_overdueamountmax2date_1142D', 'std_credit_bureau_a_1_refreshdate_3813885D', 'std_bureau_b_1_contractdate_551D', 'std_bureau_b_1_contractmaturitydate_151D', 'std_bureau_b_1_lastupdate_260D', 'std_bureau_b_2_pmts_date_1107D', 'std_debitcard_openingdate_857D', 'std_deposit_contractenddate_991D', 'std_deposit_openingdate_313D', 'std_person1_birth_259D', 'std_person1_birthdate_87D', 'std_person1_empl_employedfrom_271D', 'std_person2_empls_employedfrom_796D', 'std_static_cb_assignmentdate_238D', 'std_static_cb_assignmentdate_4527235D', 'std_static_cb_assignmentdate_4955616D', 'std_static_cb_birthdate_574D', 'std_static_cb_dateofbirth_337D', 'std_static_cb_dateofbirth_342D', 'std_static_cb_responsedate_1012D', 'std_static_cb_responsedate_4527233D', 'std_static_cb_responsedate_4917613D', 'std_tax_a_recorddate_4527225D', 'std_tax_b_deductiondate_4917603D', 'std_tax_c_processingdate_168D', 'mean_collater_typofvalofguarant_298M', 'mean_collater_typofvalofguarant_407M', 'std_collater_typofvalofguarant_407M', 'last_collater_valueofguarantee_1124L', 'last_collater_valueofguarantee_876L', 'mean_collaterals_typeofguarante_359M', 'std_collaterals_typeofguarante_359M', 'mean_collaterals_typeofguarante_669M', 'std_collaterals_typeofguarante_669M', 'last_pmts_dpd_1073P', 'last_pmts_dpd_303P', 'mean_pmts_month_158T', 'mean_pmts_month_706T', 'last_pmts_overdue_1140A', 'last_pmts_overdue_1152A', 'mean_subjectroles_name_541M', 'std_subjectroles_name_541M', 'mean_subjectroles_name_838M', 'std_subjectroles_name_838M', 'last_subjectroles_name_838M', 'count_bureau_b_1_amount_1115A', 'count_bureau_b_1_classificationofcontr_1114M', 'count_bureau_b_1_contractdate_551D', 'count_bureau_b_1_contractmaturitydate_151D', 'count_bureau_b_1_contractst_516M', 'count_bureau_b_1_contracttype_653M', 'count_bureau_b_1_credlmt_1052A', 'count_bureau_b_1_credlmt_228A', 'count_bureau_b_1_credlmt_3940954A', 'count_bureau_b_1_credor_3940957M', 'count_bureau_b_1_credquantity_1099L', 'count_bureau_b_1_credquantity_984L', 'count_bureau_b_1_debtpastduevalue_732A', 'count_bureau_b_1_debtvalue_227A', 'count_bureau_b_1_dpd_550P', 'count_bureau_b_1_dpd_733P', 'count_bureau_b_1_dpdmax_851P', 'count_bureau_b_1_dpdmaxdatemonth_804T', 'count_bureau_b_1_dpdmaxdateyear_742T', 'count_bureau_b_1_installmentamount_644A', 'count_bureau_b_1_installmentamount_833A', 'count_bureau_b_1_instlamount_892A', 'count_bureau_b_1_interesteffectiverate_369L', 'count_bureau_b_1_interestrateyearly_538L', 'count_bureau_b_1_lastupdate_260D', 'count_bureau_b_1_maxdebtpduevalodued_3940955A', 'count_bureau_b_1_num_group1', 'count_bureau_b_1_numberofinstls_810L', 'count_bureau_b_1_overdueamountmax_950A', 'count_bureau_b_1_overdueamountmaxdatemonth_494T', 'count_bureau_b_1_overdueamountmaxdateyear_432T', 'count_bureau_b_1_periodicityofpmts_997L', 'count_bureau_b_1_periodicityofpmts_997M', 'count_bureau_b_1_pmtdaysoverdue_1135P', 'count_bureau_b_1_pmtmethod_731M', 'count_bureau_b_1_pmtnumpending_403L', 'count_bureau_b_1_purposeofcred_722M', 'count_bureau_b_1_residualamount_1093A', 'count_bureau_b_1_residualamount_127A', 'count_bureau_b_1_residualamount_3940956A', 'count_bureau_b_1_subjectrole_326M', 'count_bureau_b_1_subjectrole_43M', 'count_bureau_b_1_totalamount_503A', 'count_bureau_b_1_totalamount_881A', 'count_bureau_b_2_num_group1', 'count_bureau_b_2_num_group2', 'count_bureau_b_2_pmts_date_1107D', 'count_bureau_b_2_pmts_dpdvalue_108P', 'count_bureau_b_2_pmts_pmtsoverdue_635A', 'count_other_amtdebitincoming_4809443A', 'count_other_amtdebitoutgoing_4809440A', 'count_other_amtdepositbalance_4809441A', 'count_other_amtdepositincoming_4809444A', 'count_other_amtdepositoutgoing_4809442A', 'count_other_num_group1', 'count_person1_birth_259D', 'count_person1_incometype_1044T', 'count_person1_mainoccupationinc_384A', 'count_person1_sex_738L', 'count_static_cb_description_5085714M', 'count_static_cb_education_1103M', 'count_static_cb_education_88M', 'count_static_cb_maritalst_385M', 'count_static_cb_maritalst_893M','first_pmts_dpd_303P','first_pmts_overdue_1152A',\n    'count_applprev1_credacc_transactions_402L', 'last_applprev2_cacccardblochreas_147M', 'last_credit_bureau_a_1_classificationofcontr_13M', 'last_credit_bureau_a_1_contractst_545M', 'count_credit_bureau_a_1_debtoutstand_525A', 'count_credit_bureau_a_1_debtoverdue_47A', 'last_credit_bureau_a_1_description_351M', 'last_credit_bureau_a_1_financialinstitution_591M', 'count_credit_bureau_a_1_overdueamountmax2_14A', 'last_credit_bureau_a_1_purposeofcred_426M', 'last_credit_bureau_a_1_subjectrole_93M', 'count_credit_bureau_a_1_totalamount_6A', 'max_collater_typofvalofguarant_407M', 'last_collater_typofvalofguarant_407M', 'last_collaterals_typeofguarante_359M', 'last_collaterals_typeofguarante_669M', 'last_subjectroles_name_541M', 'count_person1_birthdate_87D', 'count_person1_contaddr_matchlist_1032L', 'count_person1_contaddr_smempladdr_334L', 'count_person1_contaddr_zipcode_807M', 'count_person1_education_927M', 'max_person1_empladdr_district_926M', 'max_person1_empladdr_zipcode_114M', 'count_person1_empladdr_zipcode_114M', 'count_person1_gender_992L', 'count_person1_housingtype_772L', 'count_person1_isreference_387L', 'max_person1_persontype_1072L', 'max_person1_persontype_792L', 'count_person1_persontype_792L', 'count_person1_registaddr_district_1083M', 'count_person1_role_993L', 'count_person1_safeguarantyflag_411L', 'max_person2_conts_role_79M', 'max_person2_empls_economicalst_849M', 'last_person2_empls_economicalst_849M', 'applicationcnt_361L', 'clientscnt_157L', 'clientscnt_257L', 'count_static_cb_days120_123L', 'count_static_cb_days180_256L', 'count_static_cb_days30_165L', 'count_static_cb_days360_512L', 'count_static_cb_days90_310L', 'last_static_cb_education_88M', 'count_static_cb_firstquarter_103L', 'count_static_cb_formonth_118L', 'count_static_cb_formonth_206L', 'count_static_cb_formonth_535L', 'count_static_cb_forquarter_1017L', 'count_static_cb_forquarter_462L', 'count_static_cb_forquarter_634L', 'count_static_cb_fortoday_1092L', 'count_static_cb_forweek_1077L', 'count_static_cb_forweek_528L', 'count_static_cb_forweek_601L', 'count_static_cb_foryear_618L', 'count_static_cb_foryear_818L', 'count_static_cb_foryear_850L', 'count_static_cb_fourthquarter_440L', 'last_static_cb_maritalst_893M', 'count_static_cb_numberofqueries_373L', 'count_static_cb_secondquarter_766L', 'count_static_cb_thirdquarter_1082L', 'count_applprev1_credacc_minhisbal_90A', 'max_credit_bureau_a_1_overdueamount_31A', 'count_credit_bureau_a_1_totaloutstanddebtvalue_39A', 'count_person1_childnum_185L', 'count_person1_empladdr_district_926M', 'count_person1_language1_981M', 'count_person1_personindex_1023L', 'count_person1_registaddr_zipcode_184M', 'count_person1_remitter_829L', 'count_person1_type_25L', 'last_person2_conts_role_79M', 'clientscnt_100L', 'count_applprev1_credacc_maxhisbal_375A', 'count_applprev1_credacc_status_367L', 'count_applprev2_credacc_cards_status_52L', 'applicationscnt_629L', 'numpmtchanneldd_318L', 'count_credit_bureau_a_1_dateofcredend_289D', 'count_credit_bureau_a_1_dateofcredend_353D', 'count_collater_valueofguarantee_1124L', 'count_person1_contaddr_district_15M', 'count_person1_persontype_1072L', 'applications30d_658L', 'clientscnt3m_3712950L', 'clientscnt_304L', 'clientscnt_493L', 'count_deposit_openingdate_313D', 'clientscnt_1130L', 'count_credit_bureau_a_1_interestrate_508L', 'count_credit_bureau_a_1_overdueamountmax_155A', 'count_credit_bureau_a_1_overdueamountmaxdateyear_2T', 'count_person1_maritalst_703L', 'count_person1_num_group1', 'count_static_cb_for3years_584L', 'count_credit_bureau_a_1_refreshdate_3813885D', 'count_credit_bureau_a_1_totaldebtoverduevalue_178A', 'max_person1_education_927M', 'numactivecreds_622L', 'max_applprev1_actualdpd_943P', 'count_applprev1_credacc_actualbalance_314A', 'count_applprev1_revolvingaccount_394A', 'count_credit_bureau_a_1_dateofcredstart_739D', 'count_credit_bureau_a_1_dpdmax_757P', 'count_credit_bureau_a_1_lastupdate_1112D', 'max_credit_bureau_a_1_numberofoverdueinstls_834L', 'max_credit_bureau_a_1_outstandingamount_354A', 'count_credit_bureau_a_1_overdueamountmaxdatemonth_284T', 'count_credit_bureau_a_1_totaldebtoverduevalue_718A', 'max_collaterals_typeofguarante_359M', 'count_debitcard_last180dayturnover_1134A', 'count_debitcard_openingdate_857D', 'count_person1_relationshiptoclient_415T', 'count_person1_role_1084L', 'applicationscnt_464L', 'numactiverelcontr_750L', 'numnotactivated_1143L', 'count_static_cb_dateofbirth_337D', 'max_static_cb_education_88M', 'max_static_cb_maritalst_893M', 'count_static_cb_pmtcount_4527229L', 'count_credit_bureau_a_1_overdueamountmax_35A'\n]\n\ndf_train = Pipeline.filter_cols(df_train, cols_drop)\ndf_test = df_test.select([col for col in df_train.columns if col != \"target\"])\n\nprint(\"train data shape:\\t\", df_train.shape)\nprint(\"test data shape:\\t\", df_test.shape)","metadata":{"execution":{"iopub.status.busy":"2024-04-14T17:36:56.901062Z","iopub.execute_input":"2024-04-14T17:36:56.901334Z","iopub.status.idle":"2024-04-14T17:38:09.644931Z","shell.execute_reply.started":"2024-04-14T17:36:56.901310Z","shell.execute_reply":"2024-04-14T17:38:09.643961Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Pandas Conversion","metadata":{}},{"cell_type":"code","source":"df_train, cat_cols = to_pandas(df_train)\ndf_test, cat_cols = to_pandas(df_test, cat_cols)","metadata":{"execution":{"iopub.status.busy":"2024-04-14T17:38:09.646350Z","iopub.execute_input":"2024-04-14T17:38:09.646719Z","iopub.status.idle":"2024-04-14T17:38:26.714463Z","shell.execute_reply.started":"2024-04-14T17:38:09.646686Z","shell.execute_reply":"2024-04-14T17:38:26.713485Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Garbage Collection","metadata":{}},{"cell_type":"code","source":"del data_store\n\ngc.collect()","metadata":{"execution":{"iopub.status.busy":"2024-04-14T17:38:26.715622Z","iopub.execute_input":"2024-04-14T17:38:26.715881Z","iopub.status.idle":"2024-04-14T17:38:26.961323Z","shell.execute_reply.started":"2024-04-14T17:38:26.715859Z","shell.execute_reply":"2024-04-14T17:38:26.960324Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### EDA","metadata":{}},{"cell_type":"code","source":"print(\"Train is duplicated:\\t\", df_train[\"case_id\"].duplicated().any())\nprint(\"Train Week Range:\\t\", (df_train[\"WEEK_NUM\"].min(), df_train[\"WEEK_NUM\"].max()))\n\nprint()\n\nprint(\"Test is duplicated:\\t\", df_test[\"case_id\"].duplicated().any())\nprint(\"Test Week Range:\\t\", (df_test[\"WEEK_NUM\"].min(), df_test[\"WEEK_NUM\"].max()))","metadata":{"execution":{"iopub.status.busy":"2024-04-14T17:38:26.962777Z","iopub.execute_input":"2024-04-14T17:38:26.963136Z","iopub.status.idle":"2024-04-14T17:38:26.993924Z","shell.execute_reply.started":"2024-04-14T17:38:26.963109Z","shell.execute_reply":"2024-04-14T17:38:26.993087Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.lineplot(\n    data=df_train,\n    x=\"WEEK_NUM\",\n    y=\"target\",\n)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-04-14T17:38:26.995173Z","iopub.execute_input":"2024-04-14T17:38:26.995848Z","iopub.status.idle":"2024-04-14T17:38:43.654005Z","shell.execute_reply.started":"2024-04-14T17:38:26.995803Z","shell.execute_reply":"2024-04-14T17:38:43.653131Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train[\"WEEK_NUM\"].min(), df_train[\"WEEK_NUM\"].max()","metadata":{"execution":{"iopub.status.busy":"2024-04-14T17:38:43.655224Z","iopub.execute_input":"2024-04-14T17:38:43.655499Z","iopub.status.idle":"2024-04-14T17:38:43.662164Z","shell.execute_reply.started":"2024-04-14T17:38:43.655475Z","shell.execute_reply":"2024-04-14T17:38:43.661142Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.isna().sum()[df_train.isna().sum() > 0]","metadata":{"execution":{"iopub.status.busy":"2024-04-14T17:38:43.663355Z","iopub.execute_input":"2024-04-14T17:38:43.663675Z","iopub.status.idle":"2024-04-14T17:38:44.970779Z","shell.execute_reply.started":"2024-04-14T17:38:43.663649Z","shell.execute_reply":"2024-04-14T17:38:44.969748Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Training NN","metadata":{}},{"cell_type":"code","source":"# Enconding categorical features\n\nfrom sklearn.preprocessing import LabelEncoder\n\nlabel_encoders = {}\nfor col in cat_cols:\n    le = LabelEncoder()\n    all_values = pd.concat([df_train[col], df_test[col]], axis=0)\n    le.fit(all_values)\n    df_train[col] = le.transform(df_train[col])\n    df_test[col] = le.transform(df_test[col])\n    label_encoders[col] = le    ","metadata":{"execution":{"iopub.status.busy":"2024-04-14T17:38:44.972253Z","iopub.execute_input":"2024-04-14T17:38:44.972542Z","iopub.status.idle":"2024-04-14T17:39:14.791340Z","shell.execute_reply.started":"2024-04-14T17:38:44.972517Z","shell.execute_reply":"2024-04-14T17:39:14.790337Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# splitting valid dataset\n\nX_train, X_valid = df_train[df_train[\"WEEK_NUM\"] <= 77], df_train[df_train[\"WEEK_NUM\"] > 77]\nX_train, X_valid = X_train.drop([\"WEEK_NUM\", \"case_id\"], axis=1), X_valid.drop([\"WEEK_NUM\", \"case_id\"], axis=1)\ny_train, y_valid = X_train.pop(\"target\"), X_valid.pop(\"target\")\nX_train_week, X_valid_week = df_train.loc[df_train[\"WEEK_NUM\"] <= 77, \"WEEK_NUM\"],\\\n                                df_train.loc[df_train[\"WEEK_NUM\"] > 77, \"WEEK_NUM\"]\n\nX_train, X_valid = X_train.values, X_valid.values\ny_train, y_valid = y_train.values, y_valid.values\n# week_train, week_valid = X_train_week.values(), X_valid_week.values()\n\nX_test = df_test.drop([\"WEEK_NUM\", \"case_id\"], axis=1)\nX_test = X_test.values","metadata":{"execution":{"iopub.status.busy":"2024-04-14T17:39:14.792591Z","iopub.execute_input":"2024-04-14T17:39:14.792886Z","iopub.status.idle":"2024-04-14T17:39:18.860823Z","shell.execute_reply.started":"2024-04-14T17:39:14.792861Z","shell.execute_reply":"2024-04-14T17:39:18.859972Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Model\ninp = tf.keras.layers.Input(shape=[X_train.shape[1],])\nbn = tf.keras.layers.BatchNormalization()(inp)\nx = tf.keras.layers.Dropout(0.2)(bn)\n\nhidden = [128, 64, 32]\nfor h in hidden:\n    x = tf.keras.layers.Dense(h, activation=\"relu\")(x)\n    x = tf.keras.layers.BatchNormalization()(x)\n    x = tf.keras.layers.Dropout(0.2)(x)\n    \nout = tf.keras.layers.Dense(1, activation=\"sigmoid\")(x)\n\nmodel = tf.keras.models.Model(inputs=inp, outputs=out)\n\nmodel.summary()","metadata":{"execution":{"iopub.status.busy":"2024-04-14T17:39:18.862495Z","iopub.execute_input":"2024-04-14T17:39:18.862875Z","iopub.status.idle":"2024-04-14T17:39:19.095094Z","shell.execute_reply.started":"2024-04-14T17:39:18.862839Z","shell.execute_reply":"2024-04-14T17:39:19.094096Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tf.keras.utils.plot_model(model)","metadata":{"execution":{"iopub.status.busy":"2024-04-14T17:39:19.096599Z","iopub.execute_input":"2024-04-14T17:39:19.097051Z","iopub.status.idle":"2024-04-14T17:39:19.326874Z","shell.execute_reply.started":"2024-04-14T17:39:19.097004Z","shell.execute_reply":"2024-04-14T17:39:19.325960Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"lr = 0.1\nls = 0.01\n\nmodel.compile(\n    optimizer=tf.keras.optimizers.Adam(lr),\n    loss=tf.keras.losses.BinaryCrossentropy(label_smoothing=ls),\n    metrics=[tf.keras.metrics.AUC(name='AUC')]\n)","metadata":{"execution":{"iopub.status.busy":"2024-04-14T17:39:19.331462Z","iopub.execute_input":"2024-04-14T17:39:19.331801Z","iopub.status.idle":"2024-04-14T17:39:19.358320Z","shell.execute_reply.started":"2024-04-14T17:39:19.331775Z","shell.execute_reply":"2024-04-14T17:39:19.357578Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# tf.keras.backend.clear_session()","metadata":{"execution":{"iopub.status.busy":"2024-04-14T17:39:19.359244Z","iopub.execute_input":"2024-04-14T17:39:19.359508Z","iopub.status.idle":"2024-04-14T17:39:19.363346Z","shell.execute_reply.started":"2024-04-14T17:39:19.359485Z","shell.execute_reply":"2024-04-14T17:39:19.362442Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class MetricsCallback(tf.keras.callbacks.Callback):\n    def __init__(self, validation_data, weeks):\n        super().__init__()\n        self.x, self.y = validation_data\n        self.weeks = weeks\n        \n    def stability_metric(self, preds):\n        unique_weeks = tf.unique(self.weeks)[0]\n        unique_weeks = tf.sort(unique_weeks)\n        ginis = []\n\n        for week in unique_weeks:\n            mask = tf.equal(self.weeks, week)\n            label_week = tf.boolean_mask(self.y, mask)\n            preds_week = tf.boolean_mask(preds, mask)\n\n            auc_score = roc_auc_score(label_week, preds_week)\n            ginis.append((auc_score-0.5)*2)\n\n        y = tf.convert_to_tensor(ginis, dtype=\"float32\")\n        x = tf.range(1, len(ginis)+1, 1, dtype=\"float32\") \n        mean_x = tf.math.reduce_mean(x)\n        mean_y = tf.math.reduce_mean(y)\n        var_x = tfp.stats.variance(x)\n        cov_xy = tfp.stats.covariance(x, y, event_axis=None)\n\n        beta1 = cov_xy / var_x\n        beta0 = mean_y - beta1*mean_x\n\n        y_hat = beta1*x + beta0\n        residuals = y - y_hat\n        res_std = tfp.stats.stddev(residuals)\n        avg_gini = tf.reduce_mean(y)\n\n        return avg_gini + 88.0*tf.minimum(beta1, 0) - 0.5*res_std\n            \n    def on_epoch_end(self, epoch, logs=True):\n        preds = self.model.predict(self.x)\n        metric = self.stability_metric(preds)\n        logs[\"stab_met\"] = metric.numpy()\n\n        \nmetrics_callback = MetricsCallback(\n    validation_data=(X_valid, y_valid), \n    weeks=X_valid_week\n)","metadata":{"execution":{"iopub.status.busy":"2024-04-14T17:39:19.364432Z","iopub.execute_input":"2024-04-14T17:39:19.364738Z","iopub.status.idle":"2024-04-14T17:39:19.408220Z","shell.execute_reply.started":"2024-04-14T17:39:19.364713Z","shell.execute_reply":"2024-04-14T17:39:19.407244Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"history = model.fit(\n    X_train, y_train, \n    validation_data=(X_valid, y_valid),\n    epochs=20, \n    batch_size=10000,\n    callbacks=[\n        metrics_callback,\n#         tf.keras.callbacks.EarlyStopping(monitor=\"stab_met\", patience=4, restore_best_weights=True),\n        tf.keras.callbacks.ReduceLROnPlateau(monitor='stab_met', factor=0.1, patience=2, \n                                             verbose=1, min_delta=1e-4, mode='max')\n    ]\n)","metadata":{"execution":{"iopub.status.busy":"2024-04-14T17:39:19.409325Z","iopub.execute_input":"2024-04-14T17:39:19.409622Z","iopub.status.idle":"2024-04-14T17:43:42.487276Z","shell.execute_reply.started":"2024-04-14T17:39:19.409597Z","shell.execute_reply":"2024-04-14T17:43:42.486435Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.DataFrame(history.history)","metadata":{"execution":{"iopub.status.busy":"2024-04-14T17:43:42.488971Z","iopub.execute_input":"2024-04-14T17:43:42.489349Z","iopub.status.idle":"2024-04-14T17:43:42.510621Z","shell.execute_reply.started":"2024-04-14T17:43:42.489316Z","shell.execute_reply":"2024-04-14T17:43:42.509755Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Fine-tuning on validation data\nmodel.compile(optimizer=tf.keras.optimizers.Adam(learning_rate=lr / 1000),\n              loss=tf.keras.losses.BinaryCrossentropy(label_smoothing=ls), \n              metrics=[tf.keras.metrics.AUC(name='AUC')])\nmodel.fit(X_valid, y_valid, epochs=5, batch_size=10000, verbose=1)","metadata":{"execution":{"iopub.status.busy":"2024-04-14T17:43:42.517020Z","iopub.execute_input":"2024-04-14T17:43:42.517324Z","iopub.status.idle":"2024-04-14T17:43:46.944787Z","shell.execute_reply.started":"2024-04-14T17:43:42.517287Z","shell.execute_reply":"2024-04-14T17:43:46.943905Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Prediction","metadata":{}},{"cell_type":"code","source":"y_pred = model.predict(X_test).ravel()","metadata":{"execution":{"iopub.status.busy":"2024-04-14T17:43:46.945999Z","iopub.execute_input":"2024-04-14T17:43:46.946324Z","iopub.status.idle":"2024-04-14T17:43:47.114279Z","shell.execute_reply.started":"2024-04-14T17:43:46.946299Z","shell.execute_reply":"2024-04-14T17:43:47.113463Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_pred[:10]","metadata":{"execution":{"iopub.status.busy":"2024-04-14T17:43:47.115671Z","iopub.execute_input":"2024-04-14T17:43:47.115956Z","iopub.status.idle":"2024-04-14T17:43:47.122691Z","shell.execute_reply.started":"2024-04-14T17:43:47.115924Z","shell.execute_reply":"2024-04-14T17:43:47.121752Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Submission","metadata":{}},{"cell_type":"code","source":"df_subm = pd.read_csv(ROOT / \"sample_submission.csv\")\ndf_subm = df_subm.set_index(\"case_id\")\n\ndf_subm[\"score\"] = y_pred","metadata":{"execution":{"iopub.status.busy":"2024-04-14T17:43:47.123878Z","iopub.execute_input":"2024-04-14T17:43:47.124195Z","iopub.status.idle":"2024-04-14T17:43:47.150183Z","shell.execute_reply.started":"2024-04-14T17:43:47.124159Z","shell.execute_reply":"2024-04-14T17:43:47.149223Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Check null: \", df_subm[\"score\"].isnull().any())\n\ndf_subm.head()","metadata":{"execution":{"iopub.status.busy":"2024-04-14T17:43:47.151472Z","iopub.execute_input":"2024-04-14T17:43:47.152125Z","iopub.status.idle":"2024-04-14T17:43:47.162074Z","shell.execute_reply.started":"2024-04-14T17:43:47.152090Z","shell.execute_reply":"2024-04-14T17:43:47.161076Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_subm.to_csv(\"submission.csv\")","metadata":{"execution":{"iopub.status.busy":"2024-04-14T17:43:47.163249Z","iopub.execute_input":"2024-04-14T17:43:47.163538Z","iopub.status.idle":"2024-04-14T17:43:47.172796Z","shell.execute_reply.started":"2024-04-14T17:43:47.163513Z","shell.execute_reply":"2024-04-14T17:43:47.172075Z"},"trusted":true},"execution_count":null,"outputs":[]}]}