deshpandenu / Time-Series-Forecasting-of-Amazon-Stock-Prices-using-Neural-Networks-LSTM-and-GAN-

Project analyzes Amazon Stock data using Python. Feature Extraction is performed and ARIMA and Fourier series models are made. LSTM is used with multiple features to predict stock prices and then sentimental analysis is performed using news and reddit sentiments. GANs are used to predict stock data too where Amazon data is taken from an API as Generator and CNNs are used as discriminator.
399 stars 121 forks source link

Outdated Libraries - Error when running the example #9

Closed Rajmehta123 closed 3 years ago

Rajmehta123 commented 3 years ago

Amazing project. Thanks for the contribution.

The code fails during the execution of TrainXGBoost due to the outdated library. XGBoost no longer allows a list of NumPy arrays. It always has to have the input as a 2D array.

image

https://github.com/dmlc/xgboost/pull/3970

Answer to the XGBoost list input to DMatrix: @markli123 Hi, I actually found the cause of the weird behavior. See https://github.com/dmlc/xgboost/pull/3970 8. The list gets silently converted into scipy.sparse.csr_matrix, which causes unexpected behavior causing wrong prediction. This is why we later disallowed converting list into a DMatrix directly.

Rajmehta123 commented 3 years ago

Solved by changing the list of arrays to a data frame.

        self.data = [x.reshape(1,-1) for x in self.data]
        self.labels = [x.reshape(1,-1) for x in self.labels]
        self.data = pd.DataFrame(np.concatenate(self.data))
        self.labels = pd.DataFrame(np.concatenate(self.labels))

        self.test_data = [x.reshape(1,-1) for x in self.test_data]
        self.test_labels = [x.reshape(1,-1) for x in self.test_labels]
        self.test_data = pd.DataFrame(np.concatenate(self.test_data))
        self.test_labels = pd.DataFrame(np.concatenate(self.test_labels))