{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":88400,"databundleVersionId":10121331,"sourceType":"competition"}],"dockerImageVersionId":30786,"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":"2024-11-17T10:19:39.278147Z","iopub.execute_input":"2024-11-17T10:19:39.278603Z","iopub.status.idle":"2024-11-17T10:19:40.621606Z","shell.execute_reply.started":"2024-11-17T10:19:39.278559Z","shell.execute_reply":"2024-11-17T10:19:40.620245Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"card_df = pd.read_csv(\"/kaggle/input/aiffel-ds-3-credit-card-fraud-detection/train.csv\") \ntest_df = pd.read_csv(\"/kaggle/input/aiffel-ds-3-credit-card-fraud-detection/test.csv\")\nsubmission = pd.read_csv(\"/kaggle/input/aiffel-ds-3-credit-card-fraud-detection/sample_submission.csv\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-17T10:21:21.698743Z","iopub.execute_input":"2024-11-17T10:21:21.699376Z","iopub.status.idle":"2024-11-17T10:21:26.423081Z","shell.execute_reply.started":"2024-11-17T10:21:21.699331Z","shell.execute_reply":"2024-11-17T10:21:26.421978Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"conda install -c conda-forge imbalanced-learn","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-17T10:23:08.828972Z","iopub.execute_input":"2024-11-17T10:23:08.829492Z","iopub.status.idle":"2024-11-17T10:24:59.639981Z","shell.execute_reply.started":"2024-11-17T10:23:08.829435Z","shell.execute_reply":"2024-11-17T10:24:59.638548Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nimport warnings\nwarnings.filterwarnings(\"ignore\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-17T10:25:39.700631Z","iopub.execute_input":"2024-11-17T10:25:39.701197Z","iopub.status.idle":"2024-11-17T10:25:39.70668Z","shell.execute_reply.started":"2024-11-17T10:25:39.701145Z","shell.execute_reply":"2024-11-17T10:25:39.705341Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"card_df.head(3)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-17T10:26:54.553366Z","iopub.execute_input":"2024-11-17T10:26:54.553756Z","iopub.status.idle":"2024-11-17T10:26:54.599876Z","shell.execute_reply.started":"2024-11-17T10:26:54.553719Z","shell.execute_reply":"2024-11-17T10:26:54.598691Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"card_df.info()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-17T10:27:23.825762Z","iopub.execute_input":"2024-11-17T10:27:23.826901Z","iopub.status.idle":"2024-11-17T10:27:23.866007Z","shell.execute_reply.started":"2024-11-17T10:27:23.826814Z","shell.execute_reply":"2024-11-17T10:27:23.8648Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"card_df.isna().mean()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-17T11:17:13.586157Z","iopub.execute_input":"2024-11-17T11:17:13.586624Z","iopub.status.idle":"2024-11-17T11:17:13.608969Z","shell.execute_reply.started":"2024-11-17T11:17:13.586578Z","shell.execute_reply":"2024-11-17T11:17:13.607468Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"card_df.describe()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-17T11:17:46.316954Z","iopub.execute_input":"2024-11-17T11:17:46.31743Z","iopub.status.idle":"2024-11-17T11:17:46.6364Z","shell.execute_reply.started":"2024-11-17T11:17:46.317383Z","shell.execute_reply":"2024-11-17T11:17:46.635326Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"sns.scatterplot(data=card_df,x='Amount',y='Class')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-17T11:19:59.285876Z","iopub.execute_input":"2024-11-17T11:19:59.28641Z","iopub.status.idle":"2024-11-17T11:20:00.179653Z","shell.execute_reply.started":"2024-11-17T11:19:59.286364Z","shell.execute_reply":"2024-11-17T11:20:00.178434Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"corr=card_df.corr()\nsns.heatmap(corr)\nplt.show","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-17T11:21:56.658421Z","iopub.execute_input":"2024-11-17T11:21:56.658942Z","iopub.status.idle":"2024-11-17T11:21:58.055815Z","shell.execute_reply.started":"2024-11-17T11:21:56.658896Z","shell.execute_reply":"2024-11-17T11:21:58.054367Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.model_selection import train_test_split\n\n\ndef get_preprocessed_df(df=None):\n    df_copy = df.copy()\n    df_copy.drop('Time', axis=1, inplace=True)\n    return df_copy","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-17T10:29:01.667878Z","iopub.execute_input":"2024-11-17T10:29:01.668364Z","iopub.status.idle":"2024-11-17T10:29:02.394454Z","shell.execute_reply.started":"2024-11-17T10:29:01.66832Z","shell.execute_reply":"2024-11-17T10:29:02.393149Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def get_train_test_dataset(df=None):\n    df_copy = get_preprocessed_df(df)\n    \n    X_features = df_copy.iloc[:, :-1]\n    y_target = df_copy.iloc[:, -1]\n    \n    X_train, X_test, y_train, y_test = train_test_split(X_features, y_target, test_size=0.3, random_state=0, stratify=y_target)\n    return X_train, X_test, y_train, y_test\n\nX_train, X_test, y_train, y_test = get_train_test_dataset(card_df)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-17T10:30:53.22838Z","iopub.execute_input":"2024-11-17T10:30:53.229005Z","iopub.status.idle":"2024-11-17T10:30:53.397063Z","shell.execute_reply.started":"2024-11-17T10:30:53.228962Z","shell.execute_reply":"2024-11-17T10:30:53.395847Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print('학습 데이터 레이블 값 비율')\nprint(y_train.value_counts()/y_train.shape[0] * 100)\nprint('테스트 데이터 레이블 값 비율')\nprint(y_test.value_counts()/y_test.shape[0] * 100)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-17T10:31:42.207694Z","iopub.execute_input":"2024-11-17T10:31:42.208115Z","iopub.status.idle":"2024-11-17T10:31:42.224131Z","shell.execute_reply.started":"2024-11-17T10:31:42.208075Z","shell.execute_reply":"2024-11-17T10:31:42.222431Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.metrics import confusion_matrix, accuracy_score, precision_score, recall_score, f1_score, roc_auc_score\ndef get_clf_eval(y_test, pred=None, pred_proba=None):\n    confusion = confusion_matrix(y_test, pred)\n    accuracy = accuracy_score(y_test, pred)\n    precision = precision_score(y_test, pred)\n    recall = recall_score(y_test, pred)\n    f1 = f1_score(y_test, pred)\n    roc_auc = roc_auc_score(y_test, pred)\n    \n    print('오차행렬')\n    print(confusion)\n    print('정확도: {0:.4f}, 정밀도: {1:.4f}, 재현율: {2:.4f}, F1: {3:.4f}, AUC:{4:.4f}'\n          .format(accuracy, precision, recall, f1, roc_auc))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-17T10:36:55.905842Z","iopub.execute_input":"2024-11-17T10:36:55.906293Z","iopub.status.idle":"2024-11-17T10:36:55.913773Z","shell.execute_reply.started":"2024-11-17T10:36:55.906232Z","shell.execute_reply":"2024-11-17T10:36:55.912534Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.linear_model import LogisticRegression\n\nlr_clf = LogisticRegression()\nlr_clf.fit(X_train, y_train)\nlr_pred = lr_clf.predict(X_test)\nlr_pred_proba = lr_clf.predict_proba(X_test)[:, 1]\n\nget_clf_eval(y_test, lr_pred, lr_pred_proba)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-17T10:37:23.197599Z","iopub.execute_input":"2024-11-17T10:37:23.198035Z","iopub.status.idle":"2024-11-17T10:37:25.185128Z","shell.execute_reply.started":"2024-11-17T10:37:23.197995Z","shell.execute_reply":"2024-11-17T10:37:25.183714Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.ensemble import RandomForestClassifier\n\nrf_clf = RandomForestClassifier()\nrf_clf.fit(X_train, y_train)\nrf_pred = rf_clf.predict(X_test)\nrf_pred_proba = rf_clf.predict_proba(X_test)[:, 1]\n\nget_clf_eval(y_test, rf_pred, rf_pred_proba)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-17T12:17:24.968883Z","iopub.execute_input":"2024-11-17T12:17:24.969322Z","iopub.status.idle":"2024-11-17T12:19:35.11419Z","shell.execute_reply.started":"2024-11-17T12:17:24.969281Z","shell.execute_reply":"2024-11-17T12:19:35.113012Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def get_model_train_eval(model, ftr_train=None, ftr_test=None, tgt_train=None, tgt_test=None):\n    model.fit(ftr_train, tgt_train)\n    pred = model.predict(ftr_test)\n    pred_proba = model.predict_proba(ftr_test)[:, 1]\n    get_clf_eval(tgt_test, pred, pred_proba)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-17T10:38:54.386639Z","iopub.execute_input":"2024-11-17T10:38:54.387187Z","iopub.status.idle":"2024-11-17T10:38:54.394348Z","shell.execute_reply.started":"2024-11-17T10:38:54.387141Z","shell.execute_reply":"2024-11-17T10:38:54.392916Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from lightgbm import LGBMClassifier\n\nlgbm_clf = LGBMClassifier(n_estimators=1000, num_leaves=64, n_jobs=-1, boost_from_average=False)\nget_model_train_eval(lgbm_clf, ftr_train=X_train, ftr_test=X_test, tgt_train=y_train, tgt_test=y_test)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-17T10:41:16.720791Z","iopub.execute_input":"2024-11-17T10:41:16.721603Z","iopub.status.idle":"2024-11-17T10:41:57.612108Z","shell.execute_reply.started":"2024-11-17T10:41:16.721548Z","shell.execute_reply":"2024-11-17T10:41:57.610935Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import seaborn as sns\n\nplt.figure(figsize=(8, 4))\nplt.xticks(range(0, 30000, 1000), rotation=60)\nsns.distplot(card_df['Amount'])","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-17T10:44:17.366232Z","iopub.execute_input":"2024-11-17T10:44:17.366742Z","iopub.status.idle":"2024-11-17T10:44:19.055527Z","shell.execute_reply.started":"2024-11-17T10:44:17.366699Z","shell.execute_reply":"2024-11-17T10:44:19.054305Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.preprocessing import StandardScaler\ndef get_preprocessed_df(df=None):\n    df_copy = df.copy()\n    scaler = StandardScaler()\n    amount_n = scaler.fit_transform(df_copy['Amount'].values.reshape(-1, 1))\n    df_copy.insert(0, 'Amount_Scaled', amount_n)\n    df_copy.drop(['Time', 'Amount'], axis=1, inplace=True)\n    return df_copy\nX_train, X_test, y_train, y_test = get_train_test_dataset(card_df)\n\nprint('### 로지스틱 회귀 예측 성능 ###')\nlr_clf = LogisticRegression()\nget_model_train_eval(lr_clf, ftr_train=X_train, ftr_test=X_test, tgt_train=y_train, tgt_test=y_test)\n\nprint('\\n### LightGBM 예측 성능 ###')\nlgbm_clf = LGBMClassifier(n_estimators=1000, num_leaves=64, n_jobs=-1, boost_from_average=False)\nget_model_train_eval(lgbm_clf, ftr_train=X_train, ftr_test=X_test, tgt_train=y_train, tgt_test=y_test)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-17T11:01:02.821965Z","iopub.execute_input":"2024-11-17T11:01:02.823185Z","iopub.status.idle":"2024-11-17T11:01:45.829311Z","shell.execute_reply.started":"2024-11-17T11:01:02.823126Z","shell.execute_reply":"2024-11-17T11:01:45.827989Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def get_preprocessed_df(df=None):\n    df_copy = df.copy()\n    amount_n = np.log1p(df_copy['Amount'])\n    df_copy.insert(0, 'Amount_Scaled', amount_n)\n    df_copy.drop(['Time', 'Amount'], axis=1, inplace=True)\n    return df_copy\nX_train, X_test, y_train, y_test = get_train_test_dataset(card_df)\n\nprint('### 로지스틱 회귀 예측 성능 ###')\nget_model_train_eval(lr_clf, ftr_train=X_train, ftr_test=X_test, tgt_train=y_train, tgt_test=y_test)\n\nprint('\\n### LightGBM 예측 성능 ###')\nget_model_train_eval(lgbm_clf, ftr_train=X_train, ftr_test=X_test, tgt_train=y_train, tgt_test=y_test)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-17T11:02:55.685692Z","iopub.execute_input":"2024-11-17T11:02:55.687115Z","iopub.status.idle":"2024-11-17T11:03:38.542952Z","shell.execute_reply.started":"2024-11-17T11:02:55.687047Z","shell.execute_reply":"2024-11-17T11:03:38.541736Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.figure(figsize=(18, 18))\nsns.heatmap(card_df.corr(), cmap='RdBu', annot=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-17T11:04:36.384631Z","iopub.execute_input":"2024-11-17T11:04:36.385136Z","iopub.status.idle":"2024-11-17T11:04:40.588117Z","shell.execute_reply.started":"2024-11-17T11:04:36.385094Z","shell.execute_reply":"2024-11-17T11:04:40.586972Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def get_outlier(df=None, column=None, weight=1.5):\n    fraud = df[df['Class'] == 1][column]\n    q25 = np.percentile(fraud.values, 25)\n    q75 = np.percentile(fraud.values, 75)\n    iqr = q75 - q25\n    iqr_weight = iqr * weight\n    low_val = q25 - iqr_weight\n    high_val = q75 + iqr_weight\n    outlier_index = fraud[(fraud < low_val) | (fraud > high_val)].index\n    return outlier_index\noutlier_index = get_outlier(df=card_df, column='V14', weight=1.5)\nprint(f'이상치 데이터 인덱스: {outlier_index}')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-17T11:05:38.144319Z","iopub.execute_input":"2024-11-17T11:05:38.144771Z","iopub.status.idle":"2024-11-17T11:05:38.158163Z","shell.execute_reply.started":"2024-11-17T11:05:38.144729Z","shell.execute_reply":"2024-11-17T11:05:38.156935Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"\ndef get_preprocessed_df(df=None):\n    df_copy = df.copy()\n    amount_n = np.log1p(df_copy['Amount'])\n    df_copy.insert(0, 'Amount_Scaled', amount_n)\n    df_copy.drop(['Time', 'Amount'], axis=1, inplace=True)\n    outlier_index = get_outlier(df=df_copy, column='V14', weight=1.5)\n    df_copy.drop(outlier_index, axis=0, inplace=True)\n    return df_copy\n\nX_train, X_test, y_train, y_test = get_train_test_dataset(card_df)\nprint('### 로지스틱 회귀 예측 성능 ###')\nget_model_train_eval(lr_clf, ftr_train=X_train, ftr_test=X_test, tgt_train=y_train, tgt_test=y_test)\n\nprint('\\n### LightGBM 예측 성능 ###')\nget_model_train_eval(lgbm_clf, ftr_train=X_train, ftr_test=X_test, tgt_train=y_train, tgt_test=y_test)\n\nfrom sklearn.ensemble import RandomForestClassifier\n \nrf_clf=RandomForestClassifier(n_estimators=100,random_state=0)\nprint('###랜덤 포레스트 회귀 예측 성능 ###')\nget_model_train_eval(rf_clf, ftr_train=X_train, ftr_test=X_test, tgt_train=y_train, tgt_test=y_test)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-17T12:20:55.71192Z","iopub.execute_input":"2024-11-17T12:20:55.712493Z","iopub.status.idle":"2024-11-17T12:23:51.22748Z","shell.execute_reply.started":"2024-11-17T12:20:55.712444Z","shell.execute_reply":"2024-11-17T12:23:51.225982Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def get_outlier(df=None, column=None, weight=1.5):\n    fraud = df[df['Class'] == 1][column]\n    q25 = np.percentile(fraud.values, 25)\n    q75 = np.percentile(fraud.values, 75)\n    iqr = q75 - q25\n    iqr_weight = iqr * weight\n    low_val = q25 - iqr_weight\n    high_val = q75 + iqr_weight\n    outlier_index = fraud[(fraud < low_val) | (fraud > high_val)].index\n    return outlier_index\noutlier_index = get_outlier(df=card_df, column='V17', weight=1.5)\nprint(f'이상치 데이터 인덱스: {outlier_index}')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-17T11:53:20.694301Z","iopub.execute_input":"2024-11-17T11:53:20.694754Z","iopub.status.idle":"2024-11-17T11:53:20.707631Z","shell.execute_reply.started":"2024-11-17T11:53:20.694712Z","shell.execute_reply":"2024-11-17T11:53:20.706357Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from imblearn.over_sampling import SMOTE\n\nsmote = SMOTE(random_state=0)\nX_train_over, y_train_over = smote.fit_resample(X_train, y_train)\nprint(f'SMOTE 적용 전 학습용 피처/레이블 데이터 세트: {X_train.shape, y_train.shape}')\nprint(f'SMOTE 적용 후 학습용 피처/레이블 데이터 세트: {X_train_over.shape, y_train_over.shape}')\nprint(f'SMOTE 적용 후 레이블 값 분포: \\n{pd.Series(y_train_over).value_counts()}')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-17T11:11:32.48491Z","iopub.execute_input":"2024-11-17T11:11:32.485552Z","iopub.status.idle":"2024-11-17T11:11:32.780546Z","shell.execute_reply.started":"2024-11-17T11:11:32.485498Z","shell.execute_reply":"2024-11-17T11:11:32.77915Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"lr_clf = LogisticRegression()\n\nget_model_train_eval(lr_clf, ftr_train=X_train_over, ftr_test=X_test, tgt_train=y_train_over, tgt_test=y_test)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-17T11:12:48.364639Z","iopub.execute_input":"2024-11-17T11:12:48.365176Z","iopub.status.idle":"2024-11-17T11:12:51.905688Z","shell.execute_reply.started":"2024-11-17T11:12:48.365131Z","shell.execute_reply":"2024-11-17T11:12:51.904351Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.metrics import precision_recall_curve\ndef precision_recall_curve_plot(y_test, pred_proba_c1):\n    precisions, recalls, thresholds = precision_recall_curve(y_test, pred_proba_c1)\n    \n    \n    plt.figure(figsize=(8, 6))\n    threshold_boundary = thresholds.shape[0]\n    plt.plot(thresholds, precisions[0:threshold_boundary], linestyle='--', label='precision')\n    plt.plot(thresholds, recalls[0:threshold_boundary], label='recall')\n    \n    \n    start, end = plt.xlim()\n    plt.xticks(np.round(np.arange(start, end, 0.1), 2))\n    \n    \n    plt.xlabel('Threshold value')\n    plt.ylabel('Precision and Recall value')\n    plt.legend()\n    plt.grid()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-17T11:14:15.664907Z","iopub.execute_input":"2024-11-17T11:14:15.666277Z","iopub.status.idle":"2024-11-17T11:14:15.676846Z","shell.execute_reply.started":"2024-11-17T11:14:15.666187Z","shell.execute_reply":"2024-11-17T11:14:15.675421Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"precision_recall_curve_plot(y_test, lr_clf.predict_proba(X_test)[:, 1])","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-17T11:15:01.656286Z","iopub.execute_input":"2024-11-17T11:15:01.656918Z","iopub.status.idle":"2024-11-17T11:15:02.266683Z","shell.execute_reply.started":"2024-11-17T11:15:01.656874Z","shell.execute_reply":"2024-11-17T11:15:02.265073Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"submission = pd.DataFrame({'id': 'hyemiyeo', 'Class': y_pred})\nsubmission.to_csv('submission.csv', index=False)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-17T12:29:09.821496Z","iopub.execute_input":"2024-11-17T12:29:09.821997Z","iopub.status.idle":"2024-11-17T12:29:09.863166Z","shell.execute_reply.started":"2024-11-17T12:29:09.821956Z","shell.execute_reply":"2024-11-17T12:29:09.861241Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"lgbm_clf = LGBMClassifier(n_estimators=1000, num_leaves=64, n_jobs=-1, boost_from_average=False)\nget_model_train_eval(lgbm_clf, ftr_train=X_train_over, ftr_test=X_test, tgt_train=y_train_over, tgt_test=y_test)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-17T11:15:36.22517Z","iopub.execute_input":"2024-11-17T11:15:36.225641Z","iopub.status.idle":"2024-11-17T11:17:13.583454Z","shell.execute_reply.started":"2024-11-17T11:15:36.225598Z","shell.execute_reply":"2024-11-17T11:17:13.582217Z"}},"outputs":[],"execution_count":null}]}