{"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":"# G-Research | Exploratory Data Analysis (EDA)\n\n### Acknowledgements 😍\nMy acknowledgments are given to: \n1. [Yam Peleg. G-Research: XGBoost with GPU (Fit in 1min)](https://www.kaggle.com/yamqwe/g-research-xgboost-with-gpu-fit-in-1min).\n2. [Carlos Stein N Brito. Tutorial to the G-Research Crypto Competition](https://www.kaggle.com/cstein06/tutorial-to-the-g-research-crypto-competition).\n\n### About 💸\nIn the G-Research Crypto forecasting competition, participants have the challenge to predict price returns across a bundle of major cryptocurrencies. ","metadata":{}},{"cell_type":"markdown","source":"### 1. Import libraries","metadata":{}},{"cell_type":"code","source":"import time\nimport pandas as pd\nimport numpy as np\nimport scipy.stats as stats\nfrom datetime import datetime\nimport matplotlib.pyplot as plt\nimport plotly.graph_objects as go\nfrom sklearn.preprocessing import StandardScaler\nfrom sklearn.linear_model import LinearRegression\nfrom sklearn.multioutput import MultiOutputRegressor","metadata":{"execution":{"iopub.status.busy":"2022-01-26T13:22:52.878499Z","iopub.execute_input":"2022-01-26T13:22:52.878771Z","iopub.status.idle":"2022-01-26T13:22:52.888113Z","shell.execute_reply.started":"2022-01-26T13:22:52.878741Z","shell.execute_reply":"2022-01-26T13:22:52.887217Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### 2. Read data","metadata":{}},{"cell_type":"code","source":"data_folder = \"../input/g-research-crypto-forecasting/\"\ncrypto_df = pd.read_csv(data_folder + 'train.csv')\ncrypto_df.head(10)","metadata":{"execution":{"iopub.status.busy":"2022-01-26T13:04:45.796389Z","iopub.execute_input":"2022-01-26T13:04:45.796811Z","iopub.status.idle":"2022-01-26T13:05:17.284512Z","shell.execute_reply.started":"2022-01-26T13:04:45.796769Z","shell.execute_reply":"2022-01-26T13:05:17.283838Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Our aim is to predict **\"Target\" column**. The full description of each column you can find [here](https://www.kaggle.com/cstein06/tutorial-to-the-g-research-crypto-competition?scriptVersionId=84976518&cellId=12). \n\nWe also can check the **asset information**, including the list of all assets, the Asset_ID to asset mapping, and the weight of each asset used to weigh their relative importance in the evaluation metric.","metadata":{}},{"cell_type":"code","source":"asset_details = pd.read_csv(data_folder + 'asset_details.csv')\nasset_details","metadata":{"execution":{"iopub.status.busy":"2022-01-26T13:05:17.285815Z","iopub.execute_input":"2022-01-26T13:05:17.287144Z","iopub.status.idle":"2022-01-26T13:05:17.302467Z","shell.execute_reply.started":"2022-01-26T13:05:17.287105Z","shell.execute_reply":"2022-01-26T13:05:17.301812Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### 3. Visualize data: Candlestick Bar\nThe trading data format is an aggregated form of market data including for Open, High, Low and Close. We can visualize this data through the commonly used **candlestick bar** chart, which allows traders to perform technical analysis on intraday values. \n\nThe **bar's body length** represents the price range between the open and close of that day's trading. When the bar is **red**, it means the close was lower than the open, and **green** otherwise. These are also referred to as bullish and bearish candlesticks. The wicks above and below the bars show the high and low prices of that interval's trading.\n\nThe bottom part of the plot shows a **rangeslider**, which you can use to zoom in the plot.","metadata":{}},{"cell_type":"code","source":"# Asset_ID = 1 for Bitcoin, for example\nbtc = crypto_df[crypto_df[\"Asset_ID\"]==1].set_index(\"timestamp\") \n\n# select recent data rows\nbtc_mini = btc.iloc[-200:] \n\nfig = go.Figure(data=[go.Candlestick(x=btc_mini.index, \n                                     open=btc_mini['Open'], \n                                     high=btc_mini['High'], \n                                     low=btc_mini['Low'], \n                                     close=btc_mini['Close'])])\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-01-26T13:05:17.304251Z","iopub.execute_input":"2022-01-26T13:05:17.304922Z","iopub.status.idle":"2022-01-26T13:05:17.688529Z","shell.execute_reply.started":"2022-01-26T13:05:17.304886Z","shell.execute_reply":"2022-01-26T13:05:17.687863Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### 4. Exploratory Data Analysis (EDA). Check for missing data","metadata":{}},{"cell_type":"code","source":"# Asset_ID = 6 for Ethereum, as example\neth = crypto_df[crypto_df[\"Asset_ID\"]==6].set_index(\"timestamp\") \neth.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2022-01-26T13:05:17.689832Z","iopub.execute_input":"2022-01-26T13:05:17.690658Z","iopub.status.idle":"2022-01-26T13:05:18.037568Z","shell.execute_reply.started":"2022-01-26T13:05:17.690622Z","shell.execute_reply":"2022-01-26T13:05:18.036882Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"As we can see, there are 340 missed \"Target\" values. \n\nLet's check the time range for Bitcoin and Ethereum data, using the coversion from timestamp to datetime.","metadata":{}},{"cell_type":"code","source":"beg_btc = btc.index[0].astype('datetime64[s]')\nend_btc = btc.index[-1].astype('datetime64[s]')\nbeg_eth = eth.index[0].astype('datetime64[s]')\nend_eth = eth.index[-1].astype('datetime64[s]')\n\nprint('BTC data goes from ', beg_btc, 'to ', end_btc)\nprint('Ethereum data goes from ', beg_eth, 'to ', end_eth)","metadata":{"execution":{"iopub.status.busy":"2022-01-26T13:05:18.038839Z","iopub.execute_input":"2022-01-26T13:05:18.039235Z","iopub.status.idle":"2022-01-26T13:05:18.047488Z","shell.execute_reply.started":"2022-01-26T13:05:18.0392Z","shell.execute_reply":"2022-01-26T13:05:18.04668Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"After that, we'll check for timegaps:","metadata":{}},{"cell_type":"code","source":"(eth.index[1:]-eth.index[:-1]).value_counts().head()","metadata":{"execution":{"iopub.status.busy":"2022-01-26T13:05:18.049113Z","iopub.execute_input":"2022-01-26T13:05:18.049771Z","iopub.status.idle":"2022-01-26T13:05:18.080352Z","shell.execute_reply.started":"2022-01-26T13:05:18.049734Z","shell.execute_reply":"2022-01-26T13:05:18.079614Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"To work with most time series models, we should preprocess our data into a format **without time gaps**. To fill the gaps, we can use the **.reindex()** method for forward filling, filling gaps with the previous valid value.","metadata":{}},{"cell_type":"code","source":"eth = eth.reindex(range(eth.index[0],eth.index[-1]+60,60),method='pad')\nbtc = btc.reindex(range(btc.index[0],btc.index[-1]+60,60),method='pad')","metadata":{"execution":{"iopub.status.busy":"2022-01-26T13:05:18.082033Z","iopub.execute_input":"2022-01-26T13:05:18.082554Z","iopub.status.idle":"2022-01-26T13:05:18.62913Z","shell.execute_reply.started":"2022-01-26T13:05:18.082517Z","shell.execute_reply":"2022-01-26T13:05:18.628357Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"And check that are no time gaps now:","metadata":{}},{"cell_type":"code","source":"(eth.index[1:]-eth.index[:-1]).value_counts().head()","metadata":{"execution":{"iopub.status.busy":"2022-01-26T13:05:18.630584Z","iopub.execute_input":"2022-01-26T13:05:18.631413Z","iopub.status.idle":"2022-01-26T13:05:18.670638Z","shell.execute_reply.started":"2022-01-26T13:05:18.631373Z","shell.execute_reply":"2022-01-26T13:05:18.669822Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"(btc.index[1:]-btc.index[:-1]).value_counts().head()","metadata":{"execution":{"iopub.status.busy":"2022-01-26T13:05:18.673404Z","iopub.execute_input":"2022-01-26T13:05:18.673666Z","iopub.status.idle":"2022-01-26T13:05:18.706067Z","shell.execute_reply.started":"2022-01-26T13:05:18.67363Z","shell.execute_reply":"2022-01-26T13:05:18.705249Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### 5. Data visualisation","metadata":{}},{"cell_type":"code","source":"# plot vwap time series for both chosen assets\nf = plt.figure(figsize=(15,4))\n\nax = f.add_subplot(121)\nplt.plot(btc['Close'], color = 'green', label='BTC')\nplt.legend()\nplt.xlabel('Time')\nplt.ylabel('Bitcoin')\n\nax2 = f.add_subplot(122)\nax2.plot(eth['Close'], color='orange', label='ETH')\nplt.legend()\nplt.xlabel('Time')\nplt.ylabel('Ethereum')\n\nplt.tight_layout()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-01-26T13:05:18.707645Z","iopub.execute_input":"2022-01-26T13:05:18.707899Z","iopub.status.idle":"2022-01-26T13:05:21.178607Z","shell.execute_reply.started":"2022-01-26T13:05:18.707865Z","shell.execute_reply":"2022-01-26T13:05:21.177928Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"After that we could check if they correlate in recent time: ","metadata":{}},{"cell_type":"code","source":"# auxiliary function, from datetime to timestamp\ntotimestamp = lambda s: np.int32(time.mktime(datetime.strptime(s, \"%d/%m/%Y\").timetuple()))\n\n# create intervals \nbtc_mini_2021 = btc.loc[totimestamp('01/06/2021'):totimestamp('01/07/2021')]\neth_mini_2021 = eth.loc[totimestamp('01/06/2021'):totimestamp('01/07/2021')]","metadata":{"execution":{"iopub.status.busy":"2022-01-26T13:05:21.179708Z","iopub.execute_input":"2022-01-26T13:05:21.180099Z","iopub.status.idle":"2022-01-26T13:05:21.187042Z","shell.execute_reply.started":"2022-01-26T13:05:21.180054Z","shell.execute_reply":"2022-01-26T13:05:21.18613Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# plot time series for both chosen assets\nf = plt.figure(figsize=(7,8))\n\nax = f.add_subplot(211)\nplt.plot(btc_mini_2021['Close'], label='btc')\nplt.legend()\nplt.xlabel('Time')\nplt.ylabel('Bitcoin Close')\n\nax2 = f.add_subplot(212)\nax2.plot(eth_mini_2021['Close'], color='red', label='eth')\nplt.legend()\nplt.xlabel('Time')\nplt.ylabel('Ethereum Close')\n\nplt.tight_layout()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-01-26T13:05:21.188484Z","iopub.execute_input":"2022-01-26T13:05:21.188744Z","iopub.status.idle":"2022-01-26T13:05:21.591125Z","shell.execute_reply.started":"2022-01-26T13:05:21.188709Z","shell.execute_reply":"2022-01-26T13:05:21.59043Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Log returns\nIn order to analyze price changes for an asset we can deal with the price difference. However, different assets exhibit different price scales, so that the their returns are not readily comparable. We can solve this problem by computing the percentage change in price instead, also known as the return. This return coincides with the percentage change in our invested capital.","metadata":{}},{"cell_type":"code","source":"# define function to compute log returns\ndef log_return(series, periods=1):\n    return np.log(series).diff(periods=periods)","metadata":{"execution":{"iopub.status.busy":"2022-01-26T13:05:21.592608Z","iopub.execute_input":"2022-01-26T13:05:21.59312Z","iopub.status.idle":"2022-01-26T13:05:21.597092Z","shell.execute_reply.started":"2022-01-26T13:05:21.593083Z","shell.execute_reply":"2022-01-26T13:05:21.596447Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"lret_btc = log_return(btc_mini_2021.Close)[1:]\nlret_eth = log_return(eth_mini_2021.Close)[1:]\nlret_btc.rename('lret_btc', inplace=True)\nlret_eth.rename('lret_eth', inplace=True)\n\nplt.figure(figsize=(8,4))\nplt.plot(lret_btc);\nplt.plot(lret_eth);\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-01-26T13:05:21.598464Z","iopub.execute_input":"2022-01-26T13:05:21.598957Z","iopub.status.idle":"2022-01-26T13:05:21.827312Z","shell.execute_reply.started":"2022-01-26T13:05:21.59892Z","shell.execute_reply":"2022-01-26T13:05:21.82662Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Correlation between assets\nWe can check how the correlation between Bitcoin and Ethereum change over time for the 2021 period we selected.","metadata":{}},{"cell_type":"code","source":"# join two asset in single DataFrame\n\nlret_btc_long = log_return(btc.Close)[1:]\nlret_eth_long = log_return(eth.Close)[1:]\nlret_btc_long.rename('lret_btc', inplace=True)\nlret_eth_long.rename('lret_eth', inplace=True)\ntwo_assets = pd.concat([lret_btc_long, lret_eth_long], axis=1)\n\n# group consecutive rows and use .corr() for correlation between columns\ncorr_time = two_assets.groupby(two_assets.index//(10000*60)).corr().loc[:,\"lret_btc\"].loc[:,\"lret_eth\"]\n\ncorr_time.plot()\nplt.xticks([])\nplt.ylabel(\"Correlation\")\nplt.title(\"Correlation between BTC and ETH over time\")\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-01-26T13:12:25.992404Z","iopub.execute_input":"2022-01-26T13:12:25.992675Z","iopub.status.idle":"2022-01-26T13:12:26.358779Z","shell.execute_reply.started":"2022-01-26T13:12:25.992646Z","shell.execute_reply":"2022-01-26T13:12:26.357951Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Note the high but variable correlation between the assets. Here we can see that there is some changing dynamics over time, and this would be critical for this time series challenge, that is, how to perform forecasts in a highly non-stationary environment.\n\nA stationary behaviour of a system or a process is characterized by non-changing statistical properties over time such as the mean, variance and autocorrelation. On the other hand, a non-stationary behaviour is characterized by a continuous change of statistical properties over time. Stationarity is important because many useful analytical tools and statistical tests and models rely on it.\n\nWe can also check the correlation between all assets visualizing the correlation matrix. Note how some assets have much higher pairwise correlation than others.","metadata":{}},{"cell_type":"code","source":"# create dataframe with returns for all assets\nall_assets_2021 = pd.DataFrame([])\nfor asset_id, asset_name in zip(asset_details.Asset_ID, asset_details.Asset_Name):\n    asset = crypto_df[crypto_df[\"Asset_ID\"]==asset_id].set_index(\"timestamp\")\n    asset = asset.loc[totimestamp('01/01/2021'):totimestamp('01/05/2021')]\n    asset = asset.reindex(range(asset.index[0],asset.index[-1]+60,60),method='pad')\n    lret = log_return(asset.Close.fillna(0))[1:]\n    all_assets_2021 = all_assets_2021.join(lret, rsuffix=asset_name, how=\"outer\")","metadata":{"execution":{"iopub.status.busy":"2022-01-26T13:15:55.632234Z","iopub.execute_input":"2022-01-26T13:15:55.632502Z","iopub.status.idle":"2022-01-26T13:15:59.65702Z","shell.execute_reply.started":"2022-01-26T13:15:55.632472Z","shell.execute_reply":"2022-01-26T13:15:59.65628Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"asset_details.Asset_ID","metadata":{"execution":{"iopub.status.busy":"2022-01-26T13:16:08.643216Z","iopub.execute_input":"2022-01-26T13:16:08.64396Z","iopub.status.idle":"2022-01-26T13:16:08.652527Z","shell.execute_reply.started":"2022-01-26T13:16:08.643919Z","shell.execute_reply":"2022-01-26T13:16:08.651659Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"asset_details.Asset_Name","metadata":{"execution":{"iopub.status.busy":"2022-01-26T13:16:12.253967Z","iopub.execute_input":"2022-01-26T13:16:12.25457Z","iopub.status.idle":"2022-01-26T13:16:12.2611Z","shell.execute_reply.started":"2022-01-26T13:16:12.254522Z","shell.execute_reply":"2022-01-26T13:16:12.260299Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.imshow(all_assets_2021.corr());\nplt.yticks(range(14), asset_details.Asset_Name.values);\nplt.xticks(range(14), asset_details.Asset_Name.values, rotation='vertical');\nplt.colorbar()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-01-26T13:16:27.061515Z","iopub.execute_input":"2022-01-26T13:16:27.061764Z","iopub.status.idle":"2022-01-26T13:16:27.453517Z","shell.execute_reply.started":"2022-01-26T13:16:27.061734Z","shell.execute_reply":"2022-01-26T13:16:27.452854Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### 6. Predictions\n### Feature engineering ","metadata":{}},{"cell_type":"code","source":"# Select some input features from the trading data: \n# 5 min log return, abs(5 min log return), upper shadow, and lower shadow.\nupper_shadow = lambda asset: asset.High - np.maximum(asset.Close,asset.Open)\nlower_shadow = lambda asset: np.minimum(asset.Close,asset.Open)- asset.Low\n\nX_btc = pd.concat([log_return(btc.VWAP,periods=5), \n                   log_return(btc.VWAP,periods=1).abs(), \n                   upper_shadow(btc), \n                   lower_shadow(btc)], axis=1)\ny_btc = btc.Target\n\nX_eth = pd.concat([log_return(eth.VWAP,periods=5), \n                   log_return(eth.VWAP,periods=1).abs(), \n                   upper_shadow(eth), \n                   lower_shadow(eth)], axis=1)\ny_eth = eth.Target","metadata":{"execution":{"iopub.status.busy":"2022-01-26T13:19:52.478106Z","iopub.execute_input":"2022-01-26T13:19:52.478864Z","iopub.status.idle":"2022-01-26T13:19:52.641976Z","shell.execute_reply.started":"2022-01-26T13:19:52.478822Z","shell.execute_reply":"2022-01-26T13:19:52.641223Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Preparing the data for building predictive models\nAs we will train linear regression parameters, we need to separate training and test sets. To do so, we will compute X and y and split this data into train and test splits.","metadata":{}},{"cell_type":"code","source":"# select training and test periods\ntrain_window = [totimestamp(\"01/05/2021\"), totimestamp(\"30/05/2021\")]\ntest_window = [totimestamp(\"01/06/2021\"), totimestamp(\"30/06/2021\")]\n\n# divide data into train and test, compute X and y\n# we aim to build simple regression models using a window_size of 1\nX_btc_train = X_btc.loc[train_window[0]:train_window[1]].fillna(0).to_numpy()  # filling NaN's with zeros\ny_btc_train = y_btc.loc[train_window[0]:train_window[1]].fillna(0).to_numpy()  \n\nX_btc_test = X_btc.loc[test_window[0]:test_window[1]].fillna(0).to_numpy() \ny_btc_test = y_btc.loc[test_window[0]:test_window[1]].fillna(0).to_numpy() \n\nX_eth_train = X_eth.loc[train_window[0]:train_window[1]].fillna(0).to_numpy()  \ny_eth_train = y_eth.loc[train_window[0]:train_window[1]].fillna(0).to_numpy()  \n\nX_eth_test = X_eth.loc[test_window[0]:test_window[1]].fillna(0).to_numpy() \ny_eth_test = y_eth.loc[test_window[0]:test_window[1]].fillna(0).to_numpy() ","metadata":{"execution":{"iopub.status.busy":"2022-01-26T13:21:08.943821Z","iopub.execute_input":"2022-01-26T13:21:08.944108Z","iopub.status.idle":"2022-01-26T13:21:08.95971Z","shell.execute_reply.started":"2022-01-26T13:21:08.944077Z","shell.execute_reply":"2022-01-26T13:21:08.958789Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Normalize data","metadata":{}},{"cell_type":"code","source":"# simple preprocessing of the data \nscaler = StandardScaler()\n\nX_btc_train_scaled = scaler.fit_transform(X_btc_train)\nX_btc_test_scaled = scaler.transform(X_btc_test)\n\nX_eth_train_scaled = scaler.fit_transform(X_eth_train)\nX_eth_test_scaled = scaler.transform(X_eth_test)","metadata":{"execution":{"iopub.status.busy":"2022-01-26T13:21:48.314592Z","iopub.execute_input":"2022-01-26T13:21:48.314844Z","iopub.status.idle":"2022-01-26T13:21:48.329595Z","shell.execute_reply.started":"2022-01-26T13:21:48.314814Z","shell.execute_reply":"2022-01-26T13:21:48.328945Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Linear Regression","metadata":{}},{"cell_type":"code","source":"# implement basic ML baseline (one per asset)\nlr = LinearRegression()\nlr.fit(X_btc_train_scaled,y_btc_train)\ny_pred_lr_btc = lr.predict(X_btc_test_scaled)\n\nlr.fit(X_eth_train_scaled,y_eth_train)\ny_pred_lr_eth = lr.predict(X_eth_test_scaled)","metadata":{"execution":{"iopub.status.busy":"2022-01-26T13:22:40.567988Z","iopub.execute_input":"2022-01-26T13:22:40.568668Z","iopub.status.idle":"2022-01-26T13:22:40.600461Z","shell.execute_reply.started":"2022-01-26T13:22:40.568626Z","shell.execute_reply":"2022-01-26T13:22:40.599614Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# we concatenate X and y for both assets\nX_both_train = np.concatenate((X_btc_train_scaled, X_eth_train_scaled), axis=1)\nX_both_test = np.concatenate((X_btc_test_scaled, X_eth_test_scaled), axis=1)\ny_both_train = np.column_stack((y_btc_train, y_eth_train))\ny_both_test = np.column_stack((y_btc_test, y_eth_test))\n\n# define the direct multioutput model and fit it\nmlr = MultiOutputRegressor(LinearRegression())\nmlr.fit(X_both_train,y_both_train)\ny_pred_lr_both = mlr.predict(X_both_test)","metadata":{"execution":{"iopub.status.busy":"2022-01-26T13:23:01.260828Z","iopub.execute_input":"2022-01-26T13:23:01.261107Z","iopub.status.idle":"2022-01-26T13:23:01.287129Z","shell.execute_reply.started":"2022-01-26T13:23:01.261075Z","shell.execute_reply":"2022-01-26T13:23:01.286399Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Evaluate results","metadata":{}},{"cell_type":"code","source":"print('Test score for LR baseline: BTC', \n      f\"{np.corrcoef(y_pred_lr_btc, y_btc_test)[0,1]:.2f}\", ', ETH', \n      f\"{np.corrcoef(y_pred_lr_eth, y_eth_test)[0,1]:.2f}\")\n\nprint('Test score for multiple output LR baseline: BTC', \n      f\"{np.corrcoef(y_pred_lr_both[:,0], y_btc_test)[0,1]:.2f}\",', ETH', \n      f\"{np.corrcoef(y_pred_lr_both[:,1], y_eth_test)[0,1]:.2f}\")","metadata":{"execution":{"iopub.status.busy":"2022-01-26T13:24:06.340491Z","iopub.execute_input":"2022-01-26T13:24:06.340772Z","iopub.status.idle":"2022-01-26T13:24:06.351744Z","shell.execute_reply.started":"2022-01-26T13:24:06.340739Z","shell.execute_reply":"2022-01-26T13:24:06.350865Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### 7. Conclusion\nThank you for reading my new article! If you liked it, please, make an upvote 💖\n\n*My other articles:*\n\n* [G-Research Forecast | Overlap | Score = 0.9999](https://www.kaggle.com/maricinnamon/g-research-forecast-overlap-score-0-9999)\n* [Harry Potter Movies Dataset | Starter Notebook](https://www.kaggle.com/maricinnamon/harry-potter-movies-dataset-starter-notebook)\n* [Contradictory, My Dear Watson | nlp | tensorflow](https://www.kaggle.com/maricinnamon/contradictory-my-dear-watson-nlp-tensorflow)\n\n👉 More articles you can find on my [page](http://https://www.kaggle.com/maricinnamon/code?userId=3717445&sortBy=dateRun&tab=profile&privacy=public).\n","metadata":{}}]}