{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"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","execution":{"iopub.status.busy":"2023-04-03T07:45:11.211169Z","iopub.execute_input":"2023-04-03T07:45:11.211646Z","iopub.status.idle":"2023-04-03T07:45:11.221027Z","shell.execute_reply.started":"2023-04-03T07:45:11.211611Z","shell.execute_reply":"2023-04-03T07:45:11.219645Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install -U deepctr-torch","metadata":{"execution":{"iopub.status.busy":"2023-04-03T07:45:11.223384Z","iopub.execute_input":"2023-04-03T07:45:11.224211Z","iopub.status.idle":"2023-04-03T07:45:21.413810Z","shell.execute_reply.started":"2023-04-03T07:45:11.224169Z","shell.execute_reply":"2023-04-03T07:45:21.412495Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\n\nimport pandas as pd\nimport torch\nfrom sklearn.metrics import mean_squared_error\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.preprocessing import LabelEncoder\n\nfrom deepctr_torch.inputs import SparseFeat, get_feature_names,DenseFeat\nfrom deepctr_torch.models import DeepFM","metadata":{"execution":{"iopub.status.busy":"2023-04-03T07:45:21.416530Z","iopub.execute_input":"2023-04-03T07:45:21.416958Z","iopub.status.idle":"2023-04-03T07:45:21.423490Z","shell.execute_reply.started":"2023-04-03T07:45:21.416912Z","shell.execute_reply":"2023-04-03T07:45:21.422334Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nimport warnings\nwarnings.filterwarnings('ignore')\nsns.set_theme(style=\"darkgrid\")\npd.set_option('display.max_columns', 0)\nplt.style.use('ggplot')\npd.options.display.float_format = '{:.2f}'.format\nimport math\nfrom sklearn.preprocessing import LabelEncoder ,MinMaxScaler\nfrom sklearn.model_selection import train_test_split\nfrom sklearn import metrics\nfrom sklearn.feature_selection import RFE\nfrom sklearn.model_selection import GridSearchCV\nimport random\nimport gzip\nimport category_encoders as ce\npd.options.display.float_format = '{:.2f}'.format","metadata":{"execution":{"iopub.status.busy":"2023-04-03T07:45:21.427167Z","iopub.execute_input":"2023-04-03T07:45:21.428123Z","iopub.status.idle":"2023-04-03T07:45:21.444188Z","shell.execute_reply.started":"2023-04-03T07:45:21.428061Z","shell.execute_reply":"2023-04-03T07:45:21.443022Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\nnum_records = 40428967\nsample_size = 40028967\nskip_values = sorted(random.sample(range(1,num_records), num_records - sample_size))\nparse_date = lambda val : pd.datetime.strptime(val, '%y%m%d%H')\n\n\ndata = pd.read_csv( \"../input/avazu-ctr-prediction/train.gz\", parse_dates=['hour'],chunksize=500000, date_parser=parse_date,\\\n                     skiprows=skip_values)\ndata=next(data)","metadata":{"execution":{"iopub.status.busy":"2023-04-03T07:45:21.447282Z","iopub.execute_input":"2023-04-03T07:45:21.448351Z","iopub.status.idle":"2023-04-03T07:45:31.770448Z","shell.execute_reply.started":"2023-04-03T07:45:21.448307Z","shell.execute_reply":"2023-04-03T07:45:31.769341Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.shape","metadata":{"execution":{"iopub.status.busy":"2023-04-03T07:45:31.771841Z","iopub.execute_input":"2023-04-03T07:45:31.772246Z","iopub.status.idle":"2023-04-03T07:45:31.779612Z","shell.execute_reply.started":"2023-04-03T07:45:31.772206Z","shell.execute_reply":"2023-04-03T07:45:31.778291Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"datecolumn=['hour']\nfor col in datecolumn:\n    data[col+'month'] = data[col].dt.month\n    data[col+'dayofweek'] = data[col].dt.dayofweek\n    data[col+'day'] = data[col].dt.day\n    data[col+'hour_time'] = data[col].dt.hour\ndata.head(2)","metadata":{"execution":{"iopub.status.busy":"2023-04-03T07:45:31.781562Z","iopub.execute_input":"2023-04-03T07:45:31.782462Z","iopub.status.idle":"2023-04-03T07:45:31.999913Z","shell.execute_reply.started":"2023-04-03T07:45:31.782418Z","shell.execute_reply":"2023-04-03T07:45:31.998738Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\ncol = ['C15', 'C16', 'C19', 'C21']\nfor col in col:\n    percentiles = data[col].quantile(0.98)\n    if data[col].quantile(0.98) < 0.5 * data[col].max():\n        data[col][data[col] >= percentiles] = percentiles","metadata":{"execution":{"iopub.status.busy":"2023-04-03T07:45:32.001469Z","iopub.execute_input":"2023-04-03T07:45:32.002496Z","iopub.status.idle":"2023-04-03T07:45:32.056661Z","shell.execute_reply.started":"2023-04-03T07:45:32.002451Z","shell.execute_reply":"2023-04-03T07:45:32.055498Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"label='click'\ntarget = [label]\ndense_features = []\nsparse_features = []\n\nfor col in (list(data.columns)):\n    if data[col].dtype == \"object\":\n        sparse_features.append(col)\n    else:\n        dense_features.append(col)\ndense_features.remove(label)","metadata":{"execution":{"iopub.status.busy":"2023-04-03T07:45:32.059107Z","iopub.execute_input":"2023-04-03T07:45:32.059799Z","iopub.status.idle":"2023-04-03T07:45:32.069234Z","shell.execute_reply.started":"2023-04-03T07:45:32.059754Z","shell.execute_reply":"2023-04-03T07:45:32.068050Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\ndata[sparse_features] = data[sparse_features].fillna('-1', )\ndata[dense_features] = data[dense_features].fillna(0, )","metadata":{"execution":{"iopub.status.busy":"2023-04-03T07:45:32.076198Z","iopub.execute_input":"2023-04-03T07:45:32.077754Z","iopub.status.idle":"2023-04-03T07:45:35.037463Z","shell.execute_reply.started":"2023-04-03T07:45:32.077700Z","shell.execute_reply":"2023-04-03T07:45:35.036303Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"drop_unique_ids=[]\n\nfor col in (list(data.columns)):\n    if len(list(data[col].unique())) == data.shape[0]:\n        drop_unique_ids.append(col)\ndrop_unique_ids","metadata":{"execution":{"iopub.status.busy":"2023-04-03T07:45:35.039391Z","iopub.execute_input":"2023-04-03T07:45:35.039818Z","iopub.status.idle":"2023-04-03T07:45:35.458789Z","shell.execute_reply.started":"2023-04-03T07:45:35.039776Z","shell.execute_reply":"2023-04-03T07:45:35.457747Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"if(len(datecolumn)>0):\n    data.drop(datecolumn, axis=1, inplace=True)\n","metadata":{"execution":{"iopub.status.busy":"2023-04-03T07:45:35.460246Z","iopub.execute_input":"2023-04-03T07:45:35.461117Z","iopub.status.idle":"2023-04-03T07:45:35.523458Z","shell.execute_reply.started":"2023-04-03T07:45:35.461074Z","shell.execute_reply":"2023-04-03T07:45:35.522409Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"if(len(drop_unique_ids)>0):\n    data.drop(drop_unique_ids, axis=1, inplace=True)","metadata":{"execution":{"iopub.status.busy":"2023-04-03T07:45:35.524831Z","iopub.execute_input":"2023-04-03T07:45:35.525819Z","iopub.status.idle":"2023-04-03T07:45:35.616021Z","shell.execute_reply.started":"2023-04-03T07:45:35.525778Z","shell.execute_reply":"2023-04-03T07:45:35.614953Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dense_features.remove('id')\ndense_features.remove('hour')\ndense_features.remove('C17')\n","metadata":{"execution":{"iopub.status.busy":"2023-04-03T07:45:35.617683Z","iopub.execute_input":"2023-04-03T07:45:35.618075Z","iopub.status.idle":"2023-04-03T07:45:35.622944Z","shell.execute_reply.started":"2023-04-03T07:45:35.618033Z","shell.execute_reply":"2023-04-03T07:45:35.621908Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\n    # 1.Label Encoding for sparse features,and do simple Transformation for dense features\nfor feat in sparse_features:\n        lbe = LabelEncoder()\n        data[feat] = lbe.fit_transform(data[feat])\nmms = MinMaxScaler(feature_range=(0, 1))\ndata[dense_features] = mms.fit_transform(data[dense_features])","metadata":{"execution":{"iopub.status.busy":"2023-04-03T07:45:35.624598Z","iopub.execute_input":"2023-04-03T07:45:35.625324Z","iopub.status.idle":"2023-04-03T07:45:37.893005Z","shell.execute_reply.started":"2023-04-03T07:45:35.625282Z","shell.execute_reply":"2023-04-03T07:45:37.891949Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\n# 2.count #unique features for each sparse field,and record dense feature field name\n\nfixlen_feature_columns = [SparseFeat(feat, vocabulary_size=data[feat].max() + 1, embedding_dim=4)\n                              for feat in sparse_features] + [DenseFeat(feat, 1, )\n                                                              for feat in dense_features]\n","metadata":{"execution":{"iopub.status.busy":"2023-04-03T07:45:37.894655Z","iopub.execute_input":"2023-04-03T07:45:37.895547Z","iopub.status.idle":"2023-04-03T07:45:37.909888Z","shell.execute_reply.started":"2023-04-03T07:45:37.895514Z","shell.execute_reply":"2023-04-03T07:45:37.908906Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dnn_feature_columns = fixlen_feature_columns\nlinear_feature_columns = fixlen_feature_columns\n\nfeature_names = get_feature_names(\n        linear_feature_columns + dnn_feature_columns)\nfeature_names","metadata":{"execution":{"iopub.status.busy":"2023-04-03T07:45:37.911562Z","iopub.execute_input":"2023-04-03T07:45:37.911947Z","iopub.status.idle":"2023-04-03T07:45:37.920226Z","shell.execute_reply.started":"2023-04-03T07:45:37.911909Z","shell.execute_reply":"2023-04-03T07:45:37.918742Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\n# 3.generate input data for model\n\ntrain, test = train_test_split(data, test_size=0.2)\ntrain_model_input = {name: train[name] for name in feature_names}\ntest_model_input = {name: test[name] for name in feature_names}\ntrain","metadata":{"execution":{"iopub.status.busy":"2023-04-03T07:45:37.923192Z","iopub.execute_input":"2023-04-03T07:45:37.923485Z","iopub.status.idle":"2023-04-03T07:45:38.117141Z","shell.execute_reply.started":"2023-04-03T07:45:37.923458Z","shell.execute_reply":"2023-04-03T07:45:38.115978Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"  # 4.Define Model,train,predict and evaluate\n\ndevice = 'cpu'\nuse_cuda = True\nif use_cuda and torch.cuda.is_available():\n        print('cuda ready...')\n        device = 'cuda:0'","metadata":{"execution":{"iopub.status.busy":"2023-04-03T07:45:38.119115Z","iopub.execute_input":"2023-04-03T07:45:38.119527Z","iopub.status.idle":"2023-04-03T07:45:38.126489Z","shell.execute_reply.started":"2023-04-03T07:45:38.119483Z","shell.execute_reply":"2023-04-03T07:45:38.124873Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## DEEPFM","metadata":{}},{"cell_type":"code","source":"model = DeepFM(linear_feature_columns=linear_feature_columns, dnn_feature_columns=dnn_feature_columns,\n                   task='binary',\n                   l2_reg_embedding=1e-1, device=device)\nmodel.compile(\"adagrad\", \"binary_crossentropy\",\n                  metrics=[\"binary_crossentropy\", \"auc\"], )","metadata":{"execution":{"iopub.status.busy":"2023-04-03T07:45:38.128623Z","iopub.execute_input":"2023-04-03T07:45:38.129567Z","iopub.status.idle":"2023-04-03T07:45:38.162874Z","shell.execute_reply.started":"2023-04-03T07:45:38.129522Z","shell.execute_reply":"2023-04-03T07:45:38.161961Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"history = model.fit(train_model_input, train[target].values, batch_size=512, epochs=10, verbose=2,\n                        validation_split=0.15)\n","metadata":{"execution":{"iopub.status.busy":"2023-04-03T07:45:38.164563Z","iopub.execute_input":"2023-04-03T07:45:38.164962Z","iopub.status.idle":"2023-04-03T07:47:16.749366Z","shell.execute_reply.started":"2023-04-03T07:45:38.164923Z","shell.execute_reply":"2023-04-03T07:47:16.748175Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import log_loss, roc_auc_score,accuracy_score\nfrom sklearn.metrics import f1_score\nfrom sklearn.metrics import cohen_kappa_score\nfrom sklearn.metrics import roc_auc_score,roc_curve\nimport statsmodels.api as sm\nfrom sklearn.metrics import precision_score,recall_score\npred_ans = model.predict(test_model_input, 256)","metadata":{"execution":{"iopub.status.busy":"2023-04-03T07:47:16.750960Z","iopub.execute_input":"2023-04-03T07:47:16.751555Z","iopub.status.idle":"2023-04-03T07:47:18.072302Z","shell.execute_reply.started":"2023-04-03T07:47:16.751513Z","shell.execute_reply":"2023-04-03T07:47:18.071252Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ypred=[]\nfor i in pred_ans:\n    ypred.append(round(i[0]))","metadata":{"execution":{"iopub.status.busy":"2023-04-03T07:47:18.074082Z","iopub.execute_input":"2023-04-03T07:47:18.074449Z","iopub.status.idle":"2023-04-03T07:47:18.242493Z","shell.execute_reply.started":"2023-04-03T07:47:18.074413Z","shell.execute_reply":"2023-04-03T07:47:18.241315Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\nprint(\"\")\nprint(\"test LogLoss\", round(log_loss(test[target].values, pred_ans), 4))\nprint(\"test AUC\", round(roc_auc_score(test[target].values, pred_ans), 4))\nprint(\"test Roc accuracy \", round(roc_auc_score(test[target].values,ypred), 4))\nprint(\"test f1 score\", round(f1_score(test[target].values,ypred), 4))\nprint(\"test precision score\", round(precision_score(test[target].values,ypred), 4))\nprint(\"test recall score\", round(recall_score(test[target].values,ypred), 4))\nprint(\"test accuracy score\", round(accuracy_score(test[target].values,ypred), 4))\n","metadata":{"execution":{"iopub.status.busy":"2023-04-03T07:47:18.244128Z","iopub.execute_input":"2023-04-03T07:47:18.245191Z","iopub.status.idle":"2023-04-03T07:47:18.546370Z","shell.execute_reply.started":"2023-04-03T07:47:18.245147Z","shell.execute_reply":"2023-04-03T07:47:18.545206Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## XDEEPFM","metadata":{}},{"cell_type":"code","source":"from deepctr_torch.models import xDeepFM\nmodel = xDeepFM(linear_feature_columns=linear_feature_columns, dnn_feature_columns=dnn_feature_columns,\n                   task='binary',\n                   l2_reg_embedding=1e-1, device=device)\nmodel.compile(\"adagrad\", \"binary_crossentropy\",\n                  metrics=[\"binary_crossentropy\", \"auc\"], )","metadata":{"execution":{"iopub.status.busy":"2023-04-03T07:47:18.548145Z","iopub.execute_input":"2023-04-03T07:47:18.548543Z","iopub.status.idle":"2023-04-03T07:47:18.581417Z","shell.execute_reply.started":"2023-04-03T07:47:18.548505Z","shell.execute_reply":"2023-04-03T07:47:18.580492Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"history = model.fit(train_model_input, train[target].values, batch_size=512, epochs=10, verbose=2,\n                        validation_split=0.15)\n","metadata":{"execution":{"iopub.status.busy":"2023-04-03T07:47:18.582940Z","iopub.execute_input":"2023-04-03T07:47:18.583346Z","iopub.status.idle":"2023-04-03T07:49:09.950399Z","shell.execute_reply.started":"2023-04-03T07:47:18.583309Z","shell.execute_reply":"2023-04-03T07:49:09.949126Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pred_ans = model.predict(test_model_input, 256)\nypred=[]\nfor i in pred_ans:\n    ypred.append(round(i[0]))\n\nprint(\"\")\nprint(\"test LogLoss\", round(log_loss(test[target].values, pred_ans), 4))\nprint(\"test AUC\", round(roc_auc_score(test[target].values, pred_ans), 4))\nprint(\"test Roc accuracy \", round(roc_auc_score(test[target].values,ypred), 4))\n\nprint(\"test f1 score\", round(f1_score(test[target].values,ypred), 4))\nprint(\"test precision score\", round(precision_score(test[target].values,ypred), 4))\nprint(\"test recall score\", round(recall_score(test[target].values,ypred), 4))\nprint(\"test accuracy score\", round(accuracy_score(test[target].values,ypred), 4))","metadata":{"execution":{"iopub.status.busy":"2023-04-03T07:49:09.952307Z","iopub.execute_input":"2023-04-03T07:49:09.952718Z","iopub.status.idle":"2023-04-03T07:49:11.986667Z","shell.execute_reply.started":"2023-04-03T07:49:09.952677Z","shell.execute_reply":"2023-04-03T07:49:11.985677Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Wide & Deep","metadata":{}},{"cell_type":"code","source":"from deepctr_torch.models import WDL\nmodel = WDL(linear_feature_columns=linear_feature_columns, dnn_feature_columns=dnn_feature_columns,\n                   task='binary',\n                   l2_reg_embedding=1e-3, device=device)\nmodel.compile(\"adagrad\", \"binary_crossentropy\",\n                  metrics=[\"binary_crossentropy\", \"auc\"], )\nhistory = model.fit(train_model_input, train[target].values, batch_size=512, epochs=10, verbose=2,\n                        validation_split=0.15)\n\npred_ans = model.predict(test_model_input, 256)","metadata":{"execution":{"iopub.status.busy":"2023-04-03T07:49:11.991935Z","iopub.execute_input":"2023-04-03T07:49:11.992532Z","iopub.status.idle":"2023-04-03T07:50:47.893225Z","shell.execute_reply.started":"2023-04-03T07:49:11.992501Z","shell.execute_reply":"2023-04-03T07:50:47.891906Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ypred=[]\nfor i in pred_ans:\n    ypred.append(round(i[0]))\n\nprint(\"\")\nprint(\"test LogLoss\", round(log_loss(test[target].values, pred_ans), 4))\nprint(\"test AUC\", round(roc_auc_score(test[target].values, pred_ans), 4))\nprint(\"test Roc accuracy \", round(roc_auc_score(test[target].values,ypred), 4))\nprint(\"test f1 score\", round(f1_score(test[target].values,ypred), 4))\nprint(\"test precision score\", round(precision_score(test[target].values,ypred), 4))\nprint(\"test recall score\", round(recall_score(test[target].values,ypred), 4))\nprint(\"test accuracy score\", round(accuracy_score(test[target].values,ypred), 4))","metadata":{"execution":{"iopub.status.busy":"2023-04-03T07:50:47.894912Z","iopub.execute_input":"2023-04-03T07:50:47.895863Z","iopub.status.idle":"2023-04-03T07:50:48.375284Z","shell.execute_reply.started":"2023-04-03T07:50:47.895817Z","shell.execute_reply":"2023-04-03T07:50:48.373923Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Deep Cross","metadata":{}},{"cell_type":"code","source":"\nfrom deepctr_torch.models import DCN\nmodel = DCN(linear_feature_columns=linear_feature_columns, dnn_feature_columns=dnn_feature_columns,\n                   task='binary',\n                   l2_reg_embedding=1e-3, device=device)\nmodel.compile(\"adagrad\", \"binary_crossentropy\",\n                  metrics=[\"binary_crossentropy\", \"auc\"], )\nhistory = model.fit(train_model_input, train[target].values, batch_size=512, epochs=10, verbose=2,\n                        validation_split=0.15)\n\npred_ans = model.predict(test_model_input, 256)","metadata":{"execution":{"iopub.status.busy":"2023-04-03T07:50:48.377109Z","iopub.execute_input":"2023-04-03T07:50:48.377519Z","iopub.status.idle":"2023-04-03T07:52:33.635758Z","shell.execute_reply.started":"2023-04-03T07:50:48.377479Z","shell.execute_reply":"2023-04-03T07:52:33.634661Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ypred=[]\nfor i in pred_ans:\n    ypred.append(round(i[0]))\n\nprint(\"\")\nprint(\"test LogLoss\", round(log_loss(test[target].values, pred_ans), 4))\nprint(\"test AUC\", round(roc_auc_score(test[target].values, pred_ans), 4))\nprint(\"test Roc accuracy \", round(roc_auc_score(test[target].values,ypred), 4))\nprint(\"test f1 score\", round(f1_score(test[target].values,ypred), 4))\nprint(\"test precision score\", round(precision_score(test[target].values,ypred), 4))\nprint(\"test recall score\", round(recall_score(test[target].values,ypred), 4))\nprint(\"test accuracy score\", round(accuracy_score(test[target].values,ypred), 4))","metadata":{"execution":{"iopub.status.busy":"2023-04-03T07:52:33.637344Z","iopub.execute_input":"2023-04-03T07:52:33.638353Z","iopub.status.idle":"2023-04-03T07:52:34.102424Z","shell.execute_reply.started":"2023-04-03T07:52:33.638310Z","shell.execute_reply":"2023-04-03T07:52:34.101296Z"},"trusted":true},"execution_count":null,"outputs":[]}]}