fynance.neural_networks.RollNeuralNet¶
-
class
fynance.neural_networks.
RollNeuralNet
(train_period=252, estim_period=63, value_init=100, target_filter='sign', params=None)¶ Object to train/test a neural network along time axis.
Rolling Neural Network object allow you to train neural networks along training periods (from t - n to t) and predict along testing periods (from t to t + s) and roll along this time axis.
Attributes: - y : np.ndarray[np.float32, ndim=2] with shape=(T, 1)
Target to predict, a good practice is to use log-returns.
- X : np.ndarray[np.float32, ndim=2] with shape=(T, N)
Features (inputs).
- NN : keras.Model
Neural network to train and predict.
- y_train : np.ndarray[np.float64, ndim=1]
Prediction on training set.
- y_estim : np.ndarray[np.float64, ndim=1]
Prediction on estimating set.
Methods
run(y, X, NN, plot_loss=True, plot_perf=True, x_axis=None) Train rolling neural networks along pre-specified training period and predict along test period. Display loss and performance if specified. __call__(y, X, NN, start=0, end=1e8, x_axis=None) Callable method to set target and features data, neural network object (Keras object is prefered). __iter__() Train and predict along time axis from day number n to last day number T and by step of size s period. plot_loss(self, f, ax) Plot loss function plot_perf(self, f, ax) Plot perfomances.