Open personal-coding opened 4 years ago
I receive the below error when running this line test_dataset.add_technical_indicator(random_forest)
test_dataset.add_technical_indicator(random_forest)
Traceback (most recent call last): File "C:/Users/russi/PycharmProjects/stock-market-prediction-master/Stock Master.py", line 59, in <module> test_dataset.add_technical_indicator(random_forest) File "C:\Users\russi\AppData\Local\Programs\Python\Python36\lib\site-packages\nowtrade\dataset.py", line 127, in add_technical_indicator technical_indicator.results(self.data_frame) File "C:\Users\russi\AppData\Local\Programs\Python\Python36\lib\site-packages\nowtrade\technical_indicator.py", line 588, in results res = self.ensemble.activate_all(data_frame) File "C:\Users\russi\AppData\Local\Programs\Python\Python36\lib\site-packages\nowtrade\ensemble.py", line 188, in activate_all res.append(self._activate(values)) File "C:\Users\russi\AppData\Local\Programs\Python\Python36\lib\site-packages\nowtrade\ensemble.py", line 173, in _activate return self.ensemble.predict(data)[0] File "C:\Users\russi\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\ensemble\forest.py", line 693, in predict X = self._validate_X_predict(X) File "C:\Users\russi\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\ensemble\forest.py", line 359, in _validate_X_predict return self.estimators_[0]._validate_X_predict(X, check_input=True) File "C:\Users\russi\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\tree\tree.py", line 391, in _validate_X_predict X = check_array(X, dtype=DTYPE, accept_sparse="csr") File "C:\Users\russi\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\utils\validation.py", line 521, in check_array "if it contains a single sample.".format(array)) ValueError: Expected 2D array, got 1D array instead: array=[ 6.636209 6.636209 6.616788 6.632581 15.030156 6.6386986 6.645351 6.6275783 6.6353297 14.631229 6.6205664 6.6408296 6.617403 6.6324363 14.695262 6.615382 6.627128 6.600251 6.6080008 14.965006 6.6171355 6.620233 6.591564 6.5942903 14.6806345 6.595712 6.5999794 6.57864 6.5972414 14.749562 6.607663 6.6178575 6.6018143 6.6138406 14.666003 6.619193 6.6240654 6.574769 6.578654 14.765778 6.585399 6.6065016 6.558198 6.594947 14.837206 6.565251 6.5850124 6.553235 6.5659547 15.159367 6.5794597 6.586654 6.5650535 6.5779724 14.70595 6.5594735 6.5888577 6.533469 6.577249 15.231849 6.5794873 6.6034966 6.5668273 6.5884724 14.769829 6.6093493 6.618151 6.6073256 6.6140013 14.673027 6.611826 6.6233478 6.596463 6.597991 14.633968 6.6001563 6.6059203 6.5888853 6.5982227 14.251828 6.601081 6.601081 6.570112 6.5758843 14.567587 6.6042013 6.6216187 6.593866 6.617804 14.948588 6.6186857 6.6400194 6.61231 6.635093 15.147982 6.6480255 6.6561995 6.635133 6.64739 15.534 6.6852365 6.6974664 6.660063 6.66046 15.7313 6.667313 6.6738415 6.6015835 6.619246 15.695846 6.612834 6.613706 6.5828557 6.593086 15.472996 6.586861 6.588541 6.5512805 6.5564375 15.516214 6.533324 6.5575166 6.5250444 6.5570054 15.313011 6.540958 6.5805836 6.5345154 6.5525365 15.25416 ]. Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.
It's been a long time, i will check this out later and let you know.
Meanwhile what you can do is,
Then continue with the below line. test_dataset.add_technical_indicator(random_forest)
I receive the below error when running this line
test_dataset.add_technical_indicator(random_forest)
Traceback (most recent call last): File "C:/Users/russi/PycharmProjects/stock-market-prediction-master/Stock Master.py", line 59, in <module> test_dataset.add_technical_indicator(random_forest) File "C:\Users\russi\AppData\Local\Programs\Python\Python36\lib\site-packages\nowtrade\dataset.py", line 127, in add_technical_indicator technical_indicator.results(self.data_frame) File "C:\Users\russi\AppData\Local\Programs\Python\Python36\lib\site-packages\nowtrade\technical_indicator.py", line 588, in results res = self.ensemble.activate_all(data_frame) File "C:\Users\russi\AppData\Local\Programs\Python\Python36\lib\site-packages\nowtrade\ensemble.py", line 188, in activate_all res.append(self._activate(values)) File "C:\Users\russi\AppData\Local\Programs\Python\Python36\lib\site-packages\nowtrade\ensemble.py", line 173, in _activate return self.ensemble.predict(data)[0] File "C:\Users\russi\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\ensemble\forest.py", line 693, in predict X = self._validate_X_predict(X) File "C:\Users\russi\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\ensemble\forest.py", line 359, in _validate_X_predict return self.estimators_[0]._validate_X_predict(X, check_input=True) File "C:\Users\russi\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\tree\tree.py", line 391, in _validate_X_predict X = check_array(X, dtype=DTYPE, accept_sparse="csr") File "C:\Users\russi\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\utils\validation.py", line 521, in check_array "if it contains a single sample.".format(array)) ValueError: Expected 2D array, got 1D array instead: array=[ 6.636209 6.636209 6.616788 6.632581 15.030156 6.6386986 6.645351 6.6275783 6.6353297 14.631229 6.6205664 6.6408296 6.617403 6.6324363 14.695262 6.615382 6.627128 6.600251 6.6080008 14.965006 6.6171355 6.620233 6.591564 6.5942903 14.6806345 6.595712 6.5999794 6.57864 6.5972414 14.749562 6.607663 6.6178575 6.6018143 6.6138406 14.666003 6.619193 6.6240654 6.574769 6.578654 14.765778 6.585399 6.6065016 6.558198 6.594947 14.837206 6.565251 6.5850124 6.553235 6.5659547 15.159367 6.5794597 6.586654 6.5650535 6.5779724 14.70595 6.5594735 6.5888577 6.533469 6.577249 15.231849 6.5794873 6.6034966 6.5668273 6.5884724 14.769829 6.6093493 6.618151 6.6073256 6.6140013 14.673027 6.611826 6.6233478 6.596463 6.597991 14.633968 6.6001563 6.6059203 6.5888853 6.5982227 14.251828 6.601081 6.601081 6.570112 6.5758843 14.567587 6.6042013 6.6216187 6.593866 6.617804 14.948588 6.6186857 6.6400194 6.61231 6.635093 15.147982 6.6480255 6.6561995 6.635133 6.64739 15.534 6.6852365 6.6974664 6.660063 6.66046 15.7313 6.667313 6.6738415 6.6015835 6.619246 15.695846 6.612834 6.613706 6.5828557 6.593086 15.472996 6.586861 6.588541 6.5512805 6.5564375 15.516214 6.533324 6.5575166 6.5250444 6.5570054 15.313011 6.540958 6.5805836 6.5345154 6.5525365 15.25416 ]. Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.