-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Additional features #5
Comments
That's mostly data preparation, there are many ways to do it. Your aim is to include features in
You also need to remove at line 155:
|
Hello Hong,
Thanks for your quick response, however I am not getting it to work.
I tried changing the following:
Note fea is the dataset with the additional features.
class Normalizer_Fea():
def __init__(self):
self.mu = None
self.sd = None
def fit_transform_Fea(self, x):
self.mu = np.mean(x, axis=(0), keepdims=True)
self.sd = np.std(x, axis=(0), keepdims=True)
normalized_x = (x - self.mu)/self.sd
return normalized_x
def inverse_transform_Fea(self, x):
return (x*self.sd) + self.mu
# normalize features
scaler_fea = Normalizer_Fea()
normalized_fea = scaler_fea.fit_transform_Fea(fea)
def prepare_data_x(x, window_size):
# perform windowing
n_row = x.shape[0] - window_size + 1
output = np.lib.stride_tricks.as_strided(x, shape=(n_row, window_size), strides=(x.strides[0], x.strides[0]))
return output[:-1], output[-1]
def prepare_data_y(x, window_size):
# # perform simple moving average
# output = np.convolve(x, np.ones(window_size), 'valid') / window_size
# use the next day as label
output = x[window_size:]
return output
data_x, data_x_unseen = prepare_data_x(normalized_fea, window_size=config["data"]["window_size"])
data_y = prepare_data_y(normalized_data_close_price, window_size=config["data"]["window_size"])
split_index = int(data_y.shape[0]*config["data"]["train_split_size"])
data_x_train = data_x[:split_index, :]
data_x_val = data_x[split_index:, :]
data_y_train = data_y[:split_index]
data_y_val = data_y[split_index:]
Then I applied your changes and now receiving this error:
RuntimeError: mat1 and mat2 shapes cannot be multiplied (64x16 and 1x32)
Regards,
Dexter Gellizeau
Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10
From: Hong Jing ***@***.***>
Sent: Thursday, June 10, 2021 11:20 PM
To: ***@***.***>
Cc: ***@***.***>; ***@***.***>
Subject: Re: [jinglescode/time-series-forecasting-pytorch] Additional features (#5)
That's mostly data preparation, there are many ways to do it. Your aim is to include features in data_x_train and data_x_val, before creating the PyTorch Dataset at line 167<https://github.com/jinglescode/time-series-forecasting-pytorch/blob/main/project.py#L167>:
dataset_train = TimeSeriesDataset(data_x_train, data_y_train)
dataset_val = TimeSeriesDataset(data_x_val, data_y_val)
You also need to remove at line 155<https://github.com/jinglescode/time-series-forecasting-pytorch/blob/main/project.py#L155>:
x = np.expand_dims(x, 2) # in our case, we have only 1 feature, so we need to convert `x` into [batch, sequence, features] for LSTM
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#5 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AUN6P7U2UQPGBOEQLX6CVN3TSF6IVANCNFSM46PT6MFA>.
|
hi @Dextergellizeau , were you able to get the code running? i'm also trying to do the same but not able to get the code running. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
Please show how to add additional features (such as a technical indicator) to the script to help in prediction.
The text was updated successfully, but these errors were encountered: