{"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":"import numpy as np\nimport pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nimport warnings\nimport numpy as np\nimport random\nfrom scipy.stats import zscore\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.preprocessing import LabelEncoder\nfrom sklearn.metrics import mean_squared_error\n\nfrom xgboost import XGBRegressor\nfrom sklearn.ensemble import AdaBoostRegressor\nfrom catboost import CatBoostRegressor\nfrom lightgbm import LGBMRegressor\nwarnings.filterwarnings(\"ignore\")\nfrom pandas_profiling import ProfileReport\nplt.ion()","metadata":{"papermill":{"duration":3.310158,"end_time":"2021-08-26T22:05:16.531383","exception":false,"start_time":"2021-08-26T22:05:13.221225","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T03:47:46.189381Z","iopub.execute_input":"2021-10-26T03:47:46.190022Z","iopub.status.idle":"2021-10-26T03:47:50.261543Z","shell.execute_reply.started":"2021-10-26T03:47:46.189922Z","shell.execute_reply":"2021-10-26T03:47:50.260395Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def set_seed(seed=42):\n    random.seed(seed)\n    np.random.seed(seed)","metadata":{"papermill":{"duration":0.065508,"end_time":"2021-08-26T22:05:16.656354","exception":false,"start_time":"2021-08-26T22:05:16.590846","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T03:47:50.263396Z","iopub.execute_input":"2021-10-26T03:47:50.263622Z","iopub.status.idle":"2021-10-26T03:47:50.26981Z","shell.execute_reply.started":"2021-10-26T03:47:50.263594Z","shell.execute_reply":"2021-10-26T03:47:50.269145Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"set_seed()","metadata":{"papermill":{"duration":0.068442,"end_time":"2021-08-26T22:05:16.784292","exception":false,"start_time":"2021-08-26T22:05:16.71585","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T03:47:50.270759Z","iopub.execute_input":"2021-10-26T03:47:50.271675Z","iopub.status.idle":"2021-10-26T03:47:50.281085Z","shell.execute_reply.started":"2021-10-26T03:47:50.271625Z","shell.execute_reply":"2021-10-26T03:47:50.280187Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df=pd.read_csv(\"../input/beyond-analysis/train.csv\")\ndf","metadata":{"papermill":{"duration":7.005038,"end_time":"2021-08-26T22:05:23.849326","exception":false,"start_time":"2021-08-26T22:05:16.844288","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T03:47:50.283648Z","iopub.execute_input":"2021-10-26T03:47:50.284365Z","iopub.status.idle":"2021-10-26T03:47:56.907493Z","shell.execute_reply.started":"2021-10-26T03:47:50.284314Z","shell.execute_reply":"2021-10-26T03:47:56.90667Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.describe()","metadata":{"papermill":{"duration":1.049389,"end_time":"2021-08-26T22:05:24.959672","exception":false,"start_time":"2021-08-26T22:05:23.910283","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T03:47:56.908847Z","iopub.execute_input":"2021-10-26T03:47:56.909725Z","iopub.status.idle":"2021-10-26T03:47:57.814191Z","shell.execute_reply.started":"2021-10-26T03:47:56.909676Z","shell.execute_reply":"2021-10-26T03:47:57.813363Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.info()","metadata":{"papermill":{"duration":0.399709,"end_time":"2021-08-26T22:05:25.421249","exception":false,"start_time":"2021-08-26T22:05:25.02154","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T03:47:57.815555Z","iopub.execute_input":"2021-10-26T03:47:57.816419Z","iopub.status.idle":"2021-10-26T03:47:58.172205Z","shell.execute_reply.started":"2021-10-26T03:47:57.816368Z","shell.execute_reply":"2021-10-26T03:47:58.171334Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.distplot(x=df[\"Y1\"])","metadata":{"papermill":{"duration":5.158473,"end_time":"2021-08-26T22:05:30.642246","exception":false,"start_time":"2021-08-26T22:05:25.483773","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T03:47:58.173522Z","iopub.execute_input":"2021-10-26T03:47:58.174176Z","iopub.status.idle":"2021-10-26T03:48:03.184804Z","shell.execute_reply.started":"2021-10-26T03:47:58.174131Z","shell.execute_reply":"2021-10-26T03:48:03.18383Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"profile = ProfileReport(df, title=\"Pandas Profiling Report\")\nprofile","metadata":{"execution":{"iopub.status.busy":"2021-10-26T03:48:03.185943Z","iopub.execute_input":"2021-10-26T03:48:03.186175Z","iopub.status.idle":"2021-10-26T03:54:48.470162Z","shell.execute_reply.started":"2021-10-26T03:48:03.186148Z","shell.execute_reply":"2021-10-26T03:54:48.469242Z"},"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.distplot(x=df[\"Y2\"])","metadata":{"papermill":{"duration":6.519921,"end_time":"2021-08-26T22:05:37.226468","exception":false,"start_time":"2021-08-26T22:05:30.706547","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T03:54:48.471526Z","iopub.execute_input":"2021-10-26T03:54:48.471791Z","iopub.status.idle":"2021-10-26T03:54:54.990645Z","shell.execute_reply.started":"2021-10-26T03:54:48.471743Z","shell.execute_reply":"2021-10-26T03:54:54.989807Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(x=\"STATUS_CHECK\", data=df)\nplt.show()","metadata":{"papermill":{"duration":0.358371,"end_time":"2021-08-26T22:05:37.649267","exception":false,"start_time":"2021-08-26T22:05:37.290896","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T03:54:54.992212Z","iopub.execute_input":"2021-10-26T03:54:54.992463Z","iopub.status.idle":"2021-10-26T03:54:55.240206Z","shell.execute_reply.started":"2021-10-26T03:54:54.992432Z","shell.execute_reply":"2021-10-26T03:54:55.239145Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(x=\"CATEGORY_1\", data=df)\nplt.show()","metadata":{"papermill":{"duration":1.695181,"end_time":"2021-08-26T22:05:39.408243","exception":false,"start_time":"2021-08-26T22:05:37.713062","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T03:54:55.243279Z","iopub.execute_input":"2021-10-26T03:54:55.243544Z","iopub.status.idle":"2021-10-26T03:54:56.885326Z","shell.execute_reply.started":"2021-10-26T03:54:55.243511Z","shell.execute_reply":"2021-10-26T03:54:56.884447Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(x=\"CATEGORY_2\", data=df)\nplt.show()","metadata":{"papermill":{"duration":1.640599,"end_time":"2021-08-26T22:05:41.116391","exception":false,"start_time":"2021-08-26T22:05:39.475792","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T03:54:56.886993Z","iopub.execute_input":"2021-10-26T03:54:56.887352Z","iopub.status.idle":"2021-10-26T03:54:58.529783Z","shell.execute_reply.started":"2021-10-26T03:54:56.887315Z","shell.execute_reply":"2021-10-26T03:54:58.528555Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(x=\"ACTIVE_YN\", data=df)\nplt.show()","metadata":{"papermill":{"duration":0.274965,"end_time":"2021-08-26T22:05:41.458873","exception":false,"start_time":"2021-08-26T22:05:41.183908","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T03:54:58.531163Z","iopub.execute_input":"2021-10-26T03:54:58.531422Z","iopub.status.idle":"2021-10-26T03:54:58.77509Z","shell.execute_reply.started":"2021-10-26T03:54:58.531389Z","shell.execute_reply":"2021-10-26T03:54:58.774092Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df[\"DEPOSIT_TRAILS\"].nunique()","metadata":{"papermill":{"duration":0.093051,"end_time":"2021-08-26T22:05:41.617746","exception":false,"start_time":"2021-08-26T22:05:41.524695","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T03:54:58.77648Z","iopub.execute_input":"2021-10-26T03:54:58.7769Z","iopub.status.idle":"2021-10-26T03:54:58.793162Z","shell.execute_reply.started":"2021-10-26T03:54:58.776859Z","shell.execute_reply":"2021-10-26T03:54:58.792401Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.rcParams['figure.figsize'] = [14,7]\nfig,ax=plt.subplots(1,2)\nax[0].set_title(\"DEPOSIT_TRAILS\")\nsns.distplot(x=df[\"DEPOSIT_TRAILS\"],ax=ax[0])\nax[1].set_title(\"DEPOSIT_TRAILS Transformed\")\nsns.distplot(x=np.log(1+np.power(df[\"DEPOSIT_TRAILS\"],0.25)), ax=ax[1])\nplt.show()","metadata":{"papermill":{"duration":10.508762,"end_time":"2021-08-26T22:05:52.194233","exception":false,"start_time":"2021-08-26T22:05:41.685471","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T03:54:58.794404Z","iopub.execute_input":"2021-10-26T03:54:58.794746Z","iopub.status.idle":"2021-10-26T03:55:09.486585Z","shell.execute_reply.started":"2021-10-26T03:54:58.794716Z","shell.execute_reply":"2021-10-26T03:55:09.485471Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.rcParams['figure.figsize'] = [14,7]\nfig,ax=plt.subplots(1,2)\nax[0].set_title(\"REVENUE\")\nsns.distplot(x=df[\"REVENUE\"],ax=ax[0])\nax[1].set_title(\"REVENUE Transformed\")\nsns.distplot(x=np.log(1+np.power(df[\"REVENUE\"],0.25)), ax=ax[1])\nplt.show()","metadata":{"papermill":{"duration":11.307118,"end_time":"2021-08-26T22:06:03.568857","exception":false,"start_time":"2021-08-26T22:05:52.261739","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T03:55:09.488243Z","iopub.execute_input":"2021-10-26T03:55:09.488575Z","iopub.status.idle":"2021-10-26T03:55:20.863348Z","shell.execute_reply.started":"2021-10-26T03:55:09.488535Z","shell.execute_reply":"2021-10-26T03:55:20.862354Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.rcParams['figure.figsize'] = [14,7]\nfig,ax=plt.subplots(1,2)\nax[0].set_title(\"WINNINGS_1\")\nsns.distplot(x=df[\"WINNINGS_1\"],ax=ax[0])\nax[1].set_title(\"WINNINGS_1 Transformed\")\nsns.distplot(x=np.log(1+np.power(df[\"WINNINGS_1\"],0.25)), ax=ax[1])\nplt.show()","metadata":{"papermill":{"duration":11.141876,"end_time":"2021-08-26T22:06:14.777477","exception":false,"start_time":"2021-08-26T22:06:03.635601","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T03:55:20.865037Z","iopub.execute_input":"2021-10-26T03:55:20.865382Z","iopub.status.idle":"2021-10-26T03:55:32.094437Z","shell.execute_reply.started":"2021-10-26T03:55:20.865335Z","shell.execute_reply":"2021-10-26T03:55:32.093325Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.rcParams['figure.figsize'] = [14,7]\nfig,ax=plt.subplots(1,2)\nax[0].set_title(\"WINNINGS_2\")\nsns.distplot(x=df[\"WINNINGS_2\"],ax=ax[0])\nax[1].set_title(\"WINNINGS_2 Transformed\")\nsns.distplot(x=np.log(1+np.power(df[\"WINNINGS_2\"],0.25)), ax=ax[1])\nplt.show()","metadata":{"papermill":{"duration":10.270582,"end_time":"2021-08-26T22:06:25.117248","exception":false,"start_time":"2021-08-26T22:06:14.846666","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T03:55:32.096206Z","iopub.execute_input":"2021-10-26T03:55:32.09663Z","iopub.status.idle":"2021-10-26T03:55:42.680397Z","shell.execute_reply.started":"2021-10-26T03:55:32.096585Z","shell.execute_reply":"2021-10-26T03:55:42.679307Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.rcParams['figure.figsize'] = [14,7]\nfig,ax=plt.subplots(1,2)\nax[0].set_title(\"DISCOUNT\")\nsns.distplot(x=df[\"DISCOUNT\"],ax=ax[0])\nax[1].set_title(\"DISCOUNT Transformed\")\nsns.distplot(x=np.log(1+np.power(df[\"DISCOUNT\"],0.1)), ax=ax[1])\nplt.show()","metadata":{"papermill":{"duration":11.29257,"end_time":"2021-08-26T22:06:36.480091","exception":false,"start_time":"2021-08-26T22:06:25.187521","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T03:55:42.682261Z","iopub.execute_input":"2021-10-26T03:55:42.682804Z","iopub.status.idle":"2021-10-26T03:55:56.100821Z","shell.execute_reply.started":"2021-10-26T03:55:42.682734Z","shell.execute_reply":"2021-10-26T03:55:56.100004Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.rcParams['figure.figsize'] = [14,7]\nfig,ax=plt.subplots(1,2)\nax[0].set_title(\"DEPOSIT\")\nsns.distplot(x=df[\"DEPOSIT\"],ax=ax[0])\nax[1].set_title(\"DEPOSIT Transformed\")\nsns.distplot(x=np.log(1+np.power(df[\"DEPOSIT\"],0.25)), ax=ax[1])\nplt.show()","metadata":{"papermill":{"duration":11.229365,"end_time":"2021-08-26T22:06:47.783025","exception":false,"start_time":"2021-08-26T22:06:36.55366","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T03:55:56.102238Z","iopub.execute_input":"2021-10-26T03:55:56.102666Z","iopub.status.idle":"2021-10-26T03:56:07.381655Z","shell.execute_reply.started":"2021-10-26T03:55:56.102635Z","shell.execute_reply":"2021-10-26T03:56:07.380813Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.rcParams['figure.figsize'] = [14,7]\nfig,ax=plt.subplots(1,2)\nax[0].set_title(\"WITHDRAW\")\nsns.distplot(x=df[\"WITHDRAW\"],ax=ax[0])\nax[1].set_title(\"WITHDRAW Transformed\")\nsns.distplot(x=np.log(1+np.power(df[\"WITHDRAW\"],0.25)), ax=ax[1])\nplt.show()","metadata":{"papermill":{"duration":10.009032,"end_time":"2021-08-26T22:06:57.8655","exception":false,"start_time":"2021-08-26T22:06:47.856468","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T03:56:07.382868Z","iopub.execute_input":"2021-10-26T03:56:07.383108Z","iopub.status.idle":"2021-10-26T03:56:17.591623Z","shell.execute_reply.started":"2021-10-26T03:56:07.383077Z","shell.execute_reply":"2021-10-26T03:56:17.590853Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.rcParams['figure.figsize'] = [14,7]\nfig,ax=plt.subplots(1,2)\nax[0].set_title(\"ENTRY_NUMBER\")\nsns.distplot(x=df[\"ENTRY_NUMBER\"],ax=ax[0])\nax[1].set_title(\"ENTRY_NUMBER Transformed\")\nsns.distplot(x=np.log(1+np.power(df[\"ENTRY_NUMBER\"],0.25)), ax=ax[1])\nplt.show()","metadata":{"papermill":{"duration":12.108856,"end_time":"2021-08-26T22:07:10.047602","exception":false,"start_time":"2021-08-26T22:06:57.938746","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T03:56:17.593004Z","iopub.execute_input":"2021-10-26T03:56:17.593393Z","iopub.status.idle":"2021-10-26T03:56:29.592678Z","shell.execute_reply.started":"2021-10-26T03:56:17.593362Z","shell.execute_reply":"2021-10-26T03:56:29.591576Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.rcParams['figure.figsize'] = [14,7]\nfig,ax=plt.subplots(1,2)\nax[0].set_title(\"WINNINGS_NUMBER\")\nsns.distplot(x=df[\"WINNINGS_NUMBER\"],ax=ax[0])\nax[1].set_title(\"WINNINGS_NUMBER Transformed\")\nsns.distplot(x=np.log(1+np.power(df[\"WINNINGS_NUMBER\"],0.25)), ax=ax[1])\nplt.show()","metadata":{"papermill":{"duration":11.819014,"end_time":"2021-08-26T22:07:21.951402","exception":false,"start_time":"2021-08-26T22:07:10.132388","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T03:56:29.594304Z","iopub.execute_input":"2021-10-26T03:56:29.59481Z","iopub.status.idle":"2021-10-26T03:56:41.373149Z","shell.execute_reply.started":"2021-10-26T03:56:29.594733Z","shell.execute_reply":"2021-10-26T03:56:41.372109Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.rcParams['figure.figsize'] = [14,7]\nfig,ax=plt.subplots(1,2)\nax[0].set_title(\"PRACTICE_ENTRY\")\nsns.distplot(x=df[\"PRACTICE_ENTRY\"],ax=ax[0])\nax[1].set_title(\"PRACTICE_ENTRY Transformed\")\nsns.distplot(x=np.log(1+np.power(df[\"PRACTICE_ENTRY\"],0.25)), ax=ax[1])\nplt.show()","metadata":{"papermill":{"duration":10.208571,"end_time":"2021-08-26T22:07:32.237989","exception":false,"start_time":"2021-08-26T22:07:22.029418","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T03:56:41.374393Z","iopub.execute_input":"2021-10-26T03:56:41.374628Z","iopub.status.idle":"2021-10-26T03:56:51.73538Z","shell.execute_reply.started":"2021-10-26T03:56:41.374599Z","shell.execute_reply":"2021-10-26T03:56:51.734308Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.rcParams['figure.figsize'] = [14,7]\nfig,ax=plt.subplots(1,2)\nax[0].set_title(\"PRACTICE_WINNINGS\")\nsns.distplot(x=df[\"PRACTICE_WINNINGS\"],ax=ax[0])\nax[1].set_title(\"PRACTICE_WINNINGS Transformed\")\nsns.distplot(x=np.log(1+np.power(df[\"PRACTICE_WINNINGS\"],0.25)), ax=ax[1])\nplt.show()","metadata":{"papermill":{"duration":10.152408,"end_time":"2021-08-26T22:07:42.466276","exception":false,"start_time":"2021-08-26T22:07:32.313868","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T03:56:51.738018Z","iopub.execute_input":"2021-10-26T03:56:51.738543Z","iopub.status.idle":"2021-10-26T03:57:01.979641Z","shell.execute_reply.started":"2021-10-26T03:56:51.73848Z","shell.execute_reply":"2021-10-26T03:57:01.978731Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.rcParams['figure.figsize'] = [14,7]\nfig,ax=plt.subplots(1,2)\nax[0].set_title(\"PRACTICE_ENTRY_NUMBER\")\nsns.distplot(x=df[\"PRACTICE_ENTRY_NUMBER\"],ax=ax[0])\nax[1].set_title(\"PRACTICE_ENTRY_NUMBER Transformed\")\nsns.distplot(x=np.log(1+np.power(df[\"PRACTICE_ENTRY_NUMBER\"],0.25)), ax=ax[1])\nplt.show()","metadata":{"papermill":{"duration":10.309616,"end_time":"2021-08-26T22:07:52.854198","exception":false,"start_time":"2021-08-26T22:07:42.544582","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T03:57:01.980848Z","iopub.execute_input":"2021-10-26T03:57:01.981075Z","iopub.status.idle":"2021-10-26T03:57:12.30327Z","shell.execute_reply.started":"2021-10-26T03:57:01.981048Z","shell.execute_reply":"2021-10-26T03:57:12.30229Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.rcParams['figure.figsize'] = [14,7]\nfig,ax=plt.subplots(1,2)\nax[0].set_title(\"PRACTICE_WINNINGS_NUMBER\")\nsns.distplot(x=df[\"PRACTICE_WINNINGS_NUMBER\"],ax=ax[0])\nax[1].set_title(\"PRACTICE_WINNINGS_NUMBER Transformed\")\nsns.distplot(x=np.log(1+np.power(df[\"PRACTICE_WINNINGS_NUMBER\"],0.25)), ax=ax[1])\nplt.show()","metadata":{"papermill":{"duration":12.687366,"end_time":"2021-08-26T22:08:05.619011","exception":false,"start_time":"2021-08-26T22:07:52.931645","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T03:57:12.304976Z","iopub.execute_input":"2021-10-26T03:57:12.305405Z","iopub.status.idle":"2021-10-26T03:57:25.282503Z","shell.execute_reply.started":"2021-10-26T03:57:12.305357Z","shell.execute_reply":"2021-10-26T03:57:25.281483Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.jointplot(data=df, y=\"REVENUE\", x=\"Y1\")","metadata":{"papermill":{"duration":195.72519,"end_time":"2021-08-26T22:11:21.424355","exception":false,"start_time":"2021-08-26T22:08:05.699165","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T03:57:25.284015Z","iopub.execute_input":"2021-10-26T03:57:25.285045Z","iopub.status.idle":"2021-10-26T04:00:37.164936Z","shell.execute_reply.started":"2021-10-26T03:57:25.284999Z","shell.execute_reply":"2021-10-26T04:00:37.163823Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.jointplot(data=df, y=\"REVENUE\", x=\"Y2\")","metadata":{"execution":{"iopub.status.busy":"2021-10-26T04:00:37.166689Z","iopub.execute_input":"2021-10-26T04:00:37.167424Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"categorical_variables=[\"STATUS_CHECK\", \"CATEGORY_1\", \"CATEGORY_2\", \"ACTIVE_YN\"]","metadata":{"papermill":{"duration":0.089677,"end_time":"2021-08-26T22:11:21.595749","exception":false,"start_time":"2021-08-26T22:11:21.506072","status":"completed"},"tags":[],"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"le_cat1=LabelEncoder()\nle_cat1.fit(df[\"CATEGORY_1\"])","metadata":{"papermill":{"duration":0.138166,"end_time":"2021-08-26T22:11:52.207765","exception":false,"start_time":"2021-08-26T22:11:52.069599","status":"completed"},"tags":[],"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"le_cat2=LabelEncoder()\nle_cat2.fit(df[\"CATEGORY_2\"])","metadata":{"papermill":{"duration":0.14857,"end_time":"2021-08-26T22:11:52.442534","exception":false,"start_time":"2021-08-26T22:11:52.293964","status":"completed"},"tags":[],"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"continuous_variables=[\"REVENUE\", \"WINNINGS_1\", \"DEPOSIT_2\", \"DISCOUNT\", \"DEPOSIT\", \"WITHDRAW\", \"ENTRY_NUMBER\", \"ENTRY_NUMBER\", \"WINNINGS_NUMBER\"]","metadata":{"papermill":{"duration":0.098591,"end_time":"2021-08-26T22:11:52.629205","exception":false,"start_time":"2021-08-26T22:11:52.530614","status":"completed"},"tags":[],"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df[\"CATEGORY_1\"]=le_cat1.transform(df[\"CATEGORY_1\"])\ndf[\"CATEGORY_2\"]=le_cat2.transform(df[\"CATEGORY_2\"])","metadata":{"papermill":{"duration":0.806081,"end_time":"2021-08-26T22:11:53.522988","exception":false,"start_time":"2021-08-26T22:11:52.716907","status":"completed"},"tags":[],"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df=df.groupby([\"UNIQUE_IDENTIFIER\"]).mean().reset_index(drop=True)\ndf","metadata":{"papermill":{"duration":0.557899,"end_time":"2021-08-26T22:11:54.16814","exception":false,"start_time":"2021-08-26T22:11:53.610241","status":"completed"},"tags":[],"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"num_bins = int(np.floor(1 + np.log2(len(df)))) \ndf.loc[:, \"bins\"] = pd.cut(df[\"Y2\"], bins=num_bins, labels=False)","metadata":{"papermill":{"duration":0.103679,"end_time":"2021-08-26T22:11:54.359495","exception":false,"start_time":"2021-08-26T22:11:54.255816","status":"completed"},"tags":[],"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"trans_df=df","metadata":{"papermill":{"duration":0.097033,"end_time":"2021-08-26T22:11:54.543969","exception":false,"start_time":"2021-08-26T22:11:54.446936","status":"completed"},"tags":[],"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for col in continuous_variables:\n    trans_df[f\"t_{col}\"]=np.log(1+np.power(df[col],0.25))","metadata":{"papermill":{"duration":0.226016,"end_time":"2021-08-26T22:11:54.858176","exception":false,"start_time":"2021-08-26T22:11:54.63216","status":"completed"},"tags":[],"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"drop_cols=[\"SEQUENCE_NO\", \"PRACTICE_ENTRY\", \"PRACTICE_WINNINGS\", \"PRACTICE_ENTRY_NUMBER\", \"PRACTICE_WINNINGS_NUMBER\", \"CATEGORY_1\", \"CATEGORY_2\"]","metadata":{"papermill":{"duration":0.097611,"end_time":"2021-08-26T22:11:55.045273","exception":false,"start_time":"2021-08-26T22:11:54.947662","status":"completed"},"tags":[],"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"trans_df=trans_df.drop(columns=continuous_variables+drop_cols,axis=1)","metadata":{"papermill":{"duration":0.119287,"end_time":"2021-08-26T22:11:55.253247","exception":false,"start_time":"2021-08-26T22:11:55.13396","status":"completed"},"tags":[],"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"trans_df.head()","metadata":{"papermill":{"duration":0.11644,"end_time":"2021-08-26T22:11:55.530687","exception":false,"start_time":"2021-08-26T22:11:55.414247","status":"completed"},"tags":[],"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.heatmap(trans_df.corr(),annot=True)","metadata":{"papermill":{"duration":2.230619,"end_time":"2021-08-26T22:11:57.849442","exception":false,"start_time":"2021-08-26T22:11:55.618823","status":"completed"},"tags":[],"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df,val_df=train_test_split(trans_df,test_size=0.2,stratify=trans_df[\"bins\"])\ntrain_df\n","metadata":{"papermill":{"duration":0.193772,"end_time":"2021-08-26T22:11:58.140294","exception":false,"start_time":"2021-08-26T22:11:57.946522","status":"completed"},"tags":[],"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_train = train_df.drop(columns=['STATUS_CHECK', 'ACTIVE_YN', 'ENTRY', 'WINNINGS_2', 'DEPOSIT_NUMBER',\n       'WITHDRAW_NUMBER', 'DEPOSIT_TRAILS', 'bins', 't_REVENUE',\n       't_WINNINGS_1', 't_DEPOSIT_2', 't_DISCOUNT', 't_DEPOSIT', 't_WITHDRAW',\n       't_ENTRY_NUMBER', 't_WINNINGS_NUMBER'])\ny_val =  val_df.drop(columns=['STATUS_CHECK', 'ACTIVE_YN', 'ENTRY', 'WINNINGS_2', 'DEPOSIT_NUMBER',\n       'WITHDRAW_NUMBER', 'DEPOSIT_TRAILS', 'bins', 't_REVENUE',\n       't_WINNINGS_1', 't_DEPOSIT_2', 't_DISCOUNT', 't_DEPOSIT', 't_WITHDRAW',\n       't_ENTRY_NUMBER', 't_WINNINGS_NUMBER'])","metadata":{"papermill":{"duration":0.105532,"end_time":"2021-08-26T22:11:58.341068","exception":false,"start_time":"2021-08-26T22:11:58.235536","status":"completed"},"tags":[],"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train=train_df.drop(columns=[\"Y1\",\"Y2\",\"bins\"])\nX_val=val_df.drop(columns=[\"Y1\",\"Y2\",\"bins\"])","metadata":{"papermill":{"duration":0.109847,"end_time":"2021-08-26T22:11:58.545641","exception":false,"start_time":"2021-08-26T22:11:58.435794","status":"completed"},"tags":[],"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_train\n","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Neural Network","metadata":{"papermill":{"duration":0.09566,"end_time":"2021-08-26T22:11:58.736231","exception":false,"start_time":"2021-08-26T22:11:58.640571","status":"completed"},"tags":[]}},{"cell_type":"code","source":"import tensorflow as tf\nfrom tensorflow.keras.layers import Dense, Activation, Dropout \nfrom tensorflow.keras.optimizers import RMSprop #OPTIMIZER\nfrom sklearn.preprocessing import MinMaxScaler\nmodel = tf.keras.Sequential()\n\nmodel.add(tf.keras.layers.Dense(1028, input_shape=(15,),activation = 'relu'))\nmodel.add(tf.keras.layers.Dense(128, input_shape=(1028,),activation = 'relu'))\nmodel.add(tf.keras.layers.Dense(32, input_shape=(128,),activation = 'relu'))\n\n# adding the second layer - with 4 inputs(need not specify) and 1 output target\nmodel.add(tf.keras.layers.Dense(2,activation = 'relu'))","metadata":{"papermill":{"duration":22.376535,"end_time":"2021-08-26T22:12:21.208341","exception":false,"start_time":"2021-08-26T22:11:58.831806","status":"completed"},"tags":[],"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.summary()","metadata":{"papermill":{"duration":0.173241,"end_time":"2021-08-26T22:12:21.479327","exception":false,"start_time":"2021-08-26T22:12:21.306086","status":"completed"},"tags":[],"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"los = tf.keras.losses.MeanSquaredError()\nmetric = tf.keras.metrics.MeanSquaredError()\nmodel.compile(optimizer = 'adam',loss = los,metrics = [metric])  ","metadata":{"papermill":{"duration":0.108144,"end_time":"2021-08-26T22:12:21.685458","exception":false,"start_time":"2021-08-26T22:12:21.577314","status":"completed"},"tags":[],"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"history = model.fit(X_train, y_train, validation_split = 0.2 , epochs=36)","metadata":{"papermill":{"duration":7.352166,"end_time":"2021-08-26T22:12:29.13405","exception":false,"start_time":"2021-08-26T22:12:21.781884","status":"completed"},"tags":[],"execution":{"iopub.status.idle":"2021-10-26T04:03:48.772329Z","shell.execute_reply.started":"2021-10-26T04:02:26.394572Z","shell.execute_reply":"2021-10-26T04:03:48.771263Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test=pd.read_csv(\"../input/beyond-analysis/test.csv\")\ntest","metadata":{"papermill":{"duration":2.960387,"end_time":"2021-08-26T22:12:32.191323","exception":false,"start_time":"2021-08-26T22:12:29.230936","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T04:03:48.774078Z","iopub.execute_input":"2021-10-26T04:03:48.774376Z","iopub.status.idle":"2021-10-26T04:03:51.883605Z","shell.execute_reply.started":"2021-10-26T04:03:48.774341Z","shell.execute_reply":"2021-10-26T04:03:51.882573Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df=test.groupby([\"UNIQUE_IDENTIFIER\"]).mean()","metadata":{"papermill":{"duration":0.317702,"end_time":"2021-08-26T22:12:32.606774","exception":false,"start_time":"2021-08-26T22:12:32.289072","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T04:03:51.884832Z","iopub.execute_input":"2021-10-26T04:03:51.885077Z","iopub.status.idle":"2021-10-26T04:03:52.099304Z","shell.execute_reply.started":"2021-10-26T04:03:51.885049Z","shell.execute_reply":"2021-10-26T04:03:52.098233Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(len(test_df))","metadata":{"papermill":{"duration":0.103815,"end_time":"2021-08-26T22:12:32.805744","exception":false,"start_time":"2021-08-26T22:12:32.701929","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T04:03:52.100705Z","iopub.execute_input":"2021-10-26T04:03:52.100988Z","iopub.status.idle":"2021-10-26T04:03:52.106908Z","shell.execute_reply.started":"2021-10-26T04:03:52.100956Z","shell.execute_reply":"2021-10-26T04:03:52.105921Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for col in continuous_variables:\n    test_df[f\"t_{col}\"]=np.log(1+np.power(test_df[col],0.2))","metadata":{"papermill":{"duration":0.175618,"end_time":"2021-08-26T22:12:33.077396","exception":false,"start_time":"2021-08-26T22:12:32.901778","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T04:03:52.108593Z","iopub.execute_input":"2021-10-26T04:03:52.108878Z","iopub.status.idle":"2021-10-26T04:03:52.189519Z","shell.execute_reply.started":"2021-10-26T04:03:52.108848Z","shell.execute_reply":"2021-10-26T04:03:52.188525Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df","metadata":{"papermill":{"duration":0.131551,"end_time":"2021-08-26T22:12:33.308286","exception":false,"start_time":"2021-08-26T22:12:33.176735","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T04:03:52.190869Z","iopub.execute_input":"2021-10-26T04:03:52.191132Z","iopub.status.idle":"2021-10-26T04:03:52.24165Z","shell.execute_reply.started":"2021-10-26T04:03:52.191099Z","shell.execute_reply":"2021-10-26T04:03:52.240691Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"drop_cols_test=[\"SEQUENCE_NO\", \"PRACTICE_ENTRY\", \"PRACTICE_WINNINGS\", \"PRACTICE_ENTRY_NUMBER\", \"PRACTICE_WINNINGS_NUMBER\"]","metadata":{"papermill":{"duration":0.105819,"end_time":"2021-08-26T22:12:33.511103","exception":false,"start_time":"2021-08-26T22:12:33.405284","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T04:03:52.242849Z","iopub.execute_input":"2021-10-26T04:03:52.243069Z","iopub.status.idle":"2021-10-26T04:03:52.248395Z","shell.execute_reply.started":"2021-10-26T04:03:52.243043Z","shell.execute_reply":"2021-10-26T04:03:52.247584Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df=test_df.drop(columns=continuous_variables+drop_cols_test,axis=1)","metadata":{"papermill":{"duration":0.119308,"end_time":"2021-08-26T22:12:33.728939","exception":false,"start_time":"2021-08-26T22:12:33.609631","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T04:03:52.249975Z","iopub.execute_input":"2021-10-26T04:03:52.250295Z","iopub.status.idle":"2021-10-26T04:03:52.279663Z","shell.execute_reply.started":"2021-10-26T04:03:52.250258Z","shell.execute_reply":"2021-10-26T04:03:52.278849Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df","metadata":{"papermill":{"duration":0.124226,"end_time":"2021-08-26T22:12:33.950681","exception":false,"start_time":"2021-08-26T22:12:33.826455","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T04:03:52.281113Z","iopub.execute_input":"2021-10-26T04:03:52.28138Z","iopub.status.idle":"2021-10-26T04:03:52.309Z","shell.execute_reply.started":"2021-10-26T04:03:52.281351Z","shell.execute_reply":"2021-10-26T04:03:52.307863Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_test=test_df.values\ntpred = model.predict(X_train)\ntscore = mean_squared_error(y_train, tpred)\n\n# validation predictions\nvpred = model.predict(X_val)\nvscore = mean_squared_error(y_val, vpred)\n\nprint(f'Training score   - {tscore:.3f} \\nValidation score - {vscore:.3f}')","metadata":{"papermill":{"duration":0.38254,"end_time":"2021-08-26T22:12:34.43179","exception":false,"start_time":"2021-08-26T22:12:34.04925","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T04:03:52.311414Z","iopub.execute_input":"2021-10-26T04:03:52.311653Z","iopub.status.idle":"2021-10-26T04:03:57.549468Z","shell.execute_reply.started":"2021-10-26T04:03:52.311626Z","shell.execute_reply":"2021-10-26T04:03:57.54863Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_predd = model.predict(X_test)\ny_predd","metadata":{"papermill":{"duration":0.137423,"end_time":"2021-08-26T22:12:34.669832","exception":false,"start_time":"2021-08-26T22:12:34.532409","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T04:03:57.550991Z","iopub.execute_input":"2021-10-26T04:03:57.551379Z","iopub.status.idle":"2021-10-26T04:04:01.249946Z","shell.execute_reply.started":"2021-10-26T04:03:57.551339Z","shell.execute_reply":"2021-10-26T04:04:01.248687Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission = pd.read_csv('../input/beyond-analysis/sample_submission_random.csv')\nsubmission.iloc[:, 1:3] = y_predd\nsubmission","metadata":{"papermill":{"duration":14.803433,"end_time":"2021-08-26T22:12:50.638448","exception":false,"start_time":"2021-08-26T22:12:35.835015","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T04:04:01.251744Z","iopub.execute_input":"2021-10-26T04:04:01.252047Z","iopub.status.idle":"2021-10-26T04:04:01.265804Z","shell.execute_reply.started":"2021-10-26T04:04:01.252014Z","shell.execute_reply":"2021-10-26T04:04:01.265084Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.to_csv(\"submission.csv\",index = False)\n","metadata":{"papermill":{"duration":0.140167,"end_time":"2021-08-26T22:13:04.612471","exception":false,"start_time":"2021-08-26T22:13:04.472304","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-10-26T04:04:01.823545Z","iopub.status.idle":"2021-10-26T04:04:01.824159Z","shell.execute_reply.started":"2021-10-26T04:04:01.82395Z","shell.execute_reply":"2021-10-26T04:04:01.823973Z"},"trusted":true},"execution_count":null,"outputs":[]}]}