{"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":"### Hi guys, just started working on this notebook today.\n#### Trying to understand the whole logic and steps required.\n\n#### Please stay tuned and support.","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)\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))","metadata":{"execution":{"iopub.status.busy":"2022-01-11T13:16:29.329882Z","iopub.execute_input":"2022-01-11T13:16:29.330191Z","iopub.status.idle":"2022-01-11T13:16:29.343749Z","shell.execute_reply.started":"2022-01-11T13:16:29.330158Z","shell.execute_reply":"2022-01-11T13:16:29.343139Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------**","metadata":{}},{"cell_type":"markdown","source":"#### Trying to submit with below code only. Lets see what happens.","metadata":{}},{"cell_type":"code","source":"import gresearch_crypto\nenv = gresearch_crypto.make_env()\niter_test = env.iter_test()\n\ntrainDF = pd.read_csv('/kaggle/input/g-research-crypto-forecasting/train.csv', \n                 usecols=['Target', 'Asset_ID','timestamp'], dtype={'Asset_ID': 'int8'})\ntrainDF['datetime'] = pd.to_datetime(trainDF['timestamp'], unit='s')\ntrainDF = trainDF.set_index('datetime').drop('timestamp', axis=1)\ntrainDF = trainDF[(trainDF.index.year == 2021) & (trainDF.index.month > 5)]\ndfs = {asset_id: trainDF[trainDF['Asset_ID'] == asset_id].resample('1min').interpolate().copy() for asset_id in trainDF['Asset_ID'].unique()}\ndel trainDF\nfor df_test, df_pred in iter_test:\n    df_test['datetime'] = pd.to_datetime(df_test['timestamp'], unit='s')\n    for _, row in df_test.iterrows():\n        try:\n            df = dfs[row['Asset_ID']]\n            closest_train_sample = df.iloc[df.index.get_loc(row['datetime'], method='nearest')]\n            df_pred.loc[df_pred['row_id'] == row['row_id'], 'Target'] = closest_train_sample['Target']\n        except:\n            df_pred.loc[df_pred['row_id'] == row['row_id'], 'Target'] = 0\n    df_pred['Target'] = df_pred['Target'].fillna(0)\n    env.predict(df_pred)","metadata":{"execution":{"iopub.status.busy":"2022-01-11T13:18:35.109542Z","iopub.execute_input":"2022-01-11T13:18:35.110294Z","iopub.status.idle":"2022-01-11T13:19:09.142491Z","shell.execute_reply.started":"2022-01-11T13:18:35.110227Z","shell.execute_reply":"2022-01-11T13:19:09.141567Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------**","metadata":{}},{"cell_type":"code","source":"train = pd.read_csv('/kaggle/input/g-research-crypto-forecasting/train.csv')\nexample_test = pd.read_csv('/kaggle/input/g-research-crypto-forecasting/example_test.csv')\nsubmission = pd.read_csv('/kaggle/input/g-research-crypto-forecasting/example_sample_submission.csv')","metadata":{"execution":{"iopub.status.busy":"2022-01-05T09:36:34.500522Z","iopub.execute_input":"2022-01-05T09:36:34.501155Z","iopub.status.idle":"2022-01-05T09:37:31.443059Z","shell.execute_reply.started":"2022-01-05T09:36:34.501104Z","shell.execute_reply":"2022-01-05T09:37:31.442164Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"> ## Data analysis","metadata":{}},{"cell_type":"code","source":"train.head()","metadata":{"execution":{"iopub.status.busy":"2022-01-05T09:37:31.444811Z","iopub.execute_input":"2022-01-05T09:37:31.445177Z","iopub.status.idle":"2022-01-05T09:37:31.471239Z","shell.execute_reply.started":"2022-01-05T09:37:31.445131Z","shell.execute_reply":"2022-01-05T09:37:31.470428Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.dtypes","metadata":{"execution":{"iopub.status.busy":"2022-01-05T09:37:31.472713Z","iopub.execute_input":"2022-01-05T09:37:31.473301Z","iopub.status.idle":"2022-01-05T09:37:31.481489Z","shell.execute_reply.started":"2022-01-05T09:37:31.473239Z","shell.execute_reply":"2022-01-05T09:37:31.480855Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-01-05T09:37:31.482781Z","iopub.execute_input":"2022-01-05T09:37:31.483229Z","iopub.status.idle":"2022-01-05T09:37:31.959218Z","shell.execute_reply.started":"2022-01-05T09:37:31.483192Z","shell.execute_reply":"2022-01-05T09:37:31.958344Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.shape","metadata":{"execution":{"iopub.status.busy":"2022-01-05T09:37:31.960471Z","iopub.execute_input":"2022-01-05T09:37:31.960784Z","iopub.status.idle":"2022-01-05T09:37:31.966156Z","shell.execute_reply.started":"2022-01-05T09:37:31.960741Z","shell.execute_reply":"2022-01-05T09:37:31.965356Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y = train.Target\nx = train.drop(['Target'], axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-01-05T09:37:31.96738Z","iopub.execute_input":"2022-01-05T09:37:31.967686Z","iopub.status.idle":"2022-01-05T09:37:32.589432Z","shell.execute_reply.started":"2022-01-05T09:37:31.967644Z","shell.execute_reply":"2022-01-05T09:37:32.588533Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y.shape, x.shape","metadata":{"execution":{"iopub.status.busy":"2022-01-05T09:37:32.590684Z","iopub.execute_input":"2022-01-05T09:37:32.590932Z","iopub.status.idle":"2022-01-05T09:37:32.596894Z","shell.execute_reply.started":"2022-01-05T09:37:32.590901Z","shell.execute_reply":"2022-01-05T09:37:32.596069Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}