{"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":"import numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport seaborn as sns","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-08-05T17:25:13.322424Z","iopub.execute_input":"2022-08-05T17:25:13.322849Z","iopub.status.idle":"2022-08-05T17:25:13.329725Z","shell.execute_reply.started":"2022-08-05T17:25:13.322809Z","shell.execute_reply":"2022-08-05T17:25:13.328608Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_path = \"../input/tabular-playground-series-aug-2022/train.csv\"\ntest_path = \"../input/tabular-playground-series-aug-2022/test.csv\"\nsubmission_path = \"../input/tabular-playground-series-aug-2022/sample_submission.csv\"","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:13.350160Z","iopub.execute_input":"2022-08-05T17:25:13.351534Z","iopub.status.idle":"2022-08-05T17:25:13.356852Z","shell.execute_reply.started":"2022-08-05T17:25:13.351484Z","shell.execute_reply":"2022-08-05T17:25:13.355975Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df = pd.read_csv(train_path)\ntest_df = pd.read_csv(test_path)\nsub_df = pd.read_csv(submission_path)","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:13.382171Z","iopub.execute_input":"2022-08-05T17:25:13.382762Z","iopub.status.idle":"2022-08-05T17:25:13.591539Z","shell.execute_reply.started":"2022-08-05T17:25:13.382726Z","shell.execute_reply":"2022-08-05T17:25:13.590318Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.info()","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:13.594288Z","iopub.execute_input":"2022-08-05T17:25:13.594794Z","iopub.status.idle":"2022-08-05T17:25:13.620631Z","shell.execute_reply.started":"2022-08-05T17:25:13.594746Z","shell.execute_reply":"2022-08-05T17:25:13.619351Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"missing = train_df.isnull().sum()\nmissing = missing[missing > 0]\nmissing.sort_values(inplace = True)","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:13.622338Z","iopub.execute_input":"2022-08-05T17:25:13.623240Z","iopub.status.idle":"2022-08-05T17:25:13.638519Z","shell.execute_reply.started":"2022-08-05T17:25:13.623193Z","shell.execute_reply":"2022-08-05T17:25:13.637190Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Visualizing the number of rows that are null/NaN for specific columns\nfig = plt.figure(figsize = (10,10))\nsns.set(style = 'whitegrid')\nax = sns.barplot(x = missing.index.tolist(), y = missing, palette = 'hot_r')\nax.set_xticklabels(ax.get_xticklabels(), rotation = 90)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:13.641947Z","iopub.execute_input":"2022-08-05T17:25:13.642749Z","iopub.status.idle":"2022-08-05T17:25:13.980658Z","shell.execute_reply.started":"2022-08-05T17:25:13.642703Z","shell.execute_reply":"2022-08-05T17:25:13.979419Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"missing","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:13.981834Z","iopub.execute_input":"2022-08-05T17:25:13.982196Z","iopub.status.idle":"2022-08-05T17:25:13.990438Z","shell.execute_reply.started":"2022-08-05T17:25:13.982165Z","shell.execute_reply":"2022-08-05T17:25:13.989191Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.drop(\"id\", inplace=True, axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:13.992254Z","iopub.execute_input":"2022-08-05T17:25:13.992735Z","iopub.status.idle":"2022-08-05T17:25:14.005377Z","shell.execute_reply.started":"2022-08-05T17:25:13.992686Z","shell.execute_reply":"2022-08-05T17:25:14.004158Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_X = train_df.iloc[:, :-1]\ntrain_y = train_df.loc[:,'failure']","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:14.007219Z","iopub.execute_input":"2022-08-05T17:25:14.007859Z","iopub.status.idle":"2022-08-05T17:25:14.016966Z","shell.execute_reply.started":"2022-08-05T17:25:14.007811Z","shell.execute_reply":"2022-08-05T17:25:14.015425Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_X.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:14.018716Z","iopub.execute_input":"2022-08-05T17:25:14.019178Z","iopub.status.idle":"2022-08-05T17:25:14.048645Z","shell.execute_reply.started":"2022-08-05T17:25:14.019141Z","shell.execute_reply":"2022-08-05T17:25:14.047540Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"corr = train_df.corr()\nmask = np.triu(np.ones_like(corr, dtype=np.bool))\ncorr = corr.mask(mask)\n\nplt.figure(figsize = (25,25))\n# plotting correlation heatmap\ndataplot = sns.heatmap(train_df.corr(), cmap=\"YlGnBu\", annot=True)\n  \n# displaying heatmap\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:14.052359Z","iopub.execute_input":"2022-08-05T17:25:14.052729Z","iopub.status.idle":"2022-08-05T17:25:17.064046Z","shell.execute_reply.started":"2022-08-05T17:25:14.052697Z","shell.execute_reply":"2022-08-05T17:25:17.062762Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cat_cols = []\ncat_cols.extend(train_df[\"product_code\"].unique())\ntrain_df[\"product_code\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:17.065602Z","iopub.execute_input":"2022-08-05T17:25:17.066200Z","iopub.status.idle":"2022-08-05T17:25:17.078957Z","shell.execute_reply.started":"2022-08-05T17:25:17.066159Z","shell.execute_reply":"2022-08-05T17:25:17.077257Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cat_cols.extend(train_df[\"attribute_0\"].unique())\ntrain_df[\"attribute_0\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:17.080452Z","iopub.execute_input":"2022-08-05T17:25:17.081256Z","iopub.status.idle":"2022-08-05T17:25:17.095789Z","shell.execute_reply.started":"2022-08-05T17:25:17.081210Z","shell.execute_reply":"2022-08-05T17:25:17.094954Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cat_cols.extend(train_df[\"attribute_1\"].unique())\ntrain_df[\"attribute_1\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:17.096890Z","iopub.execute_input":"2022-08-05T17:25:17.097284Z","iopub.status.idle":"2022-08-05T17:25:17.110596Z","shell.execute_reply.started":"2022-08-05T17:25:17.097253Z","shell.execute_reply":"2022-08-05T17:25:17.109288Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cat_cols","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:17.111657Z","iopub.execute_input":"2022-08-05T17:25:17.112203Z","iopub.status.idle":"2022-08-05T17:25:17.120251Z","shell.execute_reply.started":"2022-08-05T17:25:17.112164Z","shell.execute_reply":"2022-08-05T17:25:17.119076Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"One Hot Encoding can be used for all the categorical columns.","metadata":{}},{"cell_type":"code","source":"train_X","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:17.122129Z","iopub.execute_input":"2022-08-05T17:25:17.122580Z","iopub.status.idle":"2022-08-05T17:25:17.167934Z","shell.execute_reply.started":"2022-08-05T17:25:17.122537Z","shell.execute_reply":"2022-08-05T17:25:17.166712Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.preprocessing import OneHotEncoder\nenc=OneHotEncoder(handle_unknown='ignore')\nenc_data=pd.DataFrame(enc.fit_transform(train_X[['product_code','attribute_0', 'attribute_1']]).toarray(), columns=cat_cols)\ntrain_X=train_X.join(enc_data)\ntrain_X.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:17.169672Z","iopub.execute_input":"2022-08-05T17:25:17.170124Z","iopub.status.idle":"2022-08-05T17:25:17.230301Z","shell.execute_reply.started":"2022-08-05T17:25:17.170080Z","shell.execute_reply":"2022-08-05T17:25:17.229437Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_X.drop([\"product_code\", \"attribute_0\", \"attribute_1\"], inplace=True, axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:17.231487Z","iopub.execute_input":"2022-08-05T17:25:17.232702Z","iopub.status.idle":"2022-08-05T17:25:17.245232Z","shell.execute_reply.started":"2022-08-05T17:25:17.232651Z","shell.execute_reply":"2022-08-05T17:25:17.244235Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_X.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:17.247406Z","iopub.execute_input":"2022-08-05T17:25:17.248412Z","iopub.status.idle":"2022-08-05T17:25:17.277521Z","shell.execute_reply.started":"2022-08-05T17:25:17.248362Z","shell.execute_reply":"2022-08-05T17:25:17.276611Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.impute import SimpleImputer\nimp = SimpleImputer(missing_values=np.nan, strategy='mean')\ncols = train_X.columns\ntrain_X= pd.DataFrame(imp.fit_transform(train_X), columns = cols)","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:17.278865Z","iopub.execute_input":"2022-08-05T17:25:17.279422Z","iopub.status.idle":"2022-08-05T17:25:17.309254Z","shell.execute_reply.started":"2022-08-05T17:25:17.279389Z","shell.execute_reply":"2022-08-05T17:25:17.308077Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_X.info()","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:17.310814Z","iopub.execute_input":"2022-08-05T17:25:17.311536Z","iopub.status.idle":"2022-08-05T17:25:17.327068Z","shell.execute_reply.started":"2022-08-05T17:25:17.311493Z","shell.execute_reply":"2022-08-05T17:25:17.325845Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize = (35, 35))\n# plotting correlation heatmap\ndataplot = sns.heatmap(pd.concat((train_X, train_y), axis=1).corr(), cmap=\"YlGnBu\", annot=True)\n  \n# displaying heatmap\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:17.329189Z","iopub.execute_input":"2022-08-05T17:25:17.329680Z","iopub.status.idle":"2022-08-05T17:25:22.325672Z","shell.execute_reply.started":"2022-08-05T17:25:17.329635Z","shell.execute_reply":"2022-08-05T17:25:22.324408Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_X.hist(bins=30, figsize=(35, 35))","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:22.331283Z","iopub.execute_input":"2022-08-05T17:25:22.331701Z","iopub.status.idle":"2022-08-05T17:25:29.248068Z","shell.execute_reply.started":"2022-08-05T17:25:22.331664Z","shell.execute_reply":"2022-08-05T17:25:29.246896Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"`Loading`, `measurement_0`, `measurement_1`, and `measurement_2` are left skewed. We can use log transform to convert them to normal distribution.","metadata":{}},{"cell_type":"code","source":"from sklearn.preprocessing import FunctionTransformer\nfrom sklearn.compose import ColumnTransformer\n\nlogtransformer = FunctionTransformer(np.log, validate=True)\nct = ColumnTransformer(transformers=[\n    (\"LogTransformation\", logtransformer, [0, 3, 4, 5]), \n])\nct.fit(train_X)\nX = pd.DataFrame(ct.transform(train_X), columns = [\n    'loading' ,'measurement_0', 'measurement_1', 'measurement_2' \n]).replace([-np.inf, np.inf], 0)","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:29.249562Z","iopub.execute_input":"2022-08-05T17:25:29.250039Z","iopub.status.idle":"2022-08-05T17:25:29.270945Z","shell.execute_reply.started":"2022-08-05T17:25:29.249992Z","shell.execute_reply":"2022-08-05T17:25:29.269383Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X.hist()","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:29.273057Z","iopub.execute_input":"2022-08-05T17:25:29.274097Z","iopub.status.idle":"2022-08-05T17:25:29.898652Z","shell.execute_reply.started":"2022-08-05T17:25:29.274057Z","shell.execute_reply":"2022-08-05T17:25:29.897389Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_X['loading'] = X['loading']\ntrain_X['measurement_0'] = X['measurement_0']\ntrain_X['measurement_1'] = X['measurement_1']\ntrain_X['measurement_2'] = X['measurement_2']","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:29.900536Z","iopub.execute_input":"2022-08-05T17:25:29.901307Z","iopub.status.idle":"2022-08-05T17:25:29.911438Z","shell.execute_reply.started":"2022-08-05T17:25:29.901260Z","shell.execute_reply":"2022-08-05T17:25:29.910470Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_X.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:29.913207Z","iopub.execute_input":"2022-08-05T17:25:29.913670Z","iopub.status.idle":"2022-08-05T17:25:29.944573Z","shell.execute_reply.started":"2022-08-05T17:25:29.913625Z","shell.execute_reply":"2022-08-05T17:25:29.943279Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.preprocessing import MinMaxScaler\n\nscaler = MinMaxScaler().fit(train_X)\ntrain_X = pd.DataFrame(scaler.transform(train_X), columns = train_X.columns)","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:29.946548Z","iopub.execute_input":"2022-08-05T17:25:29.947529Z","iopub.status.idle":"2022-08-05T17:25:29.962783Z","shell.execute_reply.started":"2022-08-05T17:25:29.947483Z","shell.execute_reply":"2022-08-05T17:25:29.961752Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_X.hist(bins=30, figsize=(35, 35))","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:29.964304Z","iopub.execute_input":"2022-08-05T17:25:29.964672Z","iopub.status.idle":"2022-08-05T17:25:36.893500Z","shell.execute_reply.started":"2022-08-05T17:25:29.964639Z","shell.execute_reply":"2022-08-05T17:25:36.892337Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_X.drop(\"material_5\", inplace=True, axis=1)\ntrain_X.drop(\"A\", inplace=True, axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:36.894891Z","iopub.execute_input":"2022-08-05T17:25:36.895253Z","iopub.status.idle":"2022-08-05T17:25:36.905529Z","shell.execute_reply.started":"2022-08-05T17:25:36.895220Z","shell.execute_reply":"2022-08-05T17:25:36.904082Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# from sklearn.model_selection import cross_val_score, GridSearchCV, KFold, RandomizedSearchCV, train_test_split\n\n# import xgboost as xgb\n# xgb_model = xgb.XGBRegressor(colsample_bytree=0.4,\n#                  gamma=0,                 \n#                  learning_rate=0.07,\n#                  max_depth=3,\n#                  min_child_weight=1.5,\n#                  n_estimators=1000,                                                                    \n#                  reg_alpha=0.75,\n#                  reg_lambda=0.45,\n#                  subsample=0.6,\n#                  seed=42, random_state=42)\n\n# xgb_model.fit(train_X, train_y)\n# pred_y = xgb_model.predict(train_X)","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:36.907008Z","iopub.execute_input":"2022-08-05T17:25:36.908226Z","iopub.status.idle":"2022-08-05T17:25:36.926896Z","shell.execute_reply.started":"2022-08-05T17:25:36.908180Z","shell.execute_reply":"2022-08-05T17:25:36.925472Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_X = train_X.iloc[:, 0:21]","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:26:55.569165Z","iopub.execute_input":"2022-08-05T17:26:55.569966Z","iopub.status.idle":"2022-08-05T17:26:55.575561Z","shell.execute_reply.started":"2022-08-05T17:26:55.569925Z","shell.execute_reply":"2022-08-05T17:26:55.574361Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.linear_model import LinearRegression\nmodel = LinearRegression().fit(train_X, train_y)\npred_y = model.predict(train_X)","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:27:10.838214Z","iopub.execute_input":"2022-08-05T17:27:10.838607Z","iopub.status.idle":"2022-08-05T17:27:10.867975Z","shell.execute_reply.started":"2022-08-05T17:27:10.838575Z","shell.execute_reply":"2022-08-05T17:27:10.866629Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# from sklearn.linear_model import Ridge\n# model = Ridge(alpha=30).fit(train_X, train_y)\n# pred_y = model.predict(train_X)","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:37.088194Z","iopub.status.idle":"2022-08-05T17:25:37.089047Z","shell.execute_reply.started":"2022-08-05T17:25:37.088727Z","shell.execute_reply":"2022-08-05T17:25:37.088757Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# from catboost import CatBoostRegressor\n\n# model = CatBoostRegressor(iterations=100,learning_rate=0.09,\n#                         depth=3,)\n# model.fit(train_X, train_y, verbose=False)\n# pred_y = model.predict(train_X)","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:37.090604Z","iopub.status.idle":"2022-08-05T17:25:37.091446Z","shell.execute_reply.started":"2022-08-05T17:25:37.091142Z","shell.execute_reply":"2022-08-05T17:25:37.091171Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn import metrics\nfpr, tpr, thresholds = metrics.roc_curve(train_y, pred_y)\nmetrics.auc(fpr, tpr)","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:27:17.501843Z","iopub.execute_input":"2022-08-05T17:27:17.502563Z","iopub.status.idle":"2022-08-05T17:27:17.517526Z","shell.execute_reply.started":"2022-08-05T17:27:17.502518Z","shell.execute_reply":"2022-08-05T17:27:17.516444Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df.drop(\"id\", inplace=True, axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:37.094595Z","iopub.status.idle":"2022-08-05T17:25:37.095244Z","shell.execute_reply.started":"2022-08-05T17:25:37.095001Z","shell.execute_reply":"2022-08-05T17:25:37.095043Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"enc_data=pd.DataFrame(enc.transform(test_df[['product_code','attribute_0', 'attribute_1']]).toarray(), columns=cat_cols)\ntest_df=test_df.join(enc_data)\ntest_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:37.096441Z","iopub.status.idle":"2022-08-05T17:25:37.097098Z","shell.execute_reply.started":"2022-08-05T17:25:37.096856Z","shell.execute_reply":"2022-08-05T17:25:37.096883Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df.drop([\"product_code\", \"attribute_0\", \"attribute_1\"], inplace=True, axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:37.098255Z","iopub.status.idle":"2022-08-05T17:25:37.098896Z","shell.execute_reply.started":"2022-08-05T17:25:37.098674Z","shell.execute_reply":"2022-08-05T17:25:37.098702Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:37.100014Z","iopub.status.idle":"2022-08-05T17:25:37.100448Z","shell.execute_reply.started":"2022-08-05T17:25:37.100253Z","shell.execute_reply":"2022-08-05T17:25:37.100272Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_X= pd.DataFrame(imp.fit_transform(test_df), columns = cols)","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:37.102401Z","iopub.status.idle":"2022-08-05T17:25:37.102803Z","shell.execute_reply.started":"2022-08-05T17:25:37.102608Z","shell.execute_reply":"2022-08-05T17:25:37.102627Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X = pd.DataFrame(ct.transform(test_X), columns = [\n    'loading' ,'measurement_0', 'measurement_1', 'measurement_2' \n]).replace([-np.inf, np.inf], 0)","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:37.104249Z","iopub.status.idle":"2022-08-05T17:25:37.104658Z","shell.execute_reply.started":"2022-08-05T17:25:37.104464Z","shell.execute_reply":"2022-08-05T17:25:37.104483Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_X['loading'] = X['loading']\ntest_X['measurement_0'] = X['measurement_0']\ntest_X['measurement_1'] = X['measurement_1']\ntest_X['measurement_2'] = X['measurement_2']","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:37.105878Z","iopub.status.idle":"2022-08-05T17:25:37.106759Z","shell.execute_reply.started":"2022-08-05T17:25:37.106540Z","shell.execute_reply":"2022-08-05T17:25:37.106562Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_X = pd.DataFrame(scaler.transform(test_X), columns = test_X.columns)","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:37.108108Z","iopub.status.idle":"2022-08-05T17:25:37.108921Z","shell.execute_reply.started":"2022-08-05T17:25:37.108711Z","shell.execute_reply":"2022-08-05T17:25:37.108733Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_X.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:37.110243Z","iopub.status.idle":"2022-08-05T17:25:37.111183Z","shell.execute_reply.started":"2022-08-05T17:25:37.110928Z","shell.execute_reply":"2022-08-05T17:25:37.110950Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_X.drop(\"material_5\", inplace=True, axis=1)\ntest_X.drop(\"A\", inplace=True, axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:37.112544Z","iopub.status.idle":"2022-08-05T17:25:37.113422Z","shell.execute_reply.started":"2022-08-05T17:25:37.113208Z","shell.execute_reply":"2022-08-05T17:25:37.113230Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_X.info()","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:37.114653Z","iopub.status.idle":"2022-08-05T17:25:37.115817Z","shell.execute_reply.started":"2022-08-05T17:25:37.115488Z","shell.execute_reply":"2022-08-05T17:25:37.115520Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_X.info()","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:37.117425Z","iopub.status.idle":"2022-08-05T17:25:37.117976Z","shell.execute_reply.started":"2022-08-05T17:25:37.117699Z","shell.execute_reply":"2022-08-05T17:25:37.117725Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_X = test_X.iloc[:, 0:21]","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:27:05.866850Z","iopub.execute_input":"2022-08-05T17:27:05.867395Z","iopub.status.idle":"2022-08-05T17:27:05.874796Z","shell.execute_reply.started":"2022-08-05T17:27:05.867350Z","shell.execute_reply":"2022-08-05T17:27:05.873309Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pred_y = model.predict(test_X)","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:37.123055Z","iopub.status.idle":"2022-08-05T17:25:37.123636Z","shell.execute_reply.started":"2022-08-05T17:25:37.123344Z","shell.execute_reply":"2022-08-05T17:25:37.123369Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_df['failure'] = pred_y\nsub_df.to_csv('submission.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:37.125416Z","iopub.status.idle":"2022-08-05T17:25:37.126385Z","shell.execute_reply.started":"2022-08-05T17:25:37.126087Z","shell.execute_reply":"2022-08-05T17:25:37.126115Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-05T17:25:37.128232Z","iopub.status.idle":"2022-08-05T17:25:37.129270Z","shell.execute_reply.started":"2022-08-05T17:25:37.129017Z","shell.execute_reply":"2022-08-05T17:25:37.129064Z"},"trusted":true},"execution_count":null,"outputs":[]}]}