{"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":{"execution":{"iopub.status.busy":"2022-05-11T21:56:21.222191Z","iopub.execute_input":"2022-05-11T21:56:21.22246Z","iopub.status.idle":"2022-05-11T21:56:21.237712Z","shell.execute_reply.started":"2022-05-11T21:56:21.222429Z","shell.execute_reply":"2022-05-11T21:56:21.236871Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt \nimport seaborn as sns\nfrom tqdm.notebook import tqdm \n\nimport matplotlib\nfrom matplotlib import rc\n\nrc(\"font\", **{\"family\": \"sans-serif\", \"sans-serif\": \"DejaVu Sans\"})\nrc(\"figure\", **{\"dpi\": 200})\nrc(\n    \"axes\",\n    **{\"spines.right\": False, \"spines.top\": False, \"xmargin\": 0.0, \"ymargin\": 0.05}\n)","metadata":{"execution":{"iopub.status.busy":"2022-05-11T21:56:23.853095Z","iopub.execute_input":"2022-05-11T21:56:23.853367Z","iopub.status.idle":"2022-05-11T21:56:23.86237Z","shell.execute_reply.started":"2022-05-11T21:56:23.853335Z","shell.execute_reply":"2022-05-11T21:56:23.861617Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.read_csv('../input/eurecom-aml-2022-challenge-1/public/train.csv', low_memory=True)\ndf_test = pd.read_csv('../input/eurecom-aml-2022-challenge-1/public/test_feat.csv', low_memory=True)\ndf.head()\ndf.shape[0]","metadata":{"execution":{"iopub.status.busy":"2022-05-11T21:56:31.764566Z","iopub.execute_input":"2022-05-11T21:56:31.765113Z","iopub.status.idle":"2022-05-11T21:57:59.905161Z","shell.execute_reply.started":"2022-05-11T21:56:31.765075Z","shell.execute_reply":"2022-05-11T21:57:59.904469Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"DATA ANALYSIS : ","metadata":{}},{"cell_type":"code","source":"#df_real=df\n#df=df.drop(index=range(1800000))","metadata":{"execution":{"iopub.status.busy":"2022-05-11T20:57:58.535349Z","iopub.execute_input":"2022-05-11T20:57:58.535882Z","iopub.status.idle":"2022-05-11T20:57:58.539139Z","shell.execute_reply.started":"2022-05-11T20:57:58.535845Z","shell.execute_reply":"2022-05-11T20:57:58.538479Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#corr_df = df.corr(method='pearson')\n#corr_df.style.background_gradient(cmap='coolwarm')","metadata":{"execution":{"iopub.status.busy":"2022-05-11T20:57:58.541232Z","iopub.execute_input":"2022-05-11T20:57:58.541735Z","iopub.status.idle":"2022-05-11T20:57:58.549024Z","shell.execute_reply.started":"2022-05-11T20:57:58.541701Z","shell.execute_reply":"2022-05-11T20:57:58.548329Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tr_coordinates = df[['fact_latitude','fact_longitude']].drop_duplicates()\nte_coordinates = df_test[['fact_latitude','fact_longitude']].drop_duplicates()","metadata":{"execution":{"iopub.status.busy":"2022-05-11T21:57:59.906914Z","iopub.execute_input":"2022-05-11T21:57:59.907686Z","iopub.status.idle":"2022-05-11T21:58:00.074077Z","shell.execute_reply.started":"2022-05-11T21:57:59.907643Z","shell.execute_reply":"2022-05-11T21:58:00.073315Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"merged = te_coordinates.merge(tr_coordinates, how='left', indicator=True)\ntropic_coordinates = merged[merged['_merge']=='left_only']\ncommon_coordinates = merged[merged['_merge']=='both']","metadata":{"execution":{"iopub.status.busy":"2022-05-11T21:58:00.075298Z","iopub.execute_input":"2022-05-11T21:58:00.075944Z","iopub.status.idle":"2022-05-11T21:58:00.110337Z","shell.execute_reply.started":"2022-05-11T21:58:00.075897Z","shell.execute_reply":"2022-05-11T21:58:00.109593Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"to_drop =['cmc_available','gfs_soil_temperature_available','wrf_available','gfs_available']\ndf=df.drop(columns=to_drop, axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-05-11T21:58:00.113052Z","iopub.execute_input":"2022-05-11T21:58:00.113345Z","iopub.status.idle":"2022-05-11T21:58:00.619753Z","shell.execute_reply.started":"2022-05-11T21:58:00.113304Z","shell.execute_reply":"2022-05-11T21:58:00.618682Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# handling the missing data and replace missing values with nan from numpy and replace with mean of all the other values\nfrom sklearn.impute import SimpleImputer\narr_df=df.values\ndf_ind=df.index\ndf_col=df.columns\nimputer = SimpleImputer(missing_values=np.nan, strategy='mean') \nn_col = arr_df.shape[1]\nimputer = imputer.fit(arr_df[:,1:n_col-1])\narr_df[:,1:n_col-1] = imputer.transform(arr_df[:,1:n_col-1])\n\ndf= pd.DataFrame(arr_df, columns = df_col, index = df_ind)","metadata":{"execution":{"iopub.status.busy":"2022-05-11T21:58:00.62135Z","iopub.execute_input":"2022-05-11T21:58:00.621767Z","iopub.status.idle":"2022-05-11T21:58:07.306994Z","shell.execute_reply.started":"2022-05-11T21:58:00.621724Z","shell.execute_reply":"2022-05-11T21:58:07.306172Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"DATA PRE-PROCESSING","metadata":{}},{"cell_type":"code","source":"#print(df.shape[0])\n#print(df.shape[1])\n","metadata":{"execution":{"iopub.status.busy":"2022-05-11T20:58:05.642273Z","iopub.execute_input":"2022-05-11T20:58:05.642537Z","iopub.status.idle":"2022-05-11T20:58:05.646179Z","shell.execute_reply.started":"2022-05-11T20:58:05.642504Z","shell.execute_reply":"2022-05-11T20:58:05.645325Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.dropna(inplace=True)\n#print(df.shape[0])\n#print(df.shape[1])","metadata":{"execution":{"iopub.status.busy":"2022-05-11T21:58:07.308619Z","iopub.execute_input":"2022-05-11T21:58:07.308918Z","iopub.status.idle":"2022-05-11T21:58:08.437667Z","shell.execute_reply.started":"2022-05-11T21:58:07.308876Z","shell.execute_reply":"2022-05-11T21:58:08.436878Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#corrdf = df.corr(method='pearson')\n#corrdf.style.background_gradient(cmap='coolwarm')","metadata":{"execution":{"iopub.status.busy":"2022-05-11T20:58:06.789695Z","iopub.execute_input":"2022-05-11T20:58:06.790133Z","iopub.status.idle":"2022-05-11T20:58:06.794003Z","shell.execute_reply.started":"2022-05-11T20:58:06.79007Z","shell.execute_reply":"2022-05-11T20:58:06.793257Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def corr_fact_temp(df, corr_val):\n    x=df\n    # Creates Correlation Matrix and Instantiates\n    corr_matrix = x.corr()\n    iters = range(len(corr_matrix.columns)-1)\n    drop_cols = []\n    corr_arr=corr_matrix.values\n    # Iterates through Correlation Matrix Table to find correlated columns\n    for i in iters:\n        val = corr_arr[i,-1]\n        if abs(val) <= corr_val:\n            drop_cols.append(i)\n\n    drop_cols.sort()\n    col_temp=[]\n    #correlated columns\n    for i in range(len(drop_cols)):\n        col_temp.append(df.columns[drop_cols[i]])\n    return col_temp","metadata":{"execution":{"iopub.status.busy":"2022-05-11T21:58:08.439242Z","iopub.execute_input":"2022-05-11T21:58:08.43954Z","iopub.status.idle":"2022-05-11T21:58:08.447155Z","shell.execute_reply.started":"2022-05-11T21:58:08.4395Z","shell.execute_reply":"2022-05-11T21:58:08.446123Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"col_temp = corr_fact_temp(df, 0.4)\n\nprint(len(col_temp))","metadata":{"execution":{"iopub.status.busy":"2022-05-11T21:58:08.448925Z","iopub.execute_input":"2022-05-11T21:58:08.449242Z","iopub.status.idle":"2022-05-11T21:59:13.183342Z","shell.execute_reply.started":"2022-05-11T21:58:08.449204Z","shell.execute_reply":"2022-05-11T21:59:13.182552Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_temp=df.drop(columns=col_temp, axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-05-11T21:59:13.184948Z","iopub.execute_input":"2022-05-11T21:59:13.185258Z","iopub.status.idle":"2022-05-11T21:59:13.345612Z","shell.execute_reply.started":"2022-05-11T21:59:13.185198Z","shell.execute_reply":"2022-05-11T21:59:13.344711Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#corr_df1 = df_temp.corr(method='pearson')\n#corr_df1.style.background_gradient(cmap='coolwarm')","metadata":{"execution":{"iopub.status.busy":"2022-05-11T20:59:04.209351Z","iopub.execute_input":"2022-05-11T20:59:04.209646Z","iopub.status.idle":"2022-05-11T20:59:04.217213Z","shell.execute_reply.started":"2022-05-11T20:59:04.209606Z","shell.execute_reply":"2022-05-11T20:59:04.216526Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def corr_df(df, corr_val):\n    '''\n    Obj: Drops features that are strongly correlated to other features.\n    Inputs:\n          df: features df (x)\n          corr_val: Columns are dropped relative to the corr_val input \n    Output: df that only includes uncorrelated features\n    '''\n    #we need to drop the targeted value first \n    x=df.drop('fact_temperature', axis=1, inplace = False)\n    \n    # Creates Correlation Matrix and Instantiates\n    corr_matrix = x.corr()\n    iters = range(len(corr_matrix.columns))\n    drop_cols = []\n    corr_arr=corr_matrix.values\n    # Iterates through Correlation Matrix Table to find correlated columns\n    for i in iters:\n        for j in range(i):\n            val = corr_arr[i,j]\n            if abs(val) >= corr_val:\n                drop_cols.append(i)\n\n    drop_cols.sort()\n    #correlated columns\n    col=[]\n    for i in range(len(drop_cols)):\n        col.append(df.columns[drop_cols[i]])\n    return col","metadata":{"execution":{"iopub.status.busy":"2022-05-11T21:59:13.348902Z","iopub.execute_input":"2022-05-11T21:59:13.350597Z","iopub.status.idle":"2022-05-11T21:59:13.360254Z","shell.execute_reply.started":"2022-05-11T21:59:13.35056Z","shell.execute_reply":"2022-05-11T21:59:13.359471Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"col = corr_df(df_temp, 0.9)\n\nprint(len(col))","metadata":{"execution":{"iopub.status.busy":"2022-05-11T21:59:13.361606Z","iopub.execute_input":"2022-05-11T21:59:13.362082Z","iopub.status.idle":"2022-05-11T21:59:19.435773Z","shell.execute_reply.started":"2022-05-11T21:59:13.361934Z","shell.execute_reply":"2022-05-11T21:59:19.434931Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_=df_temp.drop(columns=col, axis=1)\n#print(df_.shape[0])\n#print(df_.shape[1])","metadata":{"execution":{"iopub.status.busy":"2022-05-11T21:59:19.437049Z","iopub.execute_input":"2022-05-11T21:59:19.43786Z","iopub.status.idle":"2022-05-11T21:59:19.480471Z","shell.execute_reply.started":"2022-05-11T21:59:19.437816Z","shell.execute_reply":"2022-05-11T21:59:19.479569Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(df_.columns)","metadata":{"execution":{"iopub.status.busy":"2022-05-11T20:59:09.735023Z","iopub.execute_input":"2022-05-11T20:59:09.735392Z","iopub.status.idle":"2022-05-11T20:59:09.74399Z","shell.execute_reply.started":"2022-05-11T20:59:09.735336Z","shell.execute_reply":"2022-05-11T20:59:09.743119Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#corr_df2 = df_.corr(method='pearson')\n#corr_df2.style.background_gradient(cmap='coolwarm')","metadata":{"execution":{"iopub.status.busy":"2022-05-11T20:59:09.745157Z","iopub.execute_input":"2022-05-11T20:59:09.745961Z","iopub.status.idle":"2022-05-11T20:59:09.752491Z","shell.execute_reply.started":"2022-05-11T20:59:09.745925Z","shell.execute_reply":"2022-05-11T20:59:09.751679Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_.head()","metadata":{"execution":{"iopub.status.busy":"2022-05-11T21:59:19.481987Z","iopub.execute_input":"2022-05-11T21:59:19.482349Z","iopub.status.idle":"2022-05-11T21:59:19.509002Z","shell.execute_reply.started":"2022-05-11T21:59:19.482306Z","shell.execute_reply":"2022-05-11T21:59:19.50805Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X = df_.dropna().iloc[:, 1:-1].values\ny = df_.dropna().iloc[:, -1].values\nprint(df_)\n\nXmean, Xstd, ymean, ystd = X.mean(0), X.std(0), y.mean(), y.std()\nX = (X - Xmean) / Xstd\ny = (y - ymean) / ystd","metadata":{"execution":{"iopub.status.busy":"2022-05-11T21:59:19.510704Z","iopub.execute_input":"2022-05-11T21:59:19.511021Z","iopub.status.idle":"2022-05-11T21:59:19.989394Z","shell.execute_reply.started":"2022-05-11T21:59:19.51098Z","shell.execute_reply":"2022-05-11T21:59:19.988551Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"MODEL SELECTION","metadata":{}},{"cell_type":"code","source":"from sklearn.model_selection import train_test_split\nXtr, Xval, ytr, yval = train_test_split(X, y, random_state=1, test_size=10000)\n","metadata":{"execution":{"iopub.status.busy":"2022-05-11T21:59:19.990915Z","iopub.execute_input":"2022-05-11T21:59:19.991419Z","iopub.status.idle":"2022-05-11T21:59:20.343042Z","shell.execute_reply.started":"2022-05-11T21:59:19.991375Z","shell.execute_reply":"2022-05-11T21:59:20.34229Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.linear_model import Lasso\nfrom sklearn.linear_model import LinearRegression\nfrom sklearn.tree import DecisionTreeRegressor\nfrom sklearn.gaussian_process import GaussianProcessRegressor\nfrom sklearn.gaussian_process.kernels import DotProduct, WhiteKernel\nfrom sklearn.neighbors import KNeighborsRegressor\nfrom sklearn.svm import SVR\nfrom sklearn.ensemble import RandomForestRegressor, GradientBoostingRegressor, AdaBoostRegressor\n\n\nlist_of_models =[\"lin_reg\",\"lasso_reg\",\"reg_tree\",\"gaussian_process_regressor\",\"knn_reg\",\"svr\",\"random_forest\",\"gradient_boosting_reg\",\"ada_boosting_reg\"]\n\nchosen_model = list_of_models[1]\n\ndef compute_rmse(y, ypred, ystd=1.):\n    return np.mean((y - ypred)**2)**0.5 * ystd\n\n\nif chosen_model == \"lin_reg\":\n    model = LinearRegression()\nelif chosen_model == \"lasso_reg\":\n    model = Lasso(alpha=0.005)\nelif chosen_model == \"reg_tree\":\n    model = DecisionTreeRegressor(max_depth=9)\nelif chosen_model == \"gaussian_process_regressor\":\n    kernel = DotProduct() + WhiteKernel()\n    model = GaussianProcessRegressor(kernel=kernel, random_state=0)\nelif chosen_model == \"knn_reg\":\n    model = KNeighborsRegressor(n_neighbors=6)\nelif chosen_model == \"svr\":\n    model = SVR(kernel=\"poly\", C=100, gamma=\"auto\", degree=3, epsilon=0.1, coef0=1)\nelif chosen_model == \"random_forest\":\n    model = RandomForestRegressor()\nelif chosen_model == \"gradient_boosting_reg\":\n    model = GradientBoostingRegressor()\nelif chosen_model == \"ada_boosting_reg\":\n    model = AdaBoostRegressor()\n\n\nmodel.fit(Xtr, ytr)\nypred_tr = model.predict(Xtr)\nypred_val = model.predict(Xval)\n    \nprint(chosen_model)\nprint(f'Train RMSE: {compute_rmse(ytr, ypred_tr, ystd):.3f}')\nprint(f'Valid RMSE: {compute_rmse(yval, ypred_val, ystd):.3f}')\nprint()\n    \n    \n\n\n#run_model(list_of_models[6])\n#run_model(list_of_models[0])\n#run_model(list_of_models[1])\n#run_model(list_of_models[2])\n#run_model(list_of_models[7])\n#run_model(list_of_models[4])","metadata":{"execution":{"iopub.status.busy":"2022-05-11T21:59:20.344397Z","iopub.execute_input":"2022-05-11T21:59:20.344687Z","iopub.status.idle":"2022-05-11T21:59:22.594724Z","shell.execute_reply.started":"2022-05-11T21:59:20.344647Z","shell.execute_reply":"2022-05-11T21:59:22.593712Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"PARAMETER OPTIMISATION","metadata":{}},{"cell_type":"code","source":"from sklearn.model_selection import RandomizedSearchCV, GridSearchCV","metadata":{"execution":{"iopub.status.busy":"2022-05-11T21:17:26.908849Z","iopub.execute_input":"2022-05-11T21:17:26.909267Z","iopub.status.idle":"2022-05-11T21:17:26.913868Z","shell.execute_reply.started":"2022-05-11T21:17:26.909228Z","shell.execute_reply":"2022-05-11T21:17:26.91283Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import numpy as np\n\ndef get_cv_idx(n, test_size=0.2, n_splits=2):\n    train_idx, test_idx = [], []\n    for _ in range(n_splits):\n        idx = np.random.permutation(n)\n        train_size = int(n * (1 - test_size)) if isinstance(test_size, float) else n - test_size\n        train_idx.append(idx[:train_size])\n        test_idx.append(idx[train_size:])\n    return train_idx, test_idx","metadata":{"execution":{"iopub.status.busy":"2022-05-11T21:17:26.915259Z","iopub.execute_input":"2022-05-11T21:17:26.915672Z","iopub.status.idle":"2022-05-11T21:17:26.927449Z","shell.execute_reply.started":"2022-05-11T21:17:26.915635Z","shell.execute_reply":"2022-05-11T21:17:26.926793Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_idx, cv_idx = get_cv_idx(len(Xtr), test_size=10000, n_splits=10)","metadata":{"execution":{"iopub.status.busy":"2022-05-11T21:17:26.928696Z","iopub.execute_input":"2022-05-11T21:17:26.929013Z","iopub.status.idle":"2022-05-11T21:17:27.383479Z","shell.execute_reply.started":"2022-05-11T21:17:26.928978Z","shell.execute_reply":"2022-05-11T21:17:27.382718Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"list_of_models =[\"lin_reg\",\"lasso_reg\",\"reg_tree\",\"gaussian_process_regressor\",\"knn_reg\",\"svr\",\"random_forest\",\"gradient_boosting_reg\",\"ada_boosting_reg\"]\nmodels_test_hyp = [\"lasso_reg\",\"reg_tree\",\"knn_reg\",\"random_forest\",\"gradient_boosting_reg\"]\n\n\n\n\nparam_grid = {\n        \"n_neighbors\": [ 3, 4, 5]\n    }\n\n\n\n\n\nsearch = GridSearchCV(model, \n                      param_grid,\n                      n_jobs=-1, \n                      verbose=1,\n                      cv=zip(train_idx, cv_idx), \n                      scoring='neg_root_mean_squared_error').fit(Xtr, ytr)\nprint('Done!')","metadata":{"execution":{"iopub.status.busy":"2022-05-11T21:33:36.200709Z","iopub.execute_input":"2022-05-11T21:33:36.200998Z","iopub.status.idle":"2022-05-11T21:37:58.88972Z","shell.execute_reply.started":"2022-05-11T21:33:36.200968Z","shell.execute_reply":"2022-05-11T21:37:58.888931Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Best parameters set found on cv set:\")\nprint(search.best_params_)\nprint()\nprint(\"Grid scores on cv set:\")\nmeans = search.cv_results_[\"mean_test_score\"]\nstds = search.cv_results_[\"std_test_score\"]\nfor mean, std, params in zip(means, stds, search.cv_results_[\"params\"]):\n    print(\"%0.3f (+/-%0.03f) for %r\" % (-mean * ystd, (std * ystd) * 2, params))\nprint()\nprint(\"Error on the validation set\")\nypred_val = search.predict(Xval)\nprint(f'Valid RMSE: {compute_rmse(yval, ypred_val, ystd):.3f}')","metadata":{"execution":{"iopub.status.busy":"2022-05-11T21:37:58.891389Z","iopub.execute_input":"2022-05-11T21:37:58.891833Z","iopub.status.idle":"2022-05-11T21:38:04.667744Z","shell.execute_reply.started":"2022-05-11T21:37:58.891796Z","shell.execute_reply":"2022-05-11T21:38:04.666234Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"MODEL EVALUATION","metadata":{}},{"cell_type":"code","source":"df_test = pd.read_csv('../input/eurecom-aml-2022-challenge-1/public/test_feat.csv', low_memory=True)\ncol_selection =df_.columns\n\n##df_test.head()\n\nXte = df_test[col_selection].iloc[:, 1:].values\nXte = (Xte - Xmean) / Xstd","metadata":{"execution":{"iopub.status.busy":"2022-05-11T21:59:22.596344Z","iopub.execute_input":"2022-05-11T21:59:22.605001Z","iopub.status.idle":"2022-05-11T21:59:35.335372Z","shell.execute_reply.started":"2022-05-11T21:59:22.60495Z","shell.execute_reply":"2022-05-11T21:59:35.334103Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ypred_te = search.predict(Xte) * ystd + ymean  # Remember to un-standardize the predictions\ndf_test.head()","metadata":{"execution":{"iopub.status.busy":"2022-05-11T21:59:35.336792Z","iopub.status.idle":"2022-05-11T21:59:35.337268Z","shell.execute_reply.started":"2022-05-11T21:59:35.337Z","shell.execute_reply":"2022-05-11T21:59:35.337027Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"SUBMISSION","metadata":{}},{"cell_type":"code","source":"submission_df = pd.DataFrame(data={'index': df_test['index'].values,\n                                   'fact_temperature': ypred_te.squeeze()})\n\n# Save the predictions into a csv file\n# Notice that this file should be saved under the directory `/kaggle/working` \n# so that you can download it later\nsubmission_df.to_csv(\"/kaggle/working/submission.csv\", index=False)","metadata":{"execution":{"iopub.status.busy":"2022-05-11T21:59:35.338802Z","iopub.status.idle":"2022-05-11T21:59:35.339265Z","shell.execute_reply.started":"2022-05-11T21:59:35.339004Z","shell.execute_reply":"2022-05-11T21:59:35.339029Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Check the submission file\n! head -6 \"/kaggle/working/submission.csv\"","metadata":{"execution":{"iopub.status.busy":"2022-05-11T21:19:12.870375Z","iopub.status.idle":"2022-05-11T21:19:12.8719Z","shell.execute_reply.started":"2022-05-11T21:19:12.871638Z","shell.execute_reply":"2022-05-11T21:19:12.871666Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}