{"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":"2022-07-22T08:29:57.865159Z","iopub.execute_input":"2022-07-22T08:29:57.865591Z","iopub.status.idle":"2022-07-22T08:29:57.901092Z","shell.execute_reply.started":"2022-07-22T08:29:57.865494Z","shell.execute_reply":"2022-07-22T08:29:57.900118Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nimport seaborn as sns\nimport pandas as pd\nimport numpy as np\nimport gc\n","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:29:57.903265Z","iopub.execute_input":"2022-07-22T08:29:57.904173Z","iopub.status.idle":"2022-07-22T08:29:58.590738Z","shell.execute_reply.started":"2022-07-22T08:29:57.904136Z","shell.execute_reply":"2022-07-22T08:29:58.589660Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df = pd.read_csv('/kaggle/input/pubg-finish-placement-prediction/train_V2.csv')\ntest_df = pd.read_csv('/kaggle/input/pubg-finish-placement-prediction/test_V2.csv')\nsample_df = pd.read_csv('/kaggle/input/pubg-finish-placement-prediction/sample_submission_V2.csv')","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:29:58.592037Z","iopub.execute_input":"2022-07-22T08:29:58.592361Z","iopub.status.idle":"2022-07-22T08:30:28.649511Z","shell.execute_reply.started":"2022-07-22T08:29:58.592329Z","shell.execute_reply":"2022-07-22T08:30:28.648400Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:30:28.651859Z","iopub.execute_input":"2022-07-22T08:30:28.652225Z","iopub.status.idle":"2022-07-22T08:30:28.694256Z","shell.execute_reply.started":"2022-07-22T08:30:28.652193Z","shell.execute_reply":"2022-07-22T08:30:28.693174Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.info()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:30:28.695666Z","iopub.execute_input":"2022-07-22T08:30:28.696093Z","iopub.status.idle":"2022-07-22T08:30:28.719694Z","shell.execute_reply.started":"2022-07-22T08:30:28.696041Z","shell.execute_reply":"2022-07-22T08:30:28.718065Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Cheking cheaters or afks","metadata":{}},{"cell_type":"code","source":"data = train_df[train_df['walkDistance']==0].copy()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:30:28.722373Z","iopub.execute_input":"2022-07-22T08:30:28.722861Z","iopub.status.idle":"2022-07-22T08:30:28.831648Z","shell.execute_reply.started":"2022-07-22T08:30:28.722816Z","shell.execute_reply":"2022-07-22T08:30:28.830578Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:30:28.833198Z","iopub.execute_input":"2022-07-22T08:30:28.833608Z","iopub.status.idle":"2022-07-22T08:30:28.861754Z","shell.execute_reply.started":"2022-07-22T08:30:28.833565Z","shell.execute_reply":"2022-07-22T08:30:28.860761Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data2 = train.copy()\ndata2['player_count'] = data2.groupby('matchId')['Id'].transform('count')","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:58:50.163094Z","iopub.execute_input":"2022-07-22T08:58:50.163540Z","iopub.status.idle":"2022-07-22T08:58:51.919627Z","shell.execute_reply.started":"2022-07-22T08:58:50.163503Z","shell.execute_reply":"2022-07-22T08:58:51.918670Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data2.info()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:58:56.372101Z","iopub.execute_input":"2022-07-22T08:58:56.372507Z","iopub.status.idle":"2022-07-22T08:58:56.555165Z","shell.execute_reply.started":"2022-07-22T08:58:56.372472Z","shell.execute_reply":"2022-07-22T08:58:56.553610Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize = (15,10))\nsns.countplot(x = 'player_count' , data = data2 ,orient = \"h\")\nplt.title(\"player_count\",fontsize=15)\nplt.xticks(rotation=90)\nplt.show()\n","metadata":{"execution":{"iopub.status.busy":"2022-07-22T09:02:38.019924Z","iopub.execute_input":"2022-07-22T09:02:38.020712Z","iopub.status.idle":"2022-07-22T09:02:40.300786Z","shell.execute_reply.started":"2022-07-22T09:02:38.020678Z","shell.execute_reply":"2022-07-22T09:02:40.299944Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data2['killsNorm'] = data2['kills']/data2['player_count']*100\ndata2['damageDealtNorm'] = data2['damageDealt']/data2['player_count']*100\ntemp = data2[data2['kills']> 5]\ntemp[['player_count', 'kills', 'killsNorm', 'damageDealt', 'damageDealtNorm']][0:8]","metadata":{"execution":{"iopub.status.busy":"2022-07-22T09:13:59.436678Z","iopub.execute_input":"2022-07-22T09:13:59.437051Z","iopub.status.idle":"2022-07-22T09:13:59.570947Z","shell.execute_reply.started":"2022-07-22T09:13:59.437019Z","shell.execute_reply":"2022-07-22T09:13:59.569929Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data['kills'].max()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:30:28.863188Z","iopub.execute_input":"2022-07-22T08:30:28.863431Z","iopub.status.idle":"2022-07-22T08:30:28.871492Z","shell.execute_reply.started":"2022-07-22T08:30:28.863407Z","shell.execute_reply":"2022-07-22T08:30:28.870726Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.loc[data['kills'] >= 9] = '9+'\nplt.figure(figsize = (15,10))\nsns.countplot(x = data['kills'].astype('str').sort_values())\nplt.title(\"Kill Count\",fontsize=15)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:30:28.872641Z","iopub.execute_input":"2022-07-22T08:30:28.872860Z","iopub.status.idle":"2022-07-22T08:30:29.535982Z","shell.execute_reply.started":"2022-07-22T08:30:28.872838Z","shell.execute_reply":"2022-07-22T08:30:29.534934Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(data)","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:30:29.540243Z","iopub.execute_input":"2022-07-22T08:30:29.540670Z","iopub.status.idle":"2022-07-22T08:30:29.546539Z","shell.execute_reply.started":"2022-07-22T08:30:29.540636Z","shell.execute_reply":"2022-07-22T08:30:29.545774Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f\"{data[data['winPlacePerc']==1].shape[0]} players ({100*data[data['winPlacePerc']==1].shape[0]/train_df.shape[0]:.4f}%) have won without walking!\")","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:30:29.547690Z","iopub.execute_input":"2022-07-22T08:30:29.548166Z","iopub.status.idle":"2022-07-22T08:30:29.640873Z","shell.execute_reply.started":"2022-07-22T08:30:29.548136Z","shell.execute_reply":"2022-07-22T08:30:29.639827Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"del data\ngc.collect()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:30:29.642092Z","iopub.execute_input":"2022-07-22T08:30:29.642400Z","iopub.status.idle":"2022-07-22T08:30:29.865376Z","shell.execute_reply.started":"2022-07-22T08:30:29.642370Z","shell.execute_reply":"2022-07-22T08:30:29.864549Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.drop(train_df[train_df['walkDistance'] == 0 ].index, inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:30:29.866547Z","iopub.execute_input":"2022-07-22T08:30:29.867025Z","iopub.status.idle":"2022-07-22T08:30:30.658867Z","shell.execute_reply.started":"2022-07-22T08:30:29.866964Z","shell.execute_reply":"2022-07-22T08:30:30.657712Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:30:30.660170Z","iopub.execute_input":"2022-07-22T08:30:30.660469Z","iopub.status.idle":"2022-07-22T08:30:30.672309Z","shell.execute_reply.started":"2022-07-22T08:30:30.660441Z","shell.execute_reply":"2022-07-22T08:30:30.670679Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train = train_df","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:30:30.674930Z","iopub.execute_input":"2022-07-22T08:30:30.675385Z","iopub.status.idle":"2022-07-22T08:30:30.682031Z","shell.execute_reply.started":"2022-07-22T08:30:30.675344Z","shell.execute_reply":"2022-07-22T08:30:30.681125Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"The average person kills {:.4f} players, 99% of people have {} kills or less, while the most kills ever recorded is {}.\".format(train['kills'].mean(),train['kills'].quantile(0.99), train['kills'].max()))\n","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:30:30.683326Z","iopub.execute_input":"2022-07-22T08:30:30.683799Z","iopub.status.idle":"2022-07-22T08:30:30.737504Z","shell.execute_reply.started":"2022-07-22T08:30:30.683770Z","shell.execute_reply":"2022-07-22T08:30:30.736408Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f\"the average person kills {train_df['kills'].mean():.4f} players, 98% of people have less than {train_df['kills'].quantile(0.98)} kills or less while the most kills ever recorded is { train_df['kills'].max() } \")","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:30:30.739913Z","iopub.execute_input":"2022-07-22T08:30:30.740346Z","iopub.status.idle":"2022-07-22T08:30:30.786528Z","shell.execute_reply.started":"2022-07-22T08:30:30.740314Z","shell.execute_reply":"2022-07-22T08:30:30.785324Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data = train.copy()\ndata.loc[data['kills'] >= data['kills'].quantile(0.98)] = '6+'\nplt.figure(figsize = (15,10))\nsns.countplot(x = data['kills'].astype('str').sort_values())\nplt.title(\"Kill Count\",fontsize=15)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:30:30.788137Z","iopub.execute_input":"2022-07-22T08:30:30.788929Z","iopub.status.idle":"2022-07-22T08:30:55.241259Z","shell.execute_reply.started":"2022-07-22T08:30:30.788894Z","shell.execute_reply":"2022-07-22T08:30:55.240277Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Damage dealt by 0 killers","metadata":{}},{"cell_type":"code","source":"del data\ngc.collect()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:30:55.242387Z","iopub.execute_input":"2022-07-22T08:30:55.242680Z","iopub.status.idle":"2022-07-22T08:30:56.450280Z","shell.execute_reply.started":"2022-07-22T08:30:55.242656Z","shell.execute_reply":"2022-07-22T08:30:56.449215Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data = train.copy()\ndata = data[data['kills']==0]\nplt.figure(figsize=(15,10))\nplt.title(\"Damage Dealt by 0 killers\",fontsize=15)\nsns.histplot(x=data['damageDealt']) #by density instead of count\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:30:56.451678Z","iopub.execute_input":"2022-07-22T08:30:56.452034Z","iopub.status.idle":"2022-07-22T08:30:59.504158Z","shell.execute_reply.started":"2022-07-22T08:30:56.452002Z","shell.execute_reply":"2022-07-22T08:30:59.502645Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f\"{data[data['winPlacePerc']==1].shape[0]} players ({100*data[data['winPlacePerc']==1].shape[0]/train.shape[0]:.4f}%) have won without a single kill!\")","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:30:59.505890Z","iopub.execute_input":"2022-07-22T08:30:59.506316Z","iopub.status.idle":"2022-07-22T08:30:59.549125Z","shell.execute_reply.started":"2022-07-22T08:30:59.506278Z","shell.execute_reply":"2022-07-22T08:30:59.547781Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data1 = train[train['damageDealt'] == 0].copy()\nprint(\"{} players ({:.4f}%) have won without dealing damage!\".format(len(data1[data1['winPlacePerc']==1]), 100*len(data1[data1['winPlacePerc']==1])/len(train)))","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:30:59.550460Z","iopub.execute_input":"2022-07-22T08:30:59.550863Z","iopub.status.idle":"2022-07-22T08:30:59.915949Z","shell.execute_reply.started":"2022-07-22T08:30:59.550831Z","shell.execute_reply":"2022-07-22T08:30:59.915018Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.jointplot(x=\"winPlacePerc\", y=\"kills\", data=train, height=10, ratio=3, color=\"r\") #scatter w fil les deux axes  hists\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:30:59.917358Z","iopub.execute_input":"2022-07-22T08:30:59.918072Z","iopub.status.idle":"2022-07-22T08:31:21.470960Z","shell.execute_reply.started":"2022-07-22T08:30:59.918036Z","shell.execute_reply":"2022-07-22T08:31:21.470139Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"We can the they are correlated","metadata":{}},{"cell_type":"code","source":"kills = train.copy()\n\nkills['killsCategories'] = pd.cut(kills['kills'],\n                                   [-1, 0, 2, 5, 10, train['kills'].max()],\n                                   labels=['0_kills','1-2_kills', '3-5_kills', '6-10_kills', '10+_kills'])\n\nplt.figure(figsize=(15,8))\nsns.boxplot(x=\"killsCategories\", y=\"winPlacePerc\", data=kills)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:31:21.472503Z","iopub.execute_input":"2022-07-22T08:31:21.472941Z","iopub.status.idle":"2022-07-22T08:31:22.619301Z","shell.execute_reply.started":"2022-07-22T08:31:21.472912Z","shell.execute_reply":"2022-07-22T08:31:22.618320Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"del data\ndel kills\ngc.collect()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:31:22.620255Z","iopub.execute_input":"2022-07-22T08:31:22.620503Z","iopub.status.idle":"2022-07-22T08:31:23.463429Z","shell.execute_reply.started":"2022-07-22T08:31:22.620479Z","shell.execute_reply":"2022-07-22T08:31:23.462426Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data = train.copy()\n","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:31:23.465058Z","iopub.execute_input":"2022-07-22T08:31:23.465750Z","iopub.status.idle":"2022-07-22T08:31:23.798445Z","shell.execute_reply.started":"2022-07-22T08:31:23.465716Z","shell.execute_reply":"2022-07-22T08:31:23.797440Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"f,ax1 = plt.subplots(figsize =(20,10))\nsns.pointplot(x='vehicleDestroys',y='winPlacePerc',data=data,color='#606060',alpha=0.8)\nplt.xlabel('Number of Vehicle Destroys',fontsize = 15,color='blue')\nplt.ylabel('Win Percentage',fontsize = 15,color='blue')\nplt.title('Vehicle Destroys/ Win Ratio',fontsize = 20,color='blue')\nplt.grid()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:31:23.799877Z","iopub.execute_input":"2022-07-22T08:31:23.800119Z","iopub.status.idle":"2022-07-22T08:35:57.588148Z","shell.execute_reply.started":"2022-07-22T08:31:23.800096Z","shell.execute_reply":"2022-07-22T08:35:57.587027Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"del data\ngc.collect()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:35:57.594110Z","iopub.execute_input":"2022-07-22T08:35:57.594389Z","iopub.status.idle":"2022-07-22T08:35:57.801794Z","shell.execute_reply.started":"2022-07-22T08:35:57.594365Z","shell.execute_reply":"2022-07-22T08:35:57.800905Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data = train.copy()\ndata = data[data['heals'] < data['heals'].quantile(0.99)]\ndata = data[data['boosts'] < data['boosts'].quantile(0.99)]\n\nf,ax1 = plt.subplots(figsize =(20,10))\nsns.pointplot(x='heals',y='winPlacePerc',data=data,color='lime',alpha=0.8)\nsns.pointplot(x='boosts',y='winPlacePerc',data=data,color='blue',alpha=0.8)\nplt.text(4,0.6,'Heals',color='lime',fontsize = 17,style = 'italic')\nplt.text(4,0.55,'Boosts',color='blue',fontsize = 17,style = 'italic')\nplt.xlabel('Number of heal/boost items',fontsize = 15,color='blue')\nplt.ylabel('Win Percentage',fontsize = 15,color='blue')\nplt.title('Heals vs Boosts',fontsize = 20,color='blue')\nplt.grid()\nplt.show()\n","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:35:57.803055Z","iopub.execute_input":"2022-07-22T08:35:57.803716Z","iopub.status.idle":"2022-07-22T08:41:34.022788Z","shell.execute_reply.started":"2022-07-22T08:35:57.803681Z","shell.execute_reply":"2022-07-22T08:41:34.021879Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"solos = train[train['numGroups']>50]\nduos = train[(train['numGroups']>25) & (train['numGroups']<=50)]\nsquads = train[train['numGroups']<=25]\nprint(\"There are {} ({:.2f}%) solo games, {} ({:.2f}%) duo games and {} ({:.2f}%) squad games.\"\n      .format(len(solos), \n              100*len(solos)/len(train), \n              len(duos),\n              100*len(duos)/len(train),\n              len(squads),\n              100*len(squads)/len(train),))","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:41:34.024395Z","iopub.execute_input":"2022-07-22T08:41:34.024938Z","iopub.status.idle":"2022-07-22T08:41:35.135400Z","shell.execute_reply.started":"2022-07-22T08:41:34.024901Z","shell.execute_reply":"2022-07-22T08:41:35.134002Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"f,ax1 = plt.subplots(figsize =(20,10))\nsns.pointplot(x='kills',y='winPlacePerc',data=solos,color='black',alpha=0.8)\nsns.pointplot(x='kills',y='winPlacePerc',data=duos,color='#CC0000',alpha=0.8)\nsns.pointplot(x='kills',y='winPlacePerc',data=squads,color='#3399FF',alpha=0.8)\nplt.text(37,0.6,'Solos',color='black',fontsize = 17,style = 'italic')\nplt.text(37,0.55,'Duos',color='#CC0000',fontsize = 17,style = 'italic')\nplt.text(37,0.5,'Squads',color='#3399FF',fontsize = 17,style = 'italic')\nplt.xlabel('Number of kills',fontsize = 15,color='blue')\nplt.ylabel('Win Percentage',fontsize = 15,color='blue')\nplt.title('Solo vs Duo vs Squad Kills',fontsize = 20,color='blue')\nplt.grid()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:41:35.136774Z","iopub.execute_input":"2022-07-22T08:41:35.137138Z","iopub.status.idle":"2022-07-22T08:43:06.904950Z","shell.execute_reply.started":"2022-07-22T08:41:35.137109Z","shell.execute_reply":"2022-07-22T08:43:06.903705Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Correlation between variables","metadata":{}},{"cell_type":"code","source":"sns.heatmap??","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:43:06.906678Z","iopub.execute_input":"2022-07-22T08:43:06.907460Z","iopub.status.idle":"2022-07-22T08:43:07.034965Z","shell.execute_reply.started":"2022-07-22T08:43:06.907425Z","shell.execute_reply":"2022-07-22T08:43:07.033510Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.DataFrame.corr??","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:43:07.036965Z","iopub.execute_input":"2022-07-22T08:43:07.037695Z","iopub.status.idle":"2022-07-22T08:43:07.067136Z","shell.execute_reply.started":"2022-07-22T08:43:07.037659Z","shell.execute_reply":"2022-07-22T08:43:07.066202Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"del data\ngc.collect()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:43:07.068283Z","iopub.execute_input":"2022-07-22T08:43:07.068678Z","iopub.status.idle":"2022-07-22T08:43:07.337243Z","shell.execute_reply.started":"2022-07-22T08:43:07.068651Z","shell.execute_reply":"2022-07-22T08:43:07.336358Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"f,ax = plt.subplots(figsize=(15, 15))\nsns.heatmap(train.corr(), annot=True, linewidths=.5, fmt= '.1f',ax=ax)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:43:07.338465Z","iopub.execute_input":"2022-07-22T08:43:07.338750Z","iopub.status.idle":"2022-07-22T08:43:14.830960Z","shell.execute_reply.started":"2022-07-22T08:43:07.338719Z","shell.execute_reply":"2022-07-22T08:43:14.829928Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"In terms of the target variable (winPlacePerc), there are a few variables high medium to high correlation. The highest positive correlation is walkDistance and the highest negative the killPlace.","metadata":{}},{"cell_type":"markdown","source":"### Zooming on top 5 features related to winPlacePerc","metadata":{}},{"cell_type":"code","source":"k = 5 #number of variables for heatmap\nf,ax = plt.subplots(figsize=(11, 11))\ncols = train.corr().nlargest(k, 'winPlacePerc')['winPlacePerc'].index\ncm = np.corrcoef(train[cols].values.T)\nsns.set(font_scale=1.25)\nhm = sns.heatmap(cm, cbar=True, annot=True, square=True, fmt='.2f', annot_kws={'size': 10}, yticklabels=cols.values, xticklabels=cols.values)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:43:14.832219Z","iopub.execute_input":"2022-07-22T08:43:14.832545Z","iopub.status.idle":"2022-07-22T08:43:20.368843Z","shell.execute_reply.started":"2022-07-22T08:43:14.832514Z","shell.execute_reply":"2022-07-22T08:43:20.367687Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(cols)","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:43:20.370256Z","iopub.execute_input":"2022-07-22T08:43:20.370606Z","iopub.status.idle":"2022-07-22T08:43:20.378408Z","shell.execute_reply.started":"2022-07-22T08:43:20.370572Z","shell.execute_reply":"2022-07-22T08:43:20.377198Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(cm)","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:43:20.380124Z","iopub.execute_input":"2022-07-22T08:43:20.380484Z","iopub.status.idle":"2022-07-22T08:43:20.392663Z","shell.execute_reply.started":"2022-07-22T08:43:20.380459Z","shell.execute_reply":"2022-07-22T08:43:20.391768Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.set()\ncols = ['winPlacePerc', 'walkDistance', 'boosts', 'weaponsAcquired', 'damageDealt', 'killPlace']\nsns.pairplot(train[cols], height = 2.5)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:43:20.393946Z","iopub.execute_input":"2022-07-22T08:43:20.394269Z","iopub.status.idle":"2022-07-22T08:47:04.103865Z","shell.execute_reply.started":"2022-07-22T08:43:20.394238Z","shell.execute_reply":"2022-07-22T08:47:04.102795Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}