# Solution to TIMSER

It is just simple linear regression with log transformation (Here I did log log transformation but log transformation alone gives pretty much the same results). More importantly, I ignored training data completely as it is too much in the past and just introduces noise (most of the training data are from before the 2007 crisis, so it is to be expected that it is not very informative post-2007). I used only validation data for regression.

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression

# In:

X=np.arange(len(val_df)).reshape(-1,1)
Y=val_df.iloc[:,1].values.reshape(-1,1)
Y=np.log(Y)
Y=np.log(Y)

# In:

linear_regressor=LinearRegression(normalize=True)

# In:

linear_regressor.fit(X,Y)

# In:

test_X=np.arange(len(val_df),len(val_df)+1904).reshape(-1,1)

# In:

Y_pred=linear_regressor.predict(test_X)

# In:

plt.scatter(X,Y)
plt.plot(test_X, Y_pred, color=‘red’)
plt.show()

# In:

Y_pred= np.exp(np.exp(Y_pred))

# In:

Y_pred=pd.DataFrame(data=Y_pred, index=np.array(range(1904)), columns=np.array(range(1)))

# In:

subm[‘value’]=Y_pred

# In:

subma=subm.to_csv(‘submission.csv’)