{"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)\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\nimport plotly.express as px\nimport plotly.graph_objs as go\nimport plotly\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","_kg_hide-input":true,"_kg_hide-output":true,"execution":{"iopub.status.busy":"2022-03-12T22:48:24.923145Z","iopub.execute_input":"2022-03-12T22:48:24.923540Z","iopub.status.idle":"2022-03-12T22:48:27.080986Z","shell.execute_reply.started":"2022-03-12T22:48:24.923445Z","shell.execute_reply":"2022-03-12T22:48:27.080023Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<center style=\"font-family:verdana;\"><h1 style=\"font-size:200%; padding: 10px; background: #001f3f;\"><b style=\"color:#03e8fc;\">Octosport and Sportmonks</b></h1></center>\n\n\"Octosport and Sportmonks are proud to present their first football prediction competition. Do you know how to code in python and are passionate about football? Do you want to test your knowledge in machine learning, sequence learning, or neural networks? Do you want to beat the bookmaker's performance? You are at the right place.\"\n\nhttps://www.kaggle.com/c/football-match-probability-prediction/overview/description\n\nOCTOSPORT Prediction Football API\n\n\"Octosport is a data provider focused on football prediction and analytics powered with machine learning.\"\n\nhttps://www.octosport.io/\n\nSPORTMONKS - Fast and Reliable Sports Data and APIs.\n\n\"Building your Sports Data applications starts here with Sportmonks’ Sports APIs.\"\n\nhttps://www.sportmonks.com/\n\n\"EVALML includes several optional dependencies. The xgboost and catboost packages support pipelines built around those modeling libraries. The plotly and ipywidgets packages support plotting functionality in automl searches. These dependencies are recommended, and are included with EvalML by default but are not required in order to install and use EvalML.\"\n\nhttps://evalml.alteryx.com/en/stable/install.html\n\nI don't know how to code and I'm not passionate for anything. Though I'm curious about any data.","metadata":{}},{"cell_type":"markdown","source":"![](https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcScasFLYZG-sgwmQ5X-_V6r5Wt9Y-eo7N5ICg&usqp=CAU)m.facebook.com","metadata":{}},{"cell_type":"code","source":"train = pd.read_csv(\"/kaggle/input/football-match-probability-prediction/train.csv\")\ntest = pd.read_csv(\"/kaggle/input/football-match-probability-prediction/test.csv\")\nsub = pd.read_csv(\"/kaggle/input/football-match-probability-prediction/sample_submission.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-03-12T22:48:27.084658Z","iopub.execute_input":"2022-03-12T22:48:27.084881Z","iopub.status.idle":"2022-03-12T22:48:37.291480Z","shell.execute_reply.started":"2022-03-12T22:48:27.084855Z","shell.execute_reply":"2022-03-12T22:48:37.290827Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.set_option('display.max_columns', None)\ntrain.head()","metadata":{"execution":{"iopub.status.busy":"2022-03-12T22:48:39.284452Z","iopub.execute_input":"2022-03-12T22:48:39.284977Z","iopub.status.idle":"2022-03-12T22:48:39.489965Z","shell.execute_reply.started":"2022-03-12T22:48:39.284940Z","shell.execute_reply":"2022-03-12T22:48:39.489120Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.shape","metadata":{"execution":{"iopub.status.busy":"2022-03-12T22:48:45.846689Z","iopub.execute_input":"2022-03-12T22:48:45.847094Z","iopub.status.idle":"2022-03-12T22:48:45.852607Z","shell.execute_reply.started":"2022-03-12T22:48:45.847062Z","shell.execute_reply":"2022-03-12T22:48:45.851784Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-03-12T22:48:51.245496Z","iopub.execute_input":"2022-03-12T22:48:51.246162Z","iopub.status.idle":"2022-03-12T22:48:51.604065Z","shell.execute_reply.started":"2022-03-12T22:48:51.246119Z","shell.execute_reply":"2022-03-12T22:48:51.603193Z"},"_kg_hide-output":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"##Code by Taha07  https://www.kaggle.com/taha07/data-scientists-jobs-analysis-visualization/notebook\n\nfrom wordcloud import WordCloud\nfrom wordcloud import STOPWORDS\nstopwords = set(STOPWORDS)\nwordcloud = WordCloud(background_color = 'green',\n                      height =2000,\n                      width = 2000\n                     ).generate(str(train[\"home_team_name\"]))\nplt.rcParams['figure.figsize'] = (12,12)\nplt.axis(\"off\")\nplt.imshow(wordcloud)\nplt.title(\"Football Home Team Name\")\nplt.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-12T22:48:58.247311Z","iopub.execute_input":"2022-03-12T22:48:58.247578Z","iopub.status.idle":"2022-03-12T22:49:02.559056Z","shell.execute_reply.started":"2022-03-12T22:48:58.247551Z","shell.execute_reply":"2022-03-12T22:49:02.558313Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"##Code by Taha07  https://www.kaggle.com/taha07/data-scientists-jobs-analysis-visualization/notebook\n\nfrom wordcloud import WordCloud\nfrom wordcloud import STOPWORDS\nstopwords = set(STOPWORDS)\nwordcloud = WordCloud(background_color = 'orange',\n                      height =2000,\n                      width = 2000\n                     ).generate(str(train[\"away_team_name\"]))\nplt.rcParams['figure.figsize'] = (12,12)\nplt.axis(\"off\")\nplt.imshow(wordcloud)\nplt.title(\"Football Away Team Name\")\nplt.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-12T22:49:05.431474Z","iopub.execute_input":"2022-03-12T22:49:05.431800Z","iopub.status.idle":"2022-03-12T22:49:09.201878Z","shell.execute_reply.started":"2022-03-12T22:49:05.431769Z","shell.execute_reply":"2022-03-12T22:49:09.201073Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"##Code by Taha07  https://www.kaggle.com/taha07/data-scientists-jobs-analysis-visualization/notebook\n\nfrom wordcloud import WordCloud\nfrom wordcloud import STOPWORDS\nstopwords = set(STOPWORDS)\nwordcloud = WordCloud(background_color = 'purple',\n                      height =2000,\n                      width = 2000\n                     ).generate(str(train[\"league_name\"]))\nplt.rcParams['figure.figsize'] = (12,12)\nplt.axis(\"off\")\nplt.imshow(wordcloud)\nplt.title(\"Football League Name\")\nplt.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-12T22:49:11.343767Z","iopub.execute_input":"2022-03-12T22:49:11.344059Z","iopub.status.idle":"2022-03-12T22:49:14.159303Z","shell.execute_reply.started":"2022-03-12T22:49:11.344025Z","shell.execute_reply":"2022-03-12T22:49:14.158383Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"![](https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR8cVNaO55ZHaQhk19HYKNHNyf939SeEb7gnA&usqp=CAU)m.facebook.com","metadata":{}},{"cell_type":"code","source":"#Codes by Pooja Jain https://www.kaggle.com/jainpooja/av-guided-hackathon-predict-youtube-likes/notebook\n\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\ntext_cols = ['target', 'home_team_name', 'away_team_name', 'league_name']\n\nfrom wordcloud import WordCloud, STOPWORDS\n\nwc = WordCloud(stopwords = set(list(STOPWORDS) + ['|']), random_state = 42, background_color='lightblue',colormap=\"Dark2\",)\nfig, axes = plt.subplots(2,2, figsize=(20, 12))\naxes = [ax for axes_row in axes for ax in axes_row]\n\nfor i, c in enumerate(text_cols):\n  op = wc.generate(str(train[c]))\n  _ = axes[i].imshow(op)\n  _ = axes[i].set_title(c.upper(), fontsize=24)\n  _ = axes[i].axis('off')\n\n#_ = fig.delaxes(axes[3])\n_ = axes[i].axis('off')","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-12T22:49:17.243406Z","iopub.execute_input":"2022-03-12T22:49:17.243680Z","iopub.status.idle":"2022-03-12T22:49:18.224802Z","shell.execute_reply.started":"2022-03-12T22:49:17.243651Z","shell.execute_reply":"2022-03-12T22:49:18.224122Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install librosa --ignore-installed llvmlite","metadata":{"_kg_hide-output":true,"execution":{"iopub.status.busy":"2022-03-12T22:49:25.279228Z","iopub.execute_input":"2022-03-12T22:49:25.279745Z","iopub.status.idle":"2022-03-12T22:50:03.987469Z","shell.execute_reply.started":"2022-03-12T22:49:25.279686Z","shell.execute_reply":"2022-03-12T22:50:03.986466Z"},"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install evalml","metadata":{"_kg_hide-output":true,"execution":{"iopub.status.busy":"2022-03-12T22:50:15.852726Z","iopub.execute_input":"2022-03-12T22:50:15.853068Z","iopub.status.idle":"2022-03-12T22:50:56.299960Z","shell.execute_reply.started":"2022-03-12T22:50:15.853040Z","shell.execute_reply":"2022-03-12T22:50:56.298980Z"},"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# categorical features with missing values\ncategorical_nan = [feature for feature in train.columns if train[feature].isna().sum()>0 and train[feature].dtypes=='O']\nprint(categorical_nan)","metadata":{"execution":{"iopub.status.busy":"2022-03-12T22:51:09.716467Z","iopub.execute_input":"2022-03-12T22:51:09.716742Z","iopub.status.idle":"2022-03-12T22:51:10.142669Z","shell.execute_reply.started":"2022-03-12T22:51:09.716715Z","shell.execute_reply":"2022-03-12T22:51:10.141807Z"},"_kg_hide-output":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# replacing missing values in categorical features\nfor feature in categorical_nan:\n    train[feature] = train[feature].fillna('None')","metadata":{"execution":{"iopub.status.busy":"2022-03-12T22:51:14.935852Z","iopub.execute_input":"2022-03-12T22:51:14.936132Z","iopub.status.idle":"2022-03-12T22:51:15.278826Z","shell.execute_reply.started":"2022-03-12T22:51:14.936103Z","shell.execute_reply":"2022-03-12T22:51:15.278110Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train[categorical_nan].isna().sum()","metadata":{"_kg_hide-output":true,"execution":{"iopub.status.busy":"2022-03-12T22:51:19.748356Z","iopub.execute_input":"2022-03-12T22:51:19.748615Z","iopub.status.idle":"2022-03-12T22:51:20.085012Z","shell.execute_reply.started":"2022-03-12T22:51:19.748588Z","shell.execute_reply":"2022-03-12T22:51:20.084232Z"},"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Lets first handle numerical features with nan value\nnumerical_nan = [feature for feature in train.columns if train[feature].isna().sum()>1 and train[feature].dtypes!='O']\nnumerical_nan","metadata":{"_kg_hide-output":true,"execution":{"iopub.status.busy":"2022-03-12T22:51:33.117331Z","iopub.execute_input":"2022-03-12T22:51:33.117634Z","iopub.status.idle":"2022-03-12T22:51:33.528272Z","shell.execute_reply.started":"2022-03-12T22:51:33.117603Z","shell.execute_reply":"2022-03-12T22:51:33.527442Z"},"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train[numerical_nan].isna().sum()","metadata":{"_kg_hide-output":true,"execution":{"iopub.status.busy":"2022-03-12T22:51:44.117661Z","iopub.execute_input":"2022-03-12T22:51:44.117934Z","iopub.status.idle":"2022-03-12T22:51:44.221511Z","shell.execute_reply.started":"2022-03-12T22:51:44.117899Z","shell.execute_reply":"2022-03-12T22:51:44.220566Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"## Replacing the numerical Missing Values\n\nfor feature in numerical_nan:\n    ## We will replace by using median since there are outliers\n    median_value=train[feature].median()\n    \n    train[feature].fillna(median_value,inplace=True)\n    \ntrain[numerical_nan].isnull().sum()","metadata":{"_kg_hide-output":true,"execution":{"iopub.status.busy":"2022-03-12T22:51:54.822578Z","iopub.execute_input":"2022-03-12T22:51:54.822836Z","iopub.status.idle":"2022-03-12T22:51:55.208373Z","shell.execute_reply.started":"2022-03-12T22:51:54.822805Z","shell.execute_reply":"2022-03-12T22:51:55.207707Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Split our Data into Dependent i.e our Target variable and independent variable","metadata":{}},{"cell_type":"code","source":"#Code by Hamed Etezadi https://www.kaggle.com/hamedetezadi/heart-attack-risk-prediction-automl/notebook\n\nx= train.iloc[:,:-1]\nx","metadata":{"execution":{"iopub.status.busy":"2022-03-12T22:52:04.790414Z","iopub.execute_input":"2022-03-12T22:52:04.790721Z","iopub.status.idle":"2022-03-12T22:52:05.125186Z","shell.execute_reply.started":"2022-03-12T22:52:04.790690Z","shell.execute_reply":"2022-03-12T22:52:05.124623Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Label Encoding","metadata":{}},{"cell_type":"code","source":"from sklearn.preprocessing import LabelEncoder\nlbl= LabelEncoder()\n\ny= train.iloc[:,-1:]\ny= lbl.fit_transform(y)\ny","metadata":{"execution":{"iopub.status.busy":"2022-03-12T22:52:11.698522Z","iopub.execute_input":"2022-03-12T22:52:11.699048Z","iopub.status.idle":"2022-03-12T22:52:11.766136Z","shell.execute_reply.started":"2022-03-12T22:52:11.699013Z","shell.execute_reply":"2022-03-12T22:52:11.765359Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Import Eval ML Library","metadata":{}},{"cell_type":"code","source":"import evalml","metadata":{"execution":{"iopub.status.busy":"2022-03-12T22:53:11.958840Z","iopub.execute_input":"2022-03-12T22:53:11.959109Z","iopub.status.idle":"2022-03-12T22:53:11.962872Z","shell.execute_reply.started":"2022-03-12T22:53:11.959082Z","shell.execute_reply":"2022-03-12T22:53:11.962046Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train, X_test, y_train, y_test = evalml.preprocessing.split_data(x, y, problem_type='regression')","metadata":{"execution":{"iopub.status.busy":"2022-03-12T22:53:21.404581Z","iopub.execute_input":"2022-03-12T22:53:21.404875Z","iopub.status.idle":"2022-03-12T22:53:37.155833Z","shell.execute_reply.started":"2022-03-12T22:53:21.404841Z","shell.execute_reply":"2022-03-12T22:53:37.155137Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"evalml.problem_types.ProblemTypes.all_problem_types","metadata":{"_kg_hide-output":true,"execution":{"iopub.status.busy":"2022-03-12T22:53:53.938136Z","iopub.execute_input":"2022-03-12T22:53:53.939160Z","iopub.status.idle":"2022-03-12T22:53:53.944283Z","shell.execute_reply.started":"2022-03-12T22:53:53.939117Z","shell.execute_reply":"2022-03-12T22:53:53.943748Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#The evaluation metric for this competition is a multinomial Log-Loss. The log-loss measure the quality of the predicted probabilities. Check out our blog post if you want to know more about it.","metadata":{}},{"cell_type":"code","source":"from evalml.data_checks import DefaultDataChecks\n\ndata_checks = DefaultDataChecks(\"regression\", \"log loss binary\")\ndata_checks.validate(X_train, y_train)","metadata":{"execution":{"iopub.status.busy":"2022-03-12T22:57:30.595114Z","iopub.execute_input":"2022-03-12T22:57:30.596818Z","iopub.status.idle":"2022-03-12T22:57:43.307570Z","shell.execute_reply.started":"2022-03-12T22:57:30.596747Z","shell.execute_reply":"2022-03-12T22:57:43.306621Z"},"_kg_hide-output":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"![](https://i.pinimg.com/736x/79/0b/86/790b868521fb60f86d5792072ffe9bd8.jpg)in.pinterest.com","metadata":{}},{"cell_type":"markdown","source":"#Running the Auto ML to select best Algorithm","metadata":{}},{"cell_type":"code","source":"from evalml.automl import AutoMLSearch\nautoml = AutoMLSearch(X_train=X_train, y_train=y_train, problem_type='regression')\nautoml.search()","metadata":{"execution":{"iopub.status.busy":"2022-03-12T22:58:15.707520Z","iopub.execute_input":"2022-03-12T22:58:15.708129Z","iopub.status.idle":"2022-03-12T23:19:48.068918Z","shell.execute_reply.started":"2022-03-12T22:58:15.708084Z","shell.execute_reply":"2022-03-12T23:19:48.067862Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"That snippet above takes a lot of time and don't provide Any Output. Models rankings below.","metadata":{}},{"cell_type":"code","source":"automl.rankings","metadata":{"execution":{"iopub.status.busy":"2022-03-12T23:23:37.926321Z","iopub.execute_input":"2022-03-12T23:23:37.926689Z","iopub.status.idle":"2022-03-12T23:23:37.967355Z","shell.execute_reply.started":"2022-03-12T23:23:37.926651Z","shell.execute_reply":"2022-03-12T23:23:37.966362Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"automl.best_pipeline","metadata":{"execution":{"iopub.status.busy":"2022-03-12T23:24:06.363303Z","iopub.execute_input":"2022-03-12T23:24:06.363629Z","iopub.status.idle":"2022-03-12T23:24:06.382227Z","shell.execute_reply.started":"2022-03-12T23:24:06.363595Z","shell.execute_reply":"2022-03-12T23:24:06.381475Z"},"_kg_hide-output":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"best_pipeline=automl.best_pipeline","metadata":{"execution":{"iopub.status.busy":"2022-03-12T23:24:12.104167Z","iopub.execute_input":"2022-03-12T23:24:12.104659Z","iopub.status.idle":"2022-03-12T23:24:12.109732Z","shell.execute_reply.started":"2022-03-12T23:24:12.104621Z","shell.execute_reply":"2022-03-12T23:24:12.108598Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"automl.describe_pipeline(automl.rankings.iloc[0][\"id\"])","metadata":{"execution":{"iopub.status.busy":"2022-03-12T23:24:17.571828Z","iopub.execute_input":"2022-03-12T23:24:17.572081Z","iopub.status.idle":"2022-03-12T23:24:17.654211Z","shell.execute_reply.started":"2022-03-12T23:24:17.572055Z","shell.execute_reply":"2022-03-12T23:24:17.653383Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Since log loss is not an option and log loss binary resulted in Invalid objective I changed to those that returned the best scores.","metadata":{}},{"cell_type":"markdown","source":"#Red Card? Not yet.","metadata":{}},{"cell_type":"markdown","source":"![](https://i.pinimg.com/originals/58/39/9a/58399a16d19758c2a95170f0f9203c8a.gif)pinterest.com","metadata":{}},{"cell_type":"code","source":"best_pipeline.score(X_test, y_test, objectives=[\"R2\",\"ExpVariance\",\"MSE\",\"MAE\"]) #original was auc\",\"f1\",\"Precision\",\"Recall","metadata":{"execution":{"iopub.status.busy":"2022-03-12T23:34:18.388140Z","iopub.execute_input":"2022-03-12T23:34:18.388796Z","iopub.status.idle":"2022-03-12T23:34:22.951323Z","shell.execute_reply.started":"2022-03-12T23:34:18.388760Z","shell.execute_reply":"2022-03-12T23:34:22.950455Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"automl_logloss = AutoMLSearch(X_train=X_train, y_train=y_train,\n                          problem_type='regression',\n                          objective='R2', #there is no Log Loss\n                          additional_objectives=['MSE', 'MAE'],\n                          max_batches=1,\n                          optimize_thresholds=True)\n\nautoml_logloss.search()","metadata":{"execution":{"iopub.status.busy":"2022-03-12T23:36:49.761574Z","iopub.execute_input":"2022-03-12T23:36:49.761927Z","iopub.status.idle":"2022-03-12T23:58:25.922986Z","shell.execute_reply.started":"2022-03-12T23:36:49.761891Z","shell.execute_reply":"2022-03-12T23:58:25.921948Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#More time waiting. And I didn't applied Log Loss, which is the metric of the Competition.","metadata":{}},{"cell_type":"code","source":"automl_logloss.rankings","metadata":{"execution":{"iopub.status.busy":"2022-03-13T00:04:16.058138Z","iopub.execute_input":"2022-03-13T00:04:16.059314Z","iopub.status.idle":"2022-03-13T00:04:16.100186Z","shell.execute_reply.started":"2022-03-13T00:04:16.059258Z","shell.execute_reply":"2022-03-13T00:04:16.099290Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"automl_logloss.describe_pipeline(automl_logloss.rankings.iloc[0][\"id\"])","metadata":{"execution":{"iopub.status.busy":"2022-03-13T00:04:23.306693Z","iopub.execute_input":"2022-03-13T00:04:23.307416Z","iopub.status.idle":"2022-03-13T00:04:23.372865Z","shell.execute_reply.started":"2022-03-13T00:04:23.307364Z","shell.execute_reply":"2022-03-13T00:04:23.372021Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"best_pipeline_logloss = automl_logloss.best_pipeline","metadata":{"execution":{"iopub.status.busy":"2022-03-13T00:10:39.144048Z","iopub.execute_input":"2022-03-13T00:10:39.144357Z","iopub.status.idle":"2022-03-13T00:10:39.149365Z","shell.execute_reply.started":"2022-03-13T00:10:39.144330Z","shell.execute_reply":"2022-03-13T00:10:39.148685Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# get the score on holdout data\nbest_pipeline_logloss.score(X_test, y_test,  objectives=[\"R2\"])","metadata":{"execution":{"iopub.status.busy":"2022-03-13T00:10:49.145388Z","iopub.execute_input":"2022-03-13T00:10:49.146229Z","iopub.status.idle":"2022-03-13T00:10:53.958953Z","shell.execute_reply.started":"2022-03-13T00:10:49.146186Z","shell.execute_reply":"2022-03-13T00:10:53.958112Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Save the model","metadata":{}},{"cell_type":"code","source":"best_pipeline.save(\"model.pkl\")","metadata":{"execution":{"iopub.status.busy":"2022-03-13T00:11:51.185319Z","iopub.execute_input":"2022-03-13T00:11:51.185680Z","iopub.status.idle":"2022-03-13T00:11:51.243130Z","shell.execute_reply.started":"2022-03-13T00:11:51.185633Z","shell.execute_reply":"2022-03-13T00:11:51.242121Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Loading the Model","metadata":{}},{"cell_type":"code","source":"final_model=automl.load('model.pkl')","metadata":{"execution":{"iopub.status.busy":"2022-03-13T00:11:58.007065Z","iopub.execute_input":"2022-03-13T00:11:58.007836Z","iopub.status.idle":"2022-03-13T00:11:58.041875Z","shell.execute_reply.started":"2022-03-13T00:11:58.007780Z","shell.execute_reply":"2022-03-13T00:11:58.040807Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"final_model.predict(X_test)","metadata":{"execution":{"iopub.status.busy":"2022-03-13T00:14:30.398894Z","iopub.execute_input":"2022-03-13T00:14:30.399230Z","iopub.status.idle":"2022-03-13T00:14:35.184955Z","shell.execute_reply.started":"2022-03-13T00:14:30.399195Z","shell.execute_reply":"2022-03-13T00:14:35.184059Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"AttributeError: 'RegressionPipeline' object has no attribute 'predict_proba'\n\nIf you are in a regression setting, just replace predict_proba with predict.\n\nhttps://stackoverflow.com/questions/58299984/attributeerror-linearregression-object-has-no-attribute-predict-proba","metadata":{}},{"cell_type":"markdown","source":"#Nani'S Red Card/ Tarjeta Roja\n\n![](https://c.tenor.com/eBOys8RU95gAAAAC/nani-red-card.gif)","metadata":{}},{"cell_type":"markdown","source":"#Acknowledgement: \n\nHamed Etezadi  https://www.kaggle.com/hamedetezadi/heart-attack-risk-prediction-automl/notebook","metadata":{}}]}