{"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-01-08T17:56:46.358849Z","iopub.execute_input":"2023-01-08T17:56:46.359325Z","iopub.status.idle":"2023-01-08T17:56:46.383191Z","shell.execute_reply.started":"2023-01-08T17:56:46.359220Z","shell.execute_reply":"2023-01-08T17:56:46.381955Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Load Data","metadata":{}},{"cell_type":"code","source":"import numpy as np \nimport pandas as pd \nimport matplotlib.pyplot as plt\nimport seaborn as sns \nimport os\nimport optuna\nimport gc\nimport copy\nfrom sklearn.preprocessing import StandardScaler\nfrom sklearn.feature_extraction.text import CountVectorizer\nfrom sklearn.compose import ColumnTransformer\nfrom sklearn.pipeline import Pipeline,make_pipeline\nfrom sklearn.linear_model import LogisticRegression\nfrom sklearn.model_selection import KFold\nfrom sklearn.model_selection import cross_val_score\nfrom sklearn import svm\nfrom sklearn.metrics import mean_absolute_error\nfrom sklearn.metrics import roc_auc_score, accuracy_score\nfrom sklearn.model_selection import StratifiedKFold\nfrom sklearn.model_selection import train_test_split\nfrom lightgbm import LGBMClassifier\n","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:56:46.388584Z","iopub.execute_input":"2023-01-08T17:56:46.389503Z","iopub.status.idle":"2023-01-08T17:56:48.495998Z","shell.execute_reply.started":"2023-01-08T17:56:46.389466Z","shell.execute_reply":"2023-01-08T17:56:48.494898Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ls","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:56:48.498609Z","iopub.execute_input":"2023-01-08T17:56:48.499315Z","iopub.status.idle":"2023-01-08T17:56:49.677676Z","shell.execute_reply.started":"2023-01-08T17:56:48.499281Z","shell.execute_reply":"2023-01-08T17:56:49.676264Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# read data\n","metadata":{}},{"cell_type":"code","source":"tr = pd.read_csv(\"/kaggle/input/emsi-5iir-ds/train.csv\")\nte = pd.read_csv(\"/kaggle/input/emsi-5iir-ds/test.csv\")\nsubmit = pd.read_csv('/kaggle/input/emsi-5iir-ds/sample_submission.csv')","metadata":{"execution":{"iopub.status.busy":"2023-01-08T18:02:00.883823Z","iopub.execute_input":"2023-01-08T18:02:00.884985Z","iopub.status.idle":"2023-01-08T18:02:08.848201Z","shell.execute_reply.started":"2023-01-08T18:02:00.884942Z","shell.execute_reply":"2023-01-08T18:02:08.846995Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train=tr.drop([\"id\",\"target\"],axis=1)\ny_train=tr[\"target\"]\nX_train.head()","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:57:05.737838Z","iopub.execute_input":"2023-01-08T17:57:05.738186Z","iopub.status.idle":"2023-01-08T17:57:05.833060Z","shell.execute_reply.started":"2023-01-08T17:57:05.738155Z","shell.execute_reply":"2023-01-08T17:57:05.832054Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"preprocessor = ColumnTransformer(transformers=[\n(\"scaler\",StandardScaler(),[col for col in X_train.columns if col != \"f_27\"]),\n    (\"countvectorizer\",CountVectorizer(analyzer=\"char\"),\"f_27\")\n])","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:57:05.835991Z","iopub.execute_input":"2023-01-08T17:57:05.836289Z","iopub.status.idle":"2023-01-08T17:57:05.841523Z","shell.execute_reply.started":"2023-01-08T17:57:05.836263Z","shell.execute_reply":"2023-01-08T17:57:05.840507Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"preprocessor.fit_transform(X_train)","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:57:05.842711Z","iopub.execute_input":"2023-01-08T17:57:05.843484Z","iopub.status.idle":"2023-01-08T17:57:13.017509Z","shell.execute_reply.started":"2023-01-08T17:57:05.843453Z","shell.execute_reply":"2023-01-08T17:57:13.016448Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"open(\"/kaggle/input/emsi-5iir-ds/train.csv\").readlines()[0]","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:57:13.019136Z","iopub.execute_input":"2023-01-08T17:57:13.019952Z","iopub.status.idle":"2023-01-08T17:57:13.660016Z","shell.execute_reply.started":"2023-01-08T17:57:13.019908Z","shell.execute_reply":"2023-01-08T17:57:13.659251Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Visualizing Data","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(10, 6))\nplt.title('Target distribution')\nax = sns.countplot(x=tr['target'], data=tr)\nax.set_facecolor('white')","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:57:13.661207Z","iopub.execute_input":"2023-01-08T17:57:13.661985Z","iopub.status.idle":"2023-01-08T17:57:14.238524Z","shell.execute_reply.started":"2023-01-08T17:57:13.661954Z","shell.execute_reply":"2023-01-08T17:57:14.237678Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"preprocessor = ColumnTransformer(transformers=[\n(\"scaler\",StandardScaler(),[col for col in X_train.columns if col != \"f_27\"]),\n    (\"countvectorizer\",CountVectorizer(analyzer=\"char\"),\"f_27\")\n])","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:57:14.239747Z","iopub.execute_input":"2023-01-08T17:57:14.240213Z","iopub.status.idle":"2023-01-08T17:57:14.244455Z","shell.execute_reply.started":"2023-01-08T17:57:14.240183Z","shell.execute_reply":"2023-01-08T17:57:14.243724Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.read_csv(\"/kaggle/input/emsi-5iir-ds/train.csv\")","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:57:14.245634Z","iopub.execute_input":"2023-01-08T17:57:14.245984Z","iopub.status.idle":"2023-01-08T17:57:18.984832Z","shell.execute_reply.started":"2023-01-08T17:57:14.245954Z","shell.execute_reply":"2023-01-08T17:57:18.983850Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.read_csv(\"/kaggle/input/emsi-5iir-ds/test.csv\")","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:57:18.986216Z","iopub.execute_input":"2023-01-08T17:57:18.986560Z","iopub.status.idle":"2023-01-08T17:57:22.539711Z","shell.execute_reply.started":"2023-01-08T17:57:18.986530Z","shell.execute_reply":"2023-01-08T17:57:22.538613Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tr.sample(7)","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:57:22.541215Z","iopub.execute_input":"2023-01-08T17:57:22.541573Z","iopub.status.idle":"2023-01-08T17:57:22.594855Z","shell.execute_reply.started":"2023-01-08T17:57:22.541526Z","shell.execute_reply":"2023-01-08T17:57:22.593693Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"te.sample(7)","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:57:22.596144Z","iopub.execute_input":"2023-01-08T17:57:22.596445Z","iopub.status.idle":"2023-01-08T17:57:22.645837Z","shell.execute_reply.started":"2023-01-08T17:57:22.596418Z","shell.execute_reply":"2023-01-08T17:57:22.644759Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"te.columns","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:57:22.651736Z","iopub.execute_input":"2023-01-08T17:57:22.652075Z","iopub.status.idle":"2023-01-08T17:57:22.659931Z","shell.execute_reply.started":"2023-01-08T17:57:22.652047Z","shell.execute_reply":"2023-01-08T17:57:22.658573Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tr.columns","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:57:22.661802Z","iopub.execute_input":"2023-01-08T17:57:22.662222Z","iopub.status.idle":"2023-01-08T17:57:22.671558Z","shell.execute_reply.started":"2023-01-08T17:57:22.662179Z","shell.execute_reply":"2023-01-08T17:57:22.670484Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(te)","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:57:22.673419Z","iopub.execute_input":"2023-01-08T17:57:22.673885Z","iopub.status.idle":"2023-01-08T17:57:22.684319Z","shell.execute_reply.started":"2023-01-08T17:57:22.673840Z","shell.execute_reply":"2023-01-08T17:57:22.683135Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(tr)","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:57:22.685268Z","iopub.execute_input":"2023-01-08T17:57:22.685583Z","iopub.status.idle":"2023-01-08T17:57:22.692672Z","shell.execute_reply.started":"2023-01-08T17:57:22.685542Z","shell.execute_reply":"2023-01-08T17:57:22.691430Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"te.f_00.plot.hist()","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:57:22.694365Z","iopub.execute_input":"2023-01-08T17:57:22.694808Z","iopub.status.idle":"2023-01-08T17:57:23.035467Z","shell.execute_reply.started":"2023-01-08T17:57:22.694777Z","shell.execute_reply":"2023-01-08T17:57:23.034365Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tr.f_22.plot.hist()","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:57:23.036993Z","iopub.execute_input":"2023-01-08T17:57:23.037323Z","iopub.status.idle":"2023-01-08T17:57:23.393207Z","shell.execute_reply.started":"2023-01-08T17:57:23.037296Z","shell.execute_reply":"2023-01-08T17:57:23.392251Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"te.f_00.plot.hist(bins=100)","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:57:23.394709Z","iopub.execute_input":"2023-01-08T17:57:23.395004Z","iopub.status.idle":"2023-01-08T17:57:24.038807Z","shell.execute_reply.started":"2023-01-08T17:57:23.394977Z","shell.execute_reply":"2023-01-08T17:57:24.037738Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tr.f_22.plot.hist(bins=200)","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:57:24.040154Z","iopub.execute_input":"2023-01-08T17:57:24.040893Z","iopub.status.idle":"2023-01-08T17:57:24.733824Z","shell.execute_reply.started":"2023-01-08T17:57:24.040846Z","shell.execute_reply":"2023-01-08T17:57:24.733037Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tr['target'].value_counts().plot(kind='bar')","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:57:24.734868Z","iopub.execute_input":"2023-01-08T17:57:24.735657Z","iopub.status.idle":"2023-01-08T17:57:24.919988Z","shell.execute_reply.started":"2023-01-08T17:57:24.735622Z","shell.execute_reply":"2023-01-08T17:57:24.918933Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tr.hist(column=[\n    'f_07', 'f_08', \n    'f_09', 'f_10', \n    'f_11', 'f_12', \n    'f_13', 'f_14', \n    'f_15', 'f_16', \n    'f_17', 'f_18', \n    'f_29', 'f_30'\n], figsize=(20,15), bins=25);","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:57:24.921343Z","iopub.execute_input":"2023-01-08T17:57:24.921895Z","iopub.status.idle":"2023-01-08T17:57:27.926575Z","shell.execute_reply.started":"2023-01-08T17:57:24.921865Z","shell.execute_reply":"2023-01-08T17:57:27.925504Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"te.hist(column=[\n    'f_07', 'f_08', \n    'f_09', 'f_10'\n], figsize=(20,15), bins=30);","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:57:27.928100Z","iopub.execute_input":"2023-01-08T17:57:27.928743Z","iopub.status.idle":"2023-01-08T17:57:28.906805Z","shell.execute_reply.started":"2023-01-08T17:57:27.928678Z","shell.execute_reply":"2023-01-08T17:57:28.905555Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"te.corr()","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:57:28.908545Z","iopub.execute_input":"2023-01-08T17:57:28.908991Z","iopub.status.idle":"2023-01-08T17:57:30.878570Z","shell.execute_reply.started":"2023-01-08T17:57:28.908949Z","shell.execute_reply":"2023-01-08T17:57:30.877428Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tr.corr()","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:57:30.880338Z","iopub.execute_input":"2023-01-08T17:57:30.880654Z","iopub.status.idle":"2023-01-08T17:57:33.558482Z","shell.execute_reply.started":"2023-01-08T17:57:30.880626Z","shell.execute_reply":"2023-01-08T17:57:33.557748Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.heatmap(te.corr())","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:57:33.559955Z","iopub.execute_input":"2023-01-08T17:57:33.560535Z","iopub.status.idle":"2023-01-08T17:57:35.896760Z","shell.execute_reply.started":"2023-01-08T17:57:33.560505Z","shell.execute_reply":"2023-01-08T17:57:35.895717Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.heatmap(tr.corr())","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:57:35.898243Z","iopub.execute_input":"2023-01-08T17:57:35.898562Z","iopub.status.idle":"2023-01-08T17:57:38.972887Z","shell.execute_reply.started":"2023-01-08T17:57:35.898533Z","shell.execute_reply":"2023-01-08T17:57:38.971849Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tabcorr = tr.corr() \nplt.figure(figsize=(15,15))\nsns.heatmap(abs(tabcorr), cmap=\"coolwarm\")","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:57:38.974289Z","iopub.execute_input":"2023-01-08T17:57:38.974619Z","iopub.status.idle":"2023-01-08T17:57:42.407310Z","shell.execute_reply.started":"2023-01-08T17:57:38.974588Z","shell.execute_reply":"2023-01-08T17:57:42.406170Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"te.plot.scatter(x='f_01' , y='f_15')","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:57:42.408522Z","iopub.execute_input":"2023-01-08T17:57:42.409484Z","iopub.status.idle":"2023-01-08T17:57:45.013063Z","shell.execute_reply.started":"2023-01-08T17:57:42.409441Z","shell.execute_reply":"2023-01-08T17:57:45.012301Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tr.plot.scatter(x='f_02', y='f_11')","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:57:45.014358Z","iopub.execute_input":"2023-01-08T17:57:45.015232Z","iopub.status.idle":"2023-01-08T17:57:48.258635Z","shell.execute_reply.started":"2023-01-08T17:57:45.015198Z","shell.execute_reply":"2023-01-08T17:57:48.257516Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.violinplot(x='f_30',y='f_05',data=te)","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:57:48.260273Z","iopub.execute_input":"2023-01-08T17:57:48.261125Z","iopub.status.idle":"2023-01-08T17:57:50.281871Z","shell.execute_reply.started":"2023-01-08T17:57:48.261090Z","shell.execute_reply":"2023-01-08T17:57:50.280801Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.violinplot(x='f_15',y='f_01',data=te)","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:57:50.283623Z","iopub.execute_input":"2023-01-08T17:57:50.283958Z","iopub.status.idle":"2023-01-08T17:57:52.808014Z","shell.execute_reply.started":"2023-01-08T17:57:50.283929Z","shell.execute_reply":"2023-01-08T17:57:52.806985Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"te.describe()","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:57:52.809671Z","iopub.execute_input":"2023-01-08T17:57:52.809998Z","iopub.status.idle":"2023-01-08T17:57:53.697487Z","shell.execute_reply.started":"2023-01-08T17:57:52.809970Z","shell.execute_reply":"2023-01-08T17:57:53.696703Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tr.info()","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:57:53.698659Z","iopub.execute_input":"2023-01-08T17:57:53.699142Z","iopub.status.idle":"2023-01-08T17:57:53.804261Z","shell.execute_reply.started":"2023-01-08T17:57:53.699112Z","shell.execute_reply":"2023-01-08T17:57:53.803151Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# **Modeling****","metadata":{}},{"cell_type":"code","source":"y = tr[\"target\"]\nX = tr.drop(columns=[\"id\",\"f_27\", \"target\"])\n\nte = te.drop(columns=[\"id\",\"f_27\"])\n\nX.shape, te.shape","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:57:53.805583Z","iopub.execute_input":"2023-01-08T17:57:53.805939Z","iopub.status.idle":"2023-01-08T17:57:53.944150Z","shell.execute_reply.started":"2023-01-08T17:57:53.805908Z","shell.execute_reply":"2023-01-08T17:57:53.943028Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"code","source":"!pip install mljar-supervised","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:57:53.945339Z","iopub.execute_input":"2023-01-08T17:57:53.946359Z","iopub.status.idle":"2023-01-08T17:58:12.167350Z","shell.execute_reply.started":"2023-01-08T17:57:53.946324Z","shell.execute_reply":"2023-01-08T17:58:12.166202Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from supervised.automl import AutoML ","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:58:12.169928Z","iopub.execute_input":"2023-01-08T17:58:12.170394Z","iopub.status.idle":"2023-01-08T17:58:16.456222Z","shell.execute_reply.started":"2023-01-08T17:58:12.170349Z","shell.execute_reply":"2023-01-08T17:58:16.454529Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_train = tr[\"target\"]\nX_train = tr.drop([\"target\"], axis=1)","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:58:16.458519Z","iopub.execute_input":"2023-01-08T17:58:16.459794Z","iopub.status.idle":"2023-01-08T17:58:16.579881Z","shell.execute_reply.started":"2023-01-08T17:58:16.459753Z","shell.execute_reply":"2023-01-08T17:58:16.578954Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"te.head()","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:58:16.581365Z","iopub.execute_input":"2023-01-08T17:58:16.581710Z","iopub.status.idle":"2023-01-08T17:58:16.608897Z","shell.execute_reply.started":"2023-01-08T17:58:16.581660Z","shell.execute_reply":"2023-01-08T17:58:16.607766Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"kf = StratifiedKFold(n_splits=14, shuffle=True, random_state = 0)\ny_predict = []\n\nfor fold, (train_index, val_index) in enumerate(kf.split(X, y)):\n        print('*'*14, f\" Fold {fold} \", '*'*14, '\\n')\n        \n        # Split Data\n        X_train = X.loc[train_index]\n        X_val = X.loc[val_index]\n\n        y_train = y.loc[train_index]\n        y_val = y.loc[val_index]\n        \n        # Create Model here\n        model = LGBMClassifier()\n        \n        # Fit Model\n        model.fit(X_train,y_train)\n\n        # Make X_val prediction\n        y_pred = model.predict_proba(X_val)[:,1]\n        \n        ","metadata":{"execution":{"iopub.status.busy":"2023-01-08T17:58:16.617582Z","iopub.execute_input":"2023-01-08T17:58:16.617945Z","iopub.status.idle":"2023-01-08T18:01:12.045193Z","shell.execute_reply.started":"2023-01-08T17:58:16.617914Z","shell.execute_reply":"2023-01-08T18:01:12.044187Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y = tr[\"target\"]\nX = tr.drop(columns=[\"id\",\"f_27, \"target\"])\n\nte = te.drop(columns=[\"id\",\"f_27\"])\n\nX.shape, te.shape","metadata":{"execution":{"iopub.status.busy":"2023-01-08T18:02:24.034368Z","iopub.execute_input":"2023-01-08T18:02:24.034918Z","iopub.status.idle":"2023-01-08T18:02:24.042999Z","shell.execute_reply.started":"2023-01-08T18:02:24.034870Z","shell.execute_reply":"2023-01-08T18:02:24.041406Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train, X_test, y_train, y_test= train_test_split(X, y, test_size=0.33, random_state=42)","metadata":{"execution":{"iopub.status.busy":"2023-01-08T18:01:12.386286Z","iopub.status.idle":"2023-01-08T18:01:12.386707Z","shell.execute_reply.started":"2023-01-08T18:01:12.386500Z","shell.execute_reply":"2023-01-08T18:01:12.386518Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"optuna.logging.set_verbosity(optuna.logging.WARNING)\n\ndef objectivesLGBM(trial):\n    model = LGBMClassifier()\n    model.fit(X,y)\n\n    return model.score(X,y)","metadata":{"execution":{"iopub.status.busy":"2023-01-08T18:01:12.387702Z","iopub.status.idle":"2023-01-08T18:01:12.388093Z","shell.execute_reply.started":"2023-01-08T18:01:12.387912Z","shell.execute_reply":"2023-01-08T18:01:12.387929Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model = LGBMClassifier()\nmodel.fit(X, y)\n\nprint(\"Training score :\", model.score(X, y))\n\npred_y_test = model.predict(X_test)\nprint(\"Roc auc score  :\", roc_auc_score(y_test, pred_y_test))","metadata":{"execution":{"iopub.status.busy":"2023-01-08T18:01:12.389500Z","iopub.status.idle":"2023-01-08T18:01:12.390191Z","shell.execute_reply.started":"2023-01-08T18:01:12.389983Z","shell.execute_reply":"2023-01-08T18:01:12.390005Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"del model, X, y, te, X_train, y_train\ngc.collect()","metadata":{"execution":{"iopub.status.busy":"2023-01-08T18:01:12.391803Z","iopub.status.idle":"2023-01-08T18:01:12.392763Z","shell.execute_reply.started":"2023-01-08T18:01:12.392521Z","shell.execute_reply":"2023-01-08T18:01:12.392542Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"np.array(y_predict).mean(axis=0)","metadata":{"execution":{"iopub.status.busy":"2023-01-08T18:01:12.393715Z","iopub.status.idle":"2023-01-08T18:01:12.394671Z","shell.execute_reply.started":"2023-01-08T18:01:12.394345Z","shell.execute_reply":"2023-01-08T18:01:12.394376Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Submission","metadata":{}},{"cell_type":"code","source":"submission = pd.read_csv(\"/kaggle/input/emsi-5iir-ds/sample_submission.csv\")\nsubmission.shape","metadata":{"execution":{"iopub.status.busy":"2023-01-08T18:01:12.396063Z","iopub.status.idle":"2023-01-08T18:01:12.396593Z","shell.execute_reply.started":"2023-01-08T18:01:12.396312Z","shell.execute_reply":"2023-01-08T18:01:12.396338Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission['target'] = np.array(y_predict).mean(axis=0)\nsubmission.to_csv('submission.csv', index=False)\nsubmission\n","metadata":{"execution":{"iopub.status.busy":"2023-01-08T18:01:12.398350Z","iopub.status.idle":"2023-01-08T18:01:12.399150Z","shell.execute_reply.started":"2023-01-08T18:01:12.398849Z","shell.execute_reply":"2023-01-08T18:01:12.398878Z"},"trusted":true},"execution_count":null,"outputs":[]}]}