{"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":"markdown","source":"![lll](https://user-images.githubusercontent.com/50532530/121784795-9ef00480-cbd3-11eb-8df9-22a12e5608c5.PNG)","metadata":{"execution":{"iopub.status.busy":"2021-06-12T17:43:51.278627Z","iopub.execute_input":"2021-06-12T17:43:51.278988Z","iopub.status.idle":"2021-06-12T17:43:52.017830Z","shell.execute_reply.started":"2021-06-12T17:43:51.278938Z","shell.execute_reply":"2021-06-12T17:43:52.016682Z"}}},{"cell_type":"markdown","source":"# Imports","metadata":{}},{"cell_type":"code","source":"import numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport os\n!pip install h2o\nimport pickle\n\nimport h2o\nfrom h2o.automl import H2OAutoML","metadata":{"execution":{"iopub.status.busy":"2021-06-12T17:49:49.654408Z","iopub.execute_input":"2021-06-12T17:49:49.654781Z","iopub.status.idle":"2021-06-12T17:49:56.038789Z","shell.execute_reply.started":"2021-06-12T17:49:49.654746Z","shell.execute_reply":"2021-06-12T17:49:56.037665Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Lets load the data and see it","metadata":{}},{"cell_type":"code","source":"df=pd.read_csv('../input/tabular-playground-series-jun-2021/train.csv')","metadata":{"execution":{"iopub.status.busy":"2021-06-12T17:49:56.041131Z","iopub.execute_input":"2021-06-12T17:49:56.041433Z","iopub.status.idle":"2021-06-12T17:49:57.100349Z","shell.execute_reply.started":"2021-06-12T17:49:56.041398Z","shell.execute_reply":"2021-06-12T17:49:57.099522Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.head()","metadata":{"execution":{"iopub.status.busy":"2021-06-12T17:49:57.101931Z","iopub.execute_input":"2021-06-12T17:49:57.102395Z","iopub.status.idle":"2021-06-12T17:49:57.121418Z","shell.execute_reply.started":"2021-06-12T17:49:57.102346Z","shell.execute_reply":"2021-06-12T17:49:57.120338Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.describe()","metadata":{"execution":{"iopub.status.busy":"2021-06-12T17:49:57.122855Z","iopub.execute_input":"2021-06-12T17:49:57.123172Z","iopub.status.idle":"2021-06-12T17:49:57.673471Z","shell.execute_reply.started":"2021-06-12T17:49:57.123143Z","shell.execute_reply":"2021-06-12T17:49:57.672495Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['target'].unique()","metadata":{"execution":{"iopub.status.busy":"2021-06-12T17:49:57.674562Z","iopub.execute_input":"2021-06-12T17:49:57.674830Z","iopub.status.idle":"2021-06-12T17:49:57.693884Z","shell.execute_reply.started":"2021-06-12T17:49:57.674804Z","shell.execute_reply":"2021-06-12T17:49:57.692908Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# H2O modelling ","metadata":{}},{"cell_type":"code","source":"h2o.init(\n    nthreads=-1,     # number of threads when launching a new H2O server\n    max_mem_size=12  # in gigabytes\n)","metadata":{"execution":{"iopub.status.busy":"2021-06-12T17:49:57.695250Z","iopub.execute_input":"2021-06-12T17:49:57.695535Z","iopub.status.idle":"2021-06-12T17:49:57.737642Z","shell.execute_reply.started":"2021-06-12T17:49:57.695506Z","shell.execute_reply":"2021-06-12T17:49:57.736709Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df = pd.read_csv('../input/tabular-playground-series-jun-2021/train.csv')\ntest_df = pd.read_csv('../input/tabular-playground-series-jun-2021/test.csv')","metadata":{"execution":{"iopub.status.busy":"2021-06-12T17:49:57.738778Z","iopub.execute_input":"2021-06-12T17:49:57.739076Z","iopub.status.idle":"2021-06-12T17:49:59.147696Z","shell.execute_reply.started":"2021-06-12T17:49:57.739046Z","shell.execute_reply":"2021-06-12T17:49:59.146736Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_train=train_df['target']\nX_train=train_df.drop(['target','id'],axis=1)","metadata":{"execution":{"iopub.status.busy":"2021-06-12T17:49:59.150165Z","iopub.execute_input":"2021-06-12T17:49:59.150471Z","iopub.status.idle":"2021-06-12T17:49:59.192612Z","shell.execute_reply.started":"2021-06-12T17:49:59.150441Z","shell.execute_reply":"2021-06-12T17:49:59.191539Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_y_train_h = h2o.H2OFrame(pd.concat([X_train, y_train], axis='columns'))\n\n# ^ the target column should have categorical type for classification tasks\n#   (numerical type for regression tasks)\n\nX_test_h = h2o.H2OFrame(test_df)\n\nX_y_train_h.describe()","metadata":{"execution":{"iopub.status.busy":"2021-06-12T17:49:59.195055Z","iopub.execute_input":"2021-06-12T17:49:59.195490Z","iopub.status.idle":"2021-06-12T17:50:11.156927Z","shell.execute_reply.started":"2021-06-12T17:49:59.195443Z","shell.execute_reply":"2021-06-12T17:50:11.155865Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_y_train_h.head()","metadata":{"execution":{"iopub.status.busy":"2021-06-12T17:50:11.158193Z","iopub.execute_input":"2021-06-12T17:50:11.158466Z","iopub.status.idle":"2021-06-12T17:50:11.258029Z","shell.execute_reply.started":"2021-06-12T17:50:11.158437Z","shell.execute_reply":"2021-06-12T17:50:11.257011Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"feature_cols=X_train.columns","metadata":{"execution":{"iopub.status.busy":"2021-06-12T17:50:11.259611Z","iopub.execute_input":"2021-06-12T17:50:11.260300Z","iopub.status.idle":"2021-06-12T17:50:11.265112Z","shell.execute_reply.started":"2021-06-12T17:50:11.260251Z","shell.execute_reply":"2021-06-12T17:50:11.263871Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"feature_cols=list(feature_cols)","metadata":{"execution":{"iopub.status.busy":"2021-06-12T17:50:11.266790Z","iopub.execute_input":"2021-06-12T17:50:11.267614Z","iopub.status.idle":"2021-06-12T17:50:11.278629Z","shell.execute_reply.started":"2021-06-12T17:50:11.267568Z","shell.execute_reply":"2021-06-12T17:50:11.277478Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Load the pretrained models","metadata":{}},{"cell_type":"code","source":"lb = h2o.import_file(path=\"../input/auto-ml-output/aml_leaderboard.h2o\")\n\nlb.head(rows=10)","metadata":{"execution":{"iopub.status.busy":"2021-06-12T17:50:11.280538Z","iopub.execute_input":"2021-06-12T17:50:11.281391Z","iopub.status.idle":"2021-06-12T17:50:11.594243Z","shell.execute_reply.started":"2021-06-12T17:50:11.281322Z","shell.execute_reply":"2021-06-12T17:50:11.593354Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"H2O  = h2o.load_model(\"../input/auto-ml-output/StackedEnsemble_BestOfFamily_AutoML_20210611_175001\")","metadata":{"execution":{"iopub.status.busy":"2021-06-12T17:50:11.597323Z","iopub.execute_input":"2021-06-12T17:50:11.597602Z","iopub.status.idle":"2021-06-12T17:50:13.334202Z","shell.execute_reply.started":"2021-06-12T17:50:11.597575Z","shell.execute_reply":"2021-06-12T17:50:13.333303Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Predict it !","metadata":{}},{"cell_type":"code","source":"pred=H2O.predict(X_test_h)","metadata":{"execution":{"iopub.status.busy":"2021-06-12T17:50:13.335718Z","iopub.execute_input":"2021-06-12T17:50:13.336471Z","iopub.status.idle":"2021-06-12T17:50:33.175843Z","shell.execute_reply.started":"2021-06-12T17:50:13.336422Z","shell.execute_reply":"2021-06-12T17:50:33.174870Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"h20_predictions_df = pred.as_data_frame()","metadata":{"execution":{"iopub.status.busy":"2021-06-12T17:50:33.177070Z","iopub.execute_input":"2021-06-12T17:50:33.177356Z","iopub.status.idle":"2021-06-12T17:50:34.715975Z","shell.execute_reply.started":"2021-06-12T17:50:33.177327Z","shell.execute_reply":"2021-06-12T17:50:34.714988Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"h20_predictions_df.head()","metadata":{"execution":{"iopub.status.busy":"2021-06-12T17:50:34.717395Z","iopub.execute_input":"2021-06-12T17:50:34.717790Z","iopub.status.idle":"2021-06-12T17:50:34.734157Z","shell.execute_reply.started":"2021-06-12T17:50:34.717748Z","shell.execute_reply":"2021-06-12T17:50:34.733217Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub=pd.read_csv(\"../input/tabular-playground-series-jun-2021/sample_submission.csv\")","metadata":{"execution":{"iopub.status.busy":"2021-06-12T17:50:34.735685Z","iopub.execute_input":"2021-06-12T17:50:34.736121Z","iopub.status.idle":"2021-06-12T17:50:34.901914Z","shell.execute_reply.started":"2021-06-12T17:50:34.736058Z","shell.execute_reply":"2021-06-12T17:50:34.901049Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub['id']=test_df['id']","metadata":{"execution":{"iopub.status.busy":"2021-06-12T17:50:34.921500Z","iopub.execute_input":"2021-06-12T17:50:34.921816Z","iopub.status.idle":"2021-06-12T17:50:34.933112Z","shell.execute_reply.started":"2021-06-12T17:50:34.921784Z","shell.execute_reply":"2021-06-12T17:50:34.932232Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"h20_predictions_df['predict']=test_df['id']","metadata":{"execution":{"iopub.status.busy":"2021-06-12T17:50:34.934192Z","iopub.execute_input":"2021-06-12T17:50:34.934469Z","iopub.status.idle":"2021-06-12T17:50:34.945849Z","shell.execute_reply.started":"2021-06-12T17:50:34.934443Z","shell.execute_reply":"2021-06-12T17:50:34.944707Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"h20_predictions_df=h20_predictions_df.rename(columns = {'predict': 'id'}, inplace = False)","metadata":{"execution":{"iopub.status.busy":"2021-06-12T17:50:34.973545Z","iopub.execute_input":"2021-06-12T17:50:34.973838Z","iopub.status.idle":"2021-06-12T17:50:34.983253Z","shell.execute_reply.started":"2021-06-12T17:50:34.973810Z","shell.execute_reply":"2021-06-12T17:50:34.982231Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# saving the predictions","metadata":{}},{"cell_type":"code","source":"h20_predictions_df.head()","metadata":{"execution":{"iopub.status.busy":"2021-06-12T17:50:34.984505Z","iopub.execute_input":"2021-06-12T17:50:34.984865Z","iopub.status.idle":"2021-06-12T17:50:35.006703Z","shell.execute_reply.started":"2021-06-12T17:50:34.984831Z","shell.execute_reply":"2021-06-12T17:50:35.005774Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"h20_predictions_df.to_csv(\"submission.csv\",index=False)","metadata":{"execution":{"iopub.status.busy":"2021-06-12T17:50:35.007874Z","iopub.execute_input":"2021-06-12T17:50:35.008172Z","iopub.status.idle":"2021-06-12T17:50:36.828599Z","shell.execute_reply.started":"2021-06-12T17:50:35.008143Z","shell.execute_reply":"2021-06-12T17:50:36.827478Z"},"trusted":true},"execution_count":null,"outputs":[]}]}