{"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)\nfrom pathlib import Path\nimport os.path\nimport matplotlib.pyplot as plt\nimport tensorflow as tf\nimport seaborn as sns\n\n#Ignore warnings\nimport warnings\nwarnings.filterwarnings('ignore')\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-05-21T00:18:47.710368Z","iopub.execute_input":"2022-05-21T00:18:47.710735Z","iopub.status.idle":"2022-05-21T00:19:58.282999Z","shell.execute_reply.started":"2022-05-21T00:18:47.710652Z","shell.execute_reply":"2022-05-21T00:19:58.275215Z"},"_kg_hide-input":true,"_kg_hide-output":true,"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"![](https://image.slidesharecdn.com/whatisakendallstau-141002162706-phpapp02/85/what-is-a-kendalls-tau-22-320.jpg?cb=1412267289)pt.slideshare.net","metadata":{}},{"cell_type":"code","source":"!pip install dataprep","metadata":{"execution":{"iopub.status.busy":"2022-05-21T00:20:25.920168Z","iopub.execute_input":"2022-05-21T00:20:25.921108Z","iopub.status.idle":"2022-05-21T00:21:13.885562Z","shell.execute_reply.started":"2022-05-21T00:20:25.921076Z","shell.execute_reply":"2022-05-21T00:21:13.884497Z"},"_kg_hide-output":true,"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"! python -m pip install \"dask[dataframe]\" --upgrade  # or python -m pip install","metadata":{"execution":{"iopub.status.busy":"2022-05-21T00:21:16.584969Z","iopub.execute_input":"2022-05-21T00:21:16.585369Z","iopub.status.idle":"2022-05-21T00:21:27.267075Z","shell.execute_reply.started":"2022-05-21T00:21:16.585344Z","shell.execute_reply":"2022-05-21T00:21:27.266430Z"},"_kg_hide-output":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from dataprep.eda import plot, plot_correlation, create_report, plot_missing","metadata":{"execution":{"iopub.status.busy":"2022-05-21T00:21:52.722165Z","iopub.execute_input":"2022-05-21T00:21:52.722400Z","iopub.status.idle":"2022-05-21T00:21:55.205430Z","shell.execute_reply.started":"2022-05-21T00:21:52.722372Z","shell.execute_reply":"2022-05-21T00:21:55.204679Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.read_csv('../input/AI4Code/train_orders.csv',delimiter=',', encoding='ISO-8859-2')\ndf.head()","metadata":{"execution":{"iopub.status.busy":"2022-05-21T00:24:10.814242Z","iopub.execute_input":"2022-05-21T00:24:10.814874Z","iopub.status.idle":"2022-05-21T00:24:12.192556Z","shell.execute_reply.started":"2022-05-21T00:24:10.814822Z","shell.execute_reply":"2022-05-21T00:24:12.191694Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1 = pd.read_csv('../input/AI4Code/train_ancestors.csv',delimiter=',', encoding='ISO-8859-2')\ndf1.head()","metadata":{"execution":{"iopub.status.busy":"2022-05-21T00:25:34.738343Z","iopub.execute_input":"2022-05-21T00:25:34.738588Z","iopub.status.idle":"2022-05-21T00:25:34.987356Z","shell.execute_reply.started":"2022-05-21T00:25:34.738562Z","shell.execute_reply":"2022-05-21T00:25:34.986591Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.preprocessing import LabelEncoder\n\n#fill in mean for floats\nfor c in df.columns:\n    if df[c].dtype=='float16' or  df[c].dtype=='float32' or  df[c].dtype=='float64':\n        df[c].fillna(df[c].mean())\n\n#fill in -999 for categoricals\ndf = df.fillna(-999)\n# Label Encoding\nfor f in df.columns:\n    if df[f].dtype=='object': \n        lbl = LabelEncoder()\n        lbl.fit(list(df[f].values))\n        df[f] = lbl.transform(list(df[f].values))\n        \nprint('Labelling done.')","metadata":{"execution":{"iopub.status.busy":"2022-05-21T00:26:28.115079Z","iopub.execute_input":"2022-05-21T00:26:28.115334Z","iopub.status.idle":"2022-05-21T00:26:47.879419Z","shell.execute_reply.started":"2022-05-21T00:26:28.115307Z","shell.execute_reply":"2022-05-21T00:26:47.878442Z"},"_kg_hide-output":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"![](https://i.ytimg.com/vi/gDNmhEBZAO8/maxresdefault.jpg)","metadata":{}},{"cell_type":"code","source":"#API Correlation\nplot_correlation(df)","metadata":{"execution":{"iopub.status.busy":"2022-05-21T00:26:52.436946Z","iopub.execute_input":"2022-05-21T00:26:52.437466Z","iopub.status.idle":"2022-05-21T00:26:53.172345Z","shell.execute_reply.started":"2022-05-21T00:26:52.437432Z","shell.execute_reply":"2022-05-21T00:26:53.171745Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Kendall's Tau, Pearson and Spearman's\n\n\"In this video, they briefly reviewed the Pearson correlation coefficient. Of course, that's the most popular measure of correlation, but mostly just so they have a baseline to compare to the two measures of rank correlations. Specifically, they looked at the Spearman's rank correlation and Kendall's tau rank correlation.\"\n\n\"These two are measures of ordinal correlation as opposed to a measure of cardinal correlation. In computing Kendall's tau, which has a formula that's easier to remember, they had to count up the number of concordant versus discordant pairs.\"\n\nhttps://www.youtube.com/watch?v=gDNmhEBZAO8","metadata":{}},{"cell_type":"code","source":"from sklearn.preprocessing import LabelEncoder\n\n#fill in mean for floats\nfor c in df1.columns:\n    if df1[c].dtype=='float16' or  df1[c].dtype=='float32' or  df1[c].dtype=='float64':\n        df1[c].fillna(df[c].mean())\n\n#fill in -999 for categoricals\ndf1 = df1.fillna(-999)\n# Label Encoding\nfor f in df1.columns:\n    if df1[f].dtype=='object': \n        lbl = LabelEncoder()\n        lbl.fit(list(df1[f].values))\n        df1[f] = lbl.transform(list(df1[f].values))\n        \nprint('Labelling done.')","metadata":{"execution":{"iopub.status.busy":"2022-05-21T00:28:28.081745Z","iopub.execute_input":"2022-05-21T00:28:28.082201Z","iopub.status.idle":"2022-05-21T00:28:29.685031Z","shell.execute_reply.started":"2022-05-21T00:28:28.082161Z","shell.execute_reply":"2022-05-21T00:28:29.684257Z"},"_kg_hide-output":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_correlation(df1)","metadata":{"execution":{"iopub.status.busy":"2022-05-21T00:28:48.784805Z","iopub.execute_input":"2022-05-21T00:28:48.785204Z","iopub.status.idle":"2022-05-21T00:28:49.350584Z","shell.execute_reply.started":"2022-05-21T00:28:48.785168Z","shell.execute_reply":"2022-05-21T00:28:49.349791Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Sadegh Jalalian https://www.kaggle.com/code/sadeghjalalian/prediction-of-stock-index-using-xgboost-rf-and-svm\n\nplt.figure(figsize=(12,8))\nsns.heatmap(df.describe()[1:].transpose(),\n            annot=True,linecolor=\"w\",\n            linewidth=2,cmap=sns.color_palette(\"Set2\"))\nplt.title(\"Data summary\")\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-05-21T00:29:48.526669Z","iopub.execute_input":"2022-05-21T00:29:48.526940Z","iopub.status.idle":"2022-05-21T00:29:48.863029Z","shell.execute_reply.started":"2022-05-21T00:29:48.526913Z","shell.execute_reply":"2022-05-21T00:29:48.862144Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Sadegh Jalalian https://www.kaggle.com/code/sadeghjalalian/prediction-of-stock-index-using-xgboost-rf-and-svm\n\nplt.figure(figsize=(12,8))\nsns.heatmap(df1.describe()[1:].transpose(),\n            annot=True,linecolor=\"w\",\n            linewidth=2,cmap=sns.color_palette(\"Set1\"))\nplt.title(\"Data summary\")\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-05-21T00:30:59.359171Z","iopub.execute_input":"2022-05-21T00:30:59.359446Z","iopub.status.idle":"2022-05-21T00:30:59.642659Z","shell.execute_reply.started":"2022-05-21T00:30:59.359418Z","shell.execute_reply":"2022-05-21T00:30:59.642079Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Acknowledgements:\n\n\"DataPrep is free, open-source software released under the MIT license. Anyone can reuse DataPrep code for any purpose.\"\n\n\"DataPrep is built using Pandas/Dask DataFrame and can be seamlessly integrated with other Python libraries.\"\n\n\"DataPrep is designed for computational notebooks, the most popular environment among data scientists.\"\n\n\"Dataprepare is an initiative by SFU Data Science Research Group to speed up Data Science. Dataprep.eda attempts to simplify the entire EDA process with very minimal lines of code. EDA is a very essential and time-consuming part of the data science pipeline, having a tool that eases the process is a boon.\"\n\nhttps://dataprep.ai/\n\nSadegh Jalalian https://www.kaggle.com/code/sadeghjalalian/prediction-of-stock-index-using-xgboost-rf-and-svm","metadata":{}}]}