<jupyter_start><jupyter_text>Train<jupyter_code>data = pd.read_csv('data/terra/train.csv')
data = pd.read_csv('data/terra/train.csv')
data['ds'] = pd.to_datetime(data['day'], unit='d')
data['unique_id'] = data['cultivar'] + data['sitename']
data = data.rename(columns={'canopy_height':'y'})

#Series must be complete in the frequency
data = ffill_missing_dates_per_serie(data,'D')
data = data.drop_duplicates(['unique_id','ds'])

data.head()
X_train = data[['unique_id','ds']]
X_train['x'] = '1'
y_train = data[['unique_id','ds','y']]
data_plot = y_train[y_train['unique_id']=='PI157030MAC Field Scanner Season 4 Range 17 Column 14']
plt.plot(data_plot['ds'], data_plot['y'], label = 'y')
plt.show()<jupyter_output>/Users/cchallu/anaconda3/envs/esrnn_torch/lib/python3.6/site-packages/pandas/plotting/_matplotlib/converter.py:103: FutureWarning: Using an implicitly registered datetime converter for a matplotlib plotting method. The converter was registered by pandas on import. Future versions of pandas will require you to explicitly register matplotlib converters.

To register the converters:
	>>> from pandas.plotting import register_matplotlib_converters
	>>> register_matplotlib_converters()
  warnings.warn(msg, FutureWarning)<jupyter_text>Test<jupyter_code>data_test = pd.read_csv('data/terra/test_real.csv')
data_test['ds'] = pd.to_datetime(data_test['day'], unit='d')
data_test['unique_id'] = data_test['cultivar'] + data_test['sitename']
data_test.head()
X_test = data_test[['unique_id','ds','canopy_height']]
X_test.columns = ['unique_id', 'ds', 'y']
uniques = X_test['unique_id'].unique()
# Train model
esrnn = ESRNN(max_epochs=1, batch_size=16, learning_rate=3e-4, gradient_clipping_threshold=20,
              dilations=[[1, 7], [28]], add_nl_layer=True, per_series_lr_multip=1.0, 
              seasonality=[], input_size=7, output_size=50, max_periods=20, level_variability_penalty=80,
              training_percentile=60, rnn_weight_decay=0)
esrnn.fit(X_train, y_train)
y_hat = esrnn.predict(X_test[['unique_id']])
X_plot = y_train.append(y_hat)
plot_id = 0
y_test_plot = X_plot.loc[X_plot['unique_id']==uniques[plot_id]]
plot_prediction(y_test_plot['y'], y_test_plot['y_hat'])
y_hat = esrnn.predict(X_test[['unique_id','ds','y']])
np.abs(y_hat['y_hat']-y_hat['y']).mean()<jupyter_output><empty_output>