{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.11.11","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":4120,"databundleVersionId":44256,"sourceType":"competition"},{"sourceId":105113547,"sourceType":"kernelVersion"}],"dockerImageVersionId":31040,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"\nimport numpy as np\nimport pandas as pd \n\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import os\nprint(os.listdir(\"/kaggle/input\"))\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-24T19:27:58.637395Z","iopub.execute_input":"2025-06-24T19:27:58.639006Z","iopub.status.idle":"2025-06-24T19:27:58.644222Z","shell.execute_reply.started":"2025-06-24T19:27:58.638970Z","shell.execute_reply":"2025-06-24T19:27:58.643291Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import os\n\n\nprint(\"Files inside avazu-ctr-prediction:\")\nprint(os.listdir(\"/kaggle/input/avazu-ctr-prediction\"))\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-24T19:31:42.917419Z","iopub.execute_input":"2025-06-24T19:31:42.918006Z","iopub.status.idle":"2025-06-24T19:31:42.929000Z","shell.execute_reply.started":"2025-06-24T19:31:42.917980Z","shell.execute_reply":"2025-06-24T19:31:42.927963Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import pandas as pd\n\n\ndf = pd.read_csv(\"/kaggle/input/avazu-ctr-prediction/train.gz\", nrows=100000)\n\n\ndf.head()\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-24T19:32:41.417214Z","iopub.execute_input":"2025-06-24T19:32:41.418303Z","iopub.status.idle":"2025-06-24T19:32:42.005794Z","shell.execute_reply.started":"2025-06-24T19:32:41.418156Z","shell.execute_reply":"2025-06-24T19:32:42.004852Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.preprocessing import LabelEncoder\n\n\ny = df[\"click\"]\nX = df.drop(columns=[\"id\", \"click\"])\n\n\nfor col in X.columns:\n    le = LabelEncoder()\n    X[col] = le.fit_transform(X[col].astype(str))\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-24T19:33:29.257986Z","iopub.execute_input":"2025-06-24T19:33:29.258708Z","iopub.status.idle":"2025-06-24T19:33:30.172315Z","shell.execute_reply.started":"2025-06-24T19:33:29.258681Z","shell.execute_reply":"2025-06-24T19:33:30.171388Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.model_selection import train_test_split\n\n\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-24T19:33:46.117343Z","iopub.execute_input":"2025-06-24T19:33:46.118288Z","iopub.status.idle":"2025-06-24T19:33:46.268385Z","shell.execute_reply.started":"2025-06-24T19:33:46.118251Z","shell.execute_reply":"2025-06-24T19:33:46.267277Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import lightgbm as lgb\n\n\nmodel = lgb.LGBMClassifier(n_estimators=100, learning_rate=0.1, random_state=42)\n\n\nmodel.fit(X_train, y_train)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-24T19:33:59.157070Z","iopub.execute_input":"2025-06-24T19:33:59.157470Z","iopub.status.idle":"2025-06-24T19:34:05.793984Z","shell.execute_reply.started":"2025-06-24T19:33:59.157438Z","shell.execute_reply":"2025-06-24T19:34:05.793110Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.metrics import roc_auc_score, log_loss\n\n\ny_pred = model.predict_proba(X_test)[:, 1]\n\n\nauc = roc_auc_score(y_test, y_pred)\nloss = log_loss(y_test, y_pred)\n\nprint(f\"AUC Score: {auc:.4f}\")\nprint(f\"Log Loss: {loss:.4f}\")\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-24T19:34:16.162469Z","iopub.execute_input":"2025-06-24T19:34:16.163073Z","iopub.status.idle":"2025-06-24T19:34:16.265066Z","shell.execute_reply.started":"2025-06-24T19:34:16.163048Z","shell.execute_reply":"2025-06-24T19:34:16.264131Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nlgb.plot_importance(model, max_num_features=10)\nplt.title(\"Top 10 Feature Importances\")\nplt.show()\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-24T19:34:30.778135Z","iopub.execute_input":"2025-06-24T19:34:30.778445Z","iopub.status.idle":"2025-06-24T19:34:31.080611Z","shell.execute_reply.started":"2025-06-24T19:34:30.778421Z","shell.execute_reply":"2025-06-24T19:34:31.079599Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}