Boppity Bop
Boppity Bop

Reputation: 10463

How can I weight inputs for Keras model on tensorflow?

I want to predict a time series value (regression task). But I need to tell the machine that recent observations in a batch relate stronger to the label than older ones.

In other words - I want to weight input values. How can this be done?

Upvotes: 0

Views: 517

Answers (1)

razimbres
razimbres

Reputation: 5005

You can use autocorrelation of Y with itself using a time lag, like:

time_lag=4
x_train=dataframe[0:-timelag]
y_train=dataframe[time_lag:]

from pandas.plotting import autocorrelation_plot

autocorrelation_plot(dataframe)

You will notice autocorrelation will decrease its value with more distant values.

However, a proper neural network will learn that without being explicitly programmed, given that correlation with close values will naturally be bigger, and so the weights, in absolute values.

Upvotes: 1

Related Questions