{"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-08-26T21:44:43.074906Z","iopub.execute_input":"2022-08-26T21:44:43.075420Z","iopub.status.idle":"2022-08-26T21:44:43.114066Z","shell.execute_reply.started":"2022-08-26T21:44:43.075325Z","shell.execute_reply":"2022-08-26T21:44:43.112780Z"},"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#ANAI - Automated ML Library\n\n\"ANAI is an Automated Machine Learning Python Library that works with tabular data. It is intended to save time when performing data analysis. It will assist you with everything right from the beginning i.e Ingesting data using the inbuilt connectors, preprocessing, feature engineering, model building, model evaluation, model tuning and much more.\"\n\nhttps://www.kaggle.com/code/d4rklucif3r/introducing-anai-stroke-prediction\n\nKaggler: Arsh Anwar (a.k.a. d4rklucif3r)\n\nhttps://github.com/Revca-ANAI/ANAI\n\nwww.anai.io","metadata":{}},{"cell_type":"markdown","source":"![](https://revca-assets.s3.ap-south-1.amazonaws.com/Blue+Yellow+Futuristic+Virtual+Technology+Blog+Banner.png)https://www.kaggle.com/code/d4rklucif3r/introducing-anai-stroke-prediction","metadata":{}},{"cell_type":"code","source":"%pip install anai-opensource==0.1.2-alpha-5","metadata":{"_kg_hide-output":true,"execution":{"iopub.status.busy":"2022-08-26T21:45:16.832330Z","iopub.execute_input":"2022-08-26T21:45:16.832852Z","iopub.status.idle":"2022-08-26T21:45:51.948154Z","shell.execute_reply.started":"2022-08-26T21:45:16.832816Z","shell.execute_reply":"2022-08-26T21:45:51.946519Z"},"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import anai\nfrom anai.preprocessing import Preprocessor\nimport plotly.express as px","metadata":{"execution":{"iopub.status.busy":"2022-08-26T21:46:22.271791Z","iopub.execute_input":"2022-08-26T21:46:22.273152Z","iopub.status.idle":"2022-08-26T21:46:30.256087Z","shell.execute_reply.started":"2022-08-26T21:46:22.273081Z","shell.execute_reply":"2022-08-26T21:46:30.254770Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df4 = anai.load(df_filepath = '../input/big-data-derby-2022/nyra_start_table.csv')","metadata":{"execution":{"iopub.status.busy":"2022-08-26T21:47:17.746861Z","iopub.execute_input":"2022-08-26T21:47:17.747356Z","iopub.status.idle":"2022-08-26T21:47:21.397792Z","shell.execute_reply.started":"2022-08-26T21:47:17.747319Z","shell.execute_reply":"2022-08-26T21:47:21.396717Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df4.head(2)","metadata":{"execution":{"iopub.status.busy":"2022-08-26T21:47:36.133083Z","iopub.execute_input":"2022-08-26T21:47:36.134493Z","iopub.status.idle":"2022-08-26T21:47:36.265275Z","shell.execute_reply.started":"2022-08-26T21:47:36.134439Z","shell.execute_reply":"2022-08-26T21:47:36.264329Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Save for next time since we don't have Missing Values\n\ndf1 = prep.impute(method = 'mean')","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Save for next time since we don't have Missing Values\n\ndf1.isna().sum()","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"prep = Preprocessor(dataset = df4, target = 'odds')","metadata":{"execution":{"iopub.status.busy":"2022-08-26T21:48:28.312957Z","iopub.execute_input":"2022-08-26T21:48:28.313443Z","iopub.status.idle":"2022-08-26T21:48:28.325530Z","shell.execute_reply.started":"2022-08-26T21:48:28.313403Z","shell.execute_reply":"2022-08-26T21:48:28.323946Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"features, labels = prep.encode(split = True)","metadata":{"execution":{"iopub.status.busy":"2022-08-26T21:49:03.321899Z","iopub.execute_input":"2022-08-26T21:49:03.322404Z","iopub.status.idle":"2022-08-26T21:49:03.948185Z","shell.execute_reply.started":"2022-08-26T21:49:03.322364Z","shell.execute_reply":"2022-08-26T21:49:03.946763Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"features.head(4)","metadata":{"execution":{"iopub.status.busy":"2022-08-26T21:49:25.350272Z","iopub.execute_input":"2022-08-26T21:49:25.350721Z","iopub.status.idle":"2022-08-26T21:49:25.407731Z","shell.execute_reply.started":"2022-08-26T21:49:25.350683Z","shell.execute_reply":"2022-08-26T21:49:25.406406Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train, X_val, y_train, y_val, scaler = prep.prepare(features, labels, test_size = 0.2, random_state = 42, smote = False, k_neighbors = 3)","metadata":{"execution":{"iopub.status.busy":"2022-08-26T21:50:35.199415Z","iopub.execute_input":"2022-08-26T21:50:35.200617Z","iopub.status.idle":"2022-08-26T21:50:36.959112Z","shell.execute_reply.started":"2022-08-26T21:50:35.200555Z","shell.execute_reply":"2022-08-26T21:50:36.957025Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train.shape, X_val.shape, y_val.shape, y_train.shape","metadata":{"execution":{"iopub.status.busy":"2022-08-26T21:51:04.826320Z","iopub.execute_input":"2022-08-26T21:51:04.826774Z","iopub.status.idle":"2022-08-26T21:51:04.836312Z","shell.execute_reply.started":"2022-08-26T21:51:04.826737Z","shell.execute_reply":"2022-08-26T21:51:04.834738Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Arsh Anwar https://www.kaggle.com/code/d4rklucif3r/introducing-anai-stroke-prediction\n\nai = anai.run(filepath = '../input/big-data-derby-2022/nyra_start_table.csv', suppress_task_detection=True, task = 'regression')","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#ANAI's AutoML Pipeline\n\nBelow, I deleted xgb, so that it would takes less time since I was just trying it for the 1st time. ","metadata":{}},{"cell_type":"code","source":"#Code by Arsh Anwar https://www.kaggle.com/code/d4rklucif3r/introducing-anai-stroke-prediction\n\nai = anai.run(filepath = '../input/big-data-derby-2022/nyra_start_table.csv', target = 'odds', suppress_task_detection=True, task = 'regression',  predictor = ['ada', 'cat', 'knn', 'lgbm'])","metadata":{"execution":{"iopub.status.busy":"2022-08-26T21:58:44.465240Z","iopub.execute_input":"2022-08-26T21:58:44.466078Z","iopub.status.idle":"2022-08-26T21:59:29.055450Z","shell.execute_reply.started":"2022-08-26T21:58:44.466022Z","shell.execute_reply":"2022-08-26T21:59:29.053049Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Explainable ANAI","metadata":{}},{"cell_type":"code","source":"ai.explain('shap')","metadata":{"execution":{"iopub.status.busy":"2022-08-26T22:29:08.035980Z","iopub.execute_input":"2022-08-26T22:29:08.036446Z","iopub.status.idle":"2022-08-26T22:30:01.725167Z","shell.execute_reply.started":"2022-08-26T22:29:08.036406Z","shell.execute_reply":"2022-08-26T22:30:01.722901Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Explainable ANAI","metadata":{}},{"cell_type":"code","source":"ai.explain('perm')","metadata":{"execution":{"iopub.status.busy":"2022-08-26T22:01:34.630624Z","iopub.execute_input":"2022-08-26T22:01:34.631663Z","iopub.status.idle":"2022-08-26T22:01:40.760884Z","shell.execute_reply.started":"2022-08-26T22:01:34.631603Z","shell.execute_reply":"2022-08-26T22:01:40.759080Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#LB of the chosen models","metadata":{}},{"cell_type":"code","source":"ai.result()","metadata":{"execution":{"iopub.status.busy":"2022-08-26T22:02:17.502891Z","iopub.execute_input":"2022-08-26T22:02:17.503362Z","iopub.status.idle":"2022-08-26T22:02:17.536267Z","shell.execute_reply.started":"2022-08-26T22:02:17.503312Z","shell.execute_reply":"2022-08-26T22:02:17.534614Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Acknowledgements:\n\nArsh Anwar (d4rklucif3r)\n\nhttps://www.kaggle.com/code/d4rklucif3r/introducing-anai-stroke-prediction\n\nhttps://www.kaggle.com/code/d4rklucif3r/dangerous-or-not-anai-viz\n\nwww.anai.io\n\nhttps://github.com/Revca-ANAI/ANAI","metadata":{}}]}