just finished training the models for a data of 206 stocks, It took around 4 hours to finish the training. have a look at the terminal output and comment :
PS C:\Users\siddh> & C:/Users/siddh/AppData/Local/Programs/Python/Python311/python.exe c:/Users/swarn/python_codes/python_try/hugging/predictive_30.py
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\yfinance\base.py:48: FutureWarning: The default dtype for empty Series will be 'object' instead of 'float64' in a future version. Specify a dtype explicitly to silence this warning.
_empty_series = pd.Series()
Program started...
Do you want to 'Train' the models or 'Use' existing models? Enter 'Train' or 'Use': train
Enter the prediction horizon in days (e.g., 5): 15
Enter the number of years of data to use for training (e.g., 5 or 10): 5
Training the Models on 206 stocks data
Estimated Time in minutes = 206
Time of start = 2024-09-21 15:01:06.088522
Fetching stock data...
[*******************100%%] 1 of 1 completed | 0/206 [00:00<?, ?it/s]
[*******************100%%] 1 of 1 completed | 1/206 [00:03<11:27, 3.36s/it]
[*******************100%%] 1 of 1 completed | 2/206 [00:03<05:21, 1.57s/it]
[*******************100%%] 1 of 1 completed | 3/206 [00:04<03:42, 1.09s/it]
[*******************100%%] 1 of 1 completed | 4/206 [00:04<02:37, 1.28it/s]
[*******************100%%] 1 of 1 completed | 5/206 [00:04<02:01, 1.65it/s]
[*******************100%%] 1 of 1 completed | 7/206 [00:05<01:53, 1.75it/s]
[*******************] 1 of 1 completed | 9/206 [00:06<01:19, 2.48it/s]
[*******************] 1 of 1 completed | 11/206 [00:06<01:06, 2.94it/s]
[*******************] 1 of 1 completed | 13/206 [00:07<01:02, 3.09it/s]
[*******************] 1 of 1 completed | 15/206 [00:08<00:58, 3.25it/s]
[*******************] 1 of 1 completed | 17/206 [00:09<01:19, 2.37it/s]
[*******************] 1 of 1 completed | 19/206 [00:09<01:05, 2.85it/s]
[*******************] 1 of 1 completed | 21/206 [00:10<01:01, 2.99it/s]
[*******************] 1 of 1 completed | 23/206 [00:10<00:54, 3.38it/s]
[*******************] 1 of 1 completed | 25/206 [00:11<00:53, 3.36it/s]
[*******************] 1 of 1 completed | 27/206 [00:15<03:21, 1.13s/it]
[*******************] 1 of 1 completed | 29/206 [00:16<02:02, 1.45it/s]
[*******************] 1 of 1 completed | 31/206 [00:17<02:29, 1.17it/s]
[*******************] 1 of 1 completed | 33/206 [00:19<02:28, 1.17it/s]
[*******************] 1 of 1 completed | 35/206 [00:21<02:08, 1.33it/s]
[*******************] 1 of 1 completed | 37/206 [00:23<03:08, 1.11s/it]
[*******************] 1 of 1 completed | 39/206 [00:24<01:54, 1.46it/s]
[*******************] 1 of 1 completed | 41/206 [00:24<01:19, 2.07it/s]
[*******************] 1 of 1 completed | 43/206 [00:25<01:11, 2.28it/s]
[*******************] 1 of 1 completed | 45/206 [00:26<00:58, 2.74it/s]
[*******************] 1 of 1 completed | 47/206 [00:27<00:59, 2.67it/s]
[*******************] 1 of 1 completed | 49/206 [00:28<01:19, 1.98it/s]
[*******************] 1 of 1 completed | 51/206 [00:30<01:47, 1.44it/s]
[*******************] 1 of 1 completed | 53/206 [00:30<01:12, 2.11it/s]
[*******************] 1 of 1 completed | 55/206 [00:31<00:50, 2.96it/s]
[*******************] 1 of 1 completed | 57/206 [00:31<00:43, 3.42it/s]
[*******************] 1 of 1 completed | 59/206 [00:32<00:43, 3.40it/s]
[*******************] 1 of 1 completed | 61/206 [00:32<00:44, 3.23it/s]
[*******************] 1 of 1 completed | 63/206 [00:33<01:03, 2.24it/s]
[*******************] 1 of 1 completed | 65/206 [00:36<02:04, 1.14it/s]
[*******************] 1 of 1 completed | 67/206 [00:36<01:19, 1.75it/s]
[*******************] 1 of 1 completed | 69/206 [00:37<00:58, 2.35it/s]
[*******************] 1 of 1 completed | 71/206 [00:38<01:12, 1.86it/s]
[*******************] 1 of 1 completed | 73/206 [00:40<01:21, 1.64it/s]
[*******************] 1 of 1 completed | 75/206 [00:41<01:22, 1.58it/s]
[*******************] 1 of 1 completed | 77/206 [00:43<02:05, 1.03it/s]
[*******************] 1 of 1 completed | 79/206 [00:44<01:19, 1.60it/s]
[*******************] 1 of 1 completed | 81/206 [00:45<01:02, 2.01it/s]
[*******************] 1 of 1 completed | 83/206 [00:45<00:49, 2.50it/s]
[*******************] 1 of 1 completed | 85/206 [00:46<00:38, 3.15it/s]
[*******************] 1 of 1 completed | 87/206 [00:46<00:32, 3.62it/s]
[*******************] 1 of 1 completed█▎ | 89/206 [00:47<00:30, 3.89it/s]
[*******************] 1 of 1 completed██▊ | 91/206 [00:47<00:29, 3.89it/s]
[*******************] 1 of 1 completed████▎ | 93/206 [00:48<00:28, 3.90it/s]
[*******************] 1 of 1 completed█████▋ | 95/206 [00:48<00:28, 3.96it/s]
[*******************] 1 of 1 completed███████▏ | 97/206 [00:49<00:25, 4.33it/s]
[*******************] 1 of 1 completed████████▌ | 99/206 [00:49<00:27, 3.89it/s]
[*******************] 1 of 1 completed█████████▌ | 101/206 [00:54<02:45, 1.58s/it]
[*******************] 1 of 1 completed███████████ | 103/206 [00:55<01:35, 1.08it/s]
[*******************] 1 of 1 completed████████████▍ | 105/206 [00:55<00:58, 1.71it/s]
[*******************] 1 of 1 completed█████████████▊ | 107/206 [00:56<00:41, 2.36it/s]
[*******************] 1 of 1 completed███████████████▎ | 109/206 [00:57<00:36, 2.63it/s]
[*******************] 1 of 1 completed████████████████▋ | 111/206 [00:57<00:36, 2.62it/s]
[*******************] 1 of 1 completed██████████████████▏ | 113/206 [00:58<00:31, 2.96it/s]
[*******************] 1 of 1 completed███████████████████▌ | 115/206 [00:59<00:30, 3.01it/s]
[*******************] 1 of 1 completed█████████████████████ | 117/206 [00:59<00:28, 3.17it/s]
[*******************] 1 of 1 completed██████████████████████▍ | 119/206 [01:00<00:28, 3.07it/s]
[*******************] 1 of 1 completed███████████████████████▉ | 121/206 [01:01<00:32, 2.60it/s]
[*******************] 1 of 1 completed█████████████████████████▎ | 123/206 [01:02<00:41, 2.01it/s]
[*******************] 1 of 1 completed██████████████████████████▊ | 125/206 [01:02<00:31, 2.54it/s]
[*******************] 1 of 1 completed████████████████████████████▏ | 127/206 [01:03<00:25, 3.08it/s]
[*******************] 1 of 1 completed█████████████████████████████▋ | 129/206 [01:04<00:22, 3.37it/s]
[*******************] 1 of 1 completed███████████████████████████████ | 131/206 [01:04<00:21, 3.46it/s]
[*******************] 1 of 1 completed████████████████████████████████▌ | 133/206 [01:05<00:23, 3.07it/s]
[*******************] 1 of 1 completed█████████████████████████████████▉ | 135/206 [01:05<00:19, 3.62it/s]
[*******************] 1 of 1 completed███████████████████████████████████▍ | 137/206 [01:06<00:19, 3.63it/s]
[*******************] 1 of 1 completed████████████████████████████████████▊ | 139/206 [01:06<00:20, 3.29it/s]
[*******************] 1 of 1 completed██████████████████████████████████████▎ | 141/206 [01:07<00:19, 3.39it/s]
[*******************] 1 of 1 completed███████████████████████████████████████▋ | 143/206 [01:08<00:23, 2.70it/s]
[*******************] 1 of 1 completed█████████████████████████████████████████▏ | 145/206 [01:09<00:22, 2.75it/s]
[*******************] 1 of 1 completed██████████████████████████████████████████▌ | 147/206 [01:09<00:19, 3.05it/s]
[*******************] 1 of 1 completed████████████████████████████████████████████ | 149/206 [01:11<00:30, 1.90it/s]
[*******************] 1 of 1 completed█████████████████████████████████████████████▍ | 151/206 [01:12<00:33, 1.63it/s]
[*******************] 1 of 1 completed██████████████████████████████████████████████▉ | 153/206 [01:13<00:24, 2.14it/s]
[*******************] 1 of 1 completed████████████████████████████████████████████████▎ | 155/206 [01:13<00:18, 2.71it/s]
[*******************] 1 of 1 completed█████████████████████████████████████████████████▊ | 157/206 [01:14<00:16, 3.03it/s]
[*******************] 1 of 1 completed███████████████████████████████████████████████████▏ | 159/206 [01:15<00:14, 3.18it/s]
[*******************] 1 of 1 completed████████████████████████████████████████████████████▋ | 161/206 [01:16<00:21, 2.11it/s]
[*******************] 1 of 1 completed██████████████████████████████████████████████████████ | 163/206 [01:17<00:17, 2.48it/s]
[*******************] 1 of 1 completed███████████████████████████████████████████████████████▌ | 165/206 [01:18<00:15, 2.57it/s]
[*******************] 1 of 1 completed████████████████████████████████████████████████████████▉ | 167/206 [01:18<00:13, 2.95it/s]
[*******************] 1 of 1 completed██████████████████████████████████████████████████████████▍ | 169/206 [01:19<00:16, 2.19it/s]
[*******************] 1 of 1 completed███████████████████████████████████████████████████████████▊ | 171/206 [01:20<00:13, 2.53it/s]
[*******************] 1 of 1 completed█████████████████████████████████████████████████████████████▎ | 173/206 [01:21<00:11, 2.90it/s]
[*******************] 1 of 1 completed██████████████████████████████████████████████████████████████▋ | 175/206 [01:21<00:09, 3.14it/s]
[*******************] 1 of 1 completed████████████████████████████████████████████████████████████████▏ | 177/206 [01:22<00:08, 3.28it/s]
[*******************] 1 of 1 completed█████████████████████████████████████████████████████████████████▌ | 179/206 [01:24<00:17, 1.54it/s]
[*******************] 1 of 1 completed███████████████████████████████████████████████████████████████████ | 181/206 [01:24<00:12, 1.99it/s]
[*******************] 1 of 1 completed████████████████████████████████████████████████████████████████████▍ | 183/206 [01:25<00:08, 2.56it/s]
[*******************] 1 of 1 completed█████████████████████████████████████████████████████████████████████▉ | 185/206 [01:26<00:10, 2.03it/s]
[*******************] 1 of 1 completed███████████████████████████████████████████████████████████████████████▎ | 187/206 [01:27<00:07, 2.67it/s]
[*******************] 1 of 1 completed████████████████████████████████████████████████████████████████████████▊ | 189/206 [01:27<00:05, 2.90it/s]
[*******************] 1 of 1 completed██████████████████████████████████████████████████████████████████████████▏ | 191/206 [01:28<00:04, 3.31it/s]
[*******************] 1 of 1 completed███████████████████████████████████████████████████████████████████████████▋ | 193/206 [01:28<00:03, 3.44it/s]
[*******************] 1 of 1 completed█████████████████████████████████████████████████████████████████████████████ | 195/206 [01:29<00:03, 2.88it/s]
[*******************] 1 of 1 completed██████████████████████████████████████████████████████████████████████████████▌ | 197/206 [01:30<00:02, 3.60it/s]
[*******************] 1 of 1 completed███████████████████████████████████████████████████████████████████████████████▉ | 199/206 [01:32<00:05, 1.40it/s]
[*******************] 1 of 1 completed█████████████████████████████████████████████████████████████████████████████████▍ | 201/206 [01:34<00:04, 1.02it/s]
[*******************] 1 of 1 completed██████████████████████████████████████████████████████████████████████████████████▊ | 203/206 [01:35<00:02, 1.19it/s]
[*******************] 1 of 1 completed████████████████████████████████████████████████████████████████████████████████████▎| 205/206 [01:36<00:00, 1.86it/s]
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 206/206 [01:36<00:00, 2.13it/s]
Calculating technical indicators...
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 206/206 [00:01<00:00, 161.79it/s]
Label encoder saved to label_encoder.pkl
Scaler saved to scaler.pkl
Training regression models...
Best parameters for Random Forest Regressor: {'max_depth': None, 'min_samples_split': 2, 'n_estimators': 200}
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:19] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
Assistant
] 1 of 1 completed | 6/206 [00:05<01:37, 2.06it/s]
[*******************100%%
100%%
] 1 of 1 completed | 8/206 [00:06<01:35, 2.08it/s]
[*******************100%%
100%%
] 1 of 1 completed | 10/206 [00:06<01:12, 2.71it/s]
[*******************100%%
100%%
] 1 of 1 completed | 12/206 [00:07<01:03, 3.05it/s]
[*******************100%%
100%%
] 1 of 1 completed | 14/206 [00:07<01:00, 3.16it/s]
[*******************100%%
100%%
] 1 of 1 completed | 16/206 [00:08<01:30, 2.09it/s]
[*******************100%%
100%%
] 1 of 1 completed | 18/206 [00:09<01:10, 2.66it/s]
[*******************100%%
100%%
] 1 of 1 completed | 20/206 [00:10<01:05, 2.85it/s]
[*******************100%%
100%%
] 1 of 1 completed | 22/206 [00:10<00:56, 3.28it/s]
[*******************100%%
100%%
] 1 of 1 completed | 24/206 [00:11<00:47, 3.87it/s]
[*******************100%%
100%%
] 1 of 1 completed | 26/206 [00:13<02:49, 1.06it/s]
[*******************100%%
100%%
] 1 of 1 completed | 28/206 [00:15<02:33, 1.16it/s]
[*******************100%%
100%%
] 1 of 1 completed | 30/206 [00:16<01:39, 1.77it/s]
[*******************100%%
100%%
] 1 of 1 completed | 32/206 [00:19<03:07, 1.08s/it]
[*******************100%%
100%%
] 1 of 1 completed | 34/206 [00:20<02:41, 1.06it/s]
[*******************100%%
100%%
] 1 of 1 completed | 36/206 [00:21<01:45, 1.61it/s]
[*******************100%%
100%%
] 1 of 1 completed | 38/206 [00:24<02:25, 1.16it/s]
[*******************100%%
100%%
] 1 of 1 completed | 40/206 [00:24<01:34, 1.76it/s]
[*******************100%%
100%%
] 1 of 1 completed | 42/206 [00:25<01:10, 2.31it/s]
[*******************100%%
100%%
] 1 of 1 completed | 44/206 [00:26<01:03, 2.57it/s]
[*******************100%%
100%%
] 1 of 1 completed | 46/206 [00:26<01:05, 2.42it/s]
[*******************100%%
100%%
] 1 of 1 completed | 48/206 [00:28<01:38, 1.60it/s]
[*******************100%%
100%%
] 1 of 1 completed | 50/206 [00:28<01:08, 2.26it/s]
[*******************100%%
100%%
] 1 of 1 completed | 52/206 [00:30<01:26, 1.77it/s]
[*******************100%%
100%%
] 1 of 1 completed | 54/206 [00:30<01:02, 2.43it/s]
[*******************100%%
100%%
] 1 of 1 completed | 56/206 [00:31<00:48, 3.11it/s]
[*******************100%%
100%%
] 1 of 1 completed | 58/206 [00:31<00:43, 3.43it/s]
[*******************100%%
100%%
] 1 of 1 completed | 60/206 [00:32<00:47, 3.10it/s]
[*******************100%%
100%%
] 1 of 1 completed | 62/206 [00:33<00:42, 3.37it/s]
[*******************100%%
100%%
] 1 of 1 completed | 64/206 [00:34<00:56, 2.52it/s]
[*******************100%%
100%%
] 1 of 1 completed | 66/206 [00:36<01:36, 1.45it/s]
[*******************100%%
100%%
] 1 of 1 completed | 68/206 [00:37<01:06, 2.09it/s]
[*******************100%%
100%%
] 1 of 1 completed | 70/206 [00:38<01:31, 1.49it/s]
[*******************100%%
100%%
] 1 of 1 completed | 72/206 [00:39<01:01, 2.17it/s]
[*******************100%%
100%%
] 1 of 1 completed | 74/206 [00:41<01:43, 1.27it/s]
[*******************100%%
100%%
] 1 of 1 completed | 76/206 [00:41<01:08, 1.90it/s]
[*******************100%%
100%%
] 1 of 1 completed | 78/206 [00:44<01:38, 1.30it/s]
[*******************100%%
100%%
] 1 of 1 completed | 80/206 [00:44<01:06, 1.90it/s]
[*******************100%%
100%%
] 1 of 1 completed | 82/206 [00:45<00:54, 2.28it/s]
[*******************100%%
100%%
] 1 of 1 completed | 84/206 [00:45<00:44, 2.76it/s]
[*******************100%%
100%%
] 1 of 1 completed | 86/206 [00:46<00:35, 3.40it/s]
[*******************100%%
100%%
] 1 of 1 completed▋ | 88/206 [00:46<00:32, 3.64it/s]
[*******************100%%
100%%
] 1 of 1 completed██ | 90/206 [00:47<00:28, 4.07it/s]
[*******************100%%
100%%
] 1 of 1 completed███▌ | 92/206 [00:47<00:31, 3.66it/s]
[*******************100%%
100%%
] 1 of 1 completed████▉ | 94/206 [00:48<00:29, 3.83it/s]
[*******************100%%
100%%
] 1 of 1 completed██████▍ | 96/206 [00:48<00:24, 4.44it/s]
[*******************100%%
100%%
] 1 of 1 completed███████▉ | 98/206 [00:49<00:26, 4.15it/s]
[*******************100%%
100%%
] 1 of 1 completed████████▊ | 100/206 [00:50<00:46, 2.27it/s]
[*******************100%%
100%%
] 1 of 1 completed██████████▎ | 102/206 [00:55<02:03, 1.19s/it]
[*******************100%%
100%%
] 1 of 1 completed███████████▋ | 104/206 [00:55<01:13, 1.40it/s]
[*******************100%%
100%%
] 1 of 1 completed█████████████▏ | 106/206 [00:56<00:48, 2.08it/s]
[*******************100%%
100%%
] 1 of 1 completed██████████████▌ | 108/206 [00:56<00:41, 2.37it/s]
[*******************100%%
100%%
] 1 of 1 completed████████████████ | 110/206 [00:57<00:33, 2.85it/s]
[*******************100%%
100%%
] 1 of 1 completed█████████████████▍ | 112/206 [00:58<00:32, 2.89it/s]
[*******************100%%
100%%
] 1 of 1 completed██████████████████▉ | 114/206 [00:58<00:31, 2.90it/s]
[*******************100%%
100%%
] 1 of 1 completed████████████████████▎ | 116/206 [00:59<00:28, 3.13it/s]
[*******************100%%
100%%
] 1 of 1 completed█████████████████████▊ | 118/206 [01:00<00:30, 2.90it/s]
[*******************100%%
100%%
] 1 of 1 completed███████████████████████▏ | 120/206 [01:01<00:36, 2.33it/s]
[*******************100%%
100%%
] 1 of 1 completed████████████████████████▋ | 122/206 [01:01<00:29, 2.85it/s]
[*******************100%%
100%%
] 1 of 1 completed██████████████████████████ | 124/206 [01:02<00:34, 2.40it/s]
[*******************100%%
100%%
] 1 of 1 completed███████████████████████████▌ | 126/206 [01:03<00:28, 2.79it/s]
[*******************100%%
100%%
] 1 of 1 completed████████████████████████████▉ | 128/206 [01:03<00:22, 3.40it/s]
[*******************100%%
100%%
] 1 of 1 completed██████████████████████████████▍ | 130/206 [01:04<00:22, 3.43it/s]
[*******************100%%
100%%
] 1 of 1 completed███████████████████████████████▊ | 132/206 [01:05<00:24, 3.07it/s]
[*******************100%%
100%%
] 1 of 1 completed█████████████████████████████████▎ | 134/206 [01:05<00:21, 3.39it/s]
[*******************100%%
100%%
] 1 of 1 completed██████████████████████████████████▋ | 136/206 [01:06<00:18, 3.75it/s]
[*******************100%%
100%%
] 1 of 1 completed████████████████████████████████████▏ | 138/206 [01:06<00:18, 3.62it/s]
[*******************100%%
100%%
] 1 of 1 completed█████████████████████████████████████▌ | 140/206 [01:07<00:19, 3.37it/s]
[*******************100%%
100%%
] 1 of 1 completed███████████████████████████████████████ | 142/206 [01:08<00:25, 2.55it/s]
[*******************100%%
100%%
] 1 of 1 completed████████████████████████████████████████▍ | 144/206 [01:08<00:21, 2.91it/s]
[*******************100%%
100%%
] 1 of 1 completed█████████████████████████████████████████▉ | 146/206 [01:09<00:20, 2.94it/s]
[*******************100%%
100%%
] 1 of 1 completed███████████████████████████████████████████▎ | 148/206 [01:10<00:24, 2.38it/s]
[*******************100%%
100%%
] 1 of 1 completed████████████████████████████████████████████▊ | 150/206 [01:12<00:42, 1.31it/s]
[*******************100%%
100%%
] 1 of 1 completed██████████████████████████████████████████████▏ | 152/206 [01:13<00:27, 1.95it/s]
[*******************100%%
100%%
] 1 of 1 completed███████████████████████████████████████████████▋ | 154/206 [01:13<00:21, 2.42it/s]
[*******************100%%
100%%
] 1 of 1 completed█████████████████████████████████████████████████ | 156/206 [01:14<00:17, 2.88it/s]
[*******************100%%
100%%
] 1 of 1 completed██████████████████████████████████████████████████▌ | 158/206 [01:14<00:15, 3.14it/s]
[*******************100%%
100%%
] 1 of 1 completed███████████████████████████████████████████████████▉ | 160/206 [01:16<00:25, 1.80it/s]
[*******************100%%
100%%
] 1 of 1 completed█████████████████████████████████████████████████████▍ | 162/206 [01:16<00:19, 2.21it/s]
[*******************100%%
100%%
] 1 of 1 completed██████████████████████████████████████████████████████▊ | 164/206 [01:17<00:18, 2.30it/s]
[*******************100%%
100%%
] 1 of 1 completed████████████████████████████████████████████████████████▎ | 166/206 [01:18<00:14, 2.79it/s]
[*******************100%%
100%%
] 1 of 1 completed█████████████████████████████████████████████████████████▋ | 168/206 [01:19<00:20, 1.89it/s]
[*******************100%%
100%%
] 1 of 1 completed███████████████████████████████████████████████████████████▏ | 170/206 [01:20<00:15, 2.26it/s]
[*******************100%%
100%%
] 1 of 1 completed████████████████████████████████████████████████████████████▌ | 172/206 [01:20<00:12, 2.77it/s]
[*******************100%%
100%%
] 1 of 1 completed██████████████████████████████████████████████████████████████ | 174/206 [01:21<00:10, 3.12it/s]
[*******************100%%
100%%
] 1 of 1 completed███████████████████████████████████████████████████████████████▍ | 176/206 [01:22<00:09, 3.24it/s]
[*******************100%%
100%%
] 1 of 1 completed████████████████████████████████████████████████████████████████▉ | 178/206 [01:22<00:08, 3.29it/s]
[*******************100%%
100%%
] 1 of 1 completed██████████████████████████████████████████████████████████████████▎ | 180/206 [01:24<00:15, 1.70it/s]
[*******************100%%
100%%
] 1 of 1 completed███████████████████████████████████████████████████████████████████▊ | 182/206 [01:25<00:10, 2.27it/s]
[*******************100%%
100%%
] 1 of 1 completed█████████████████████████████████████████████████████████████████████▏ | 184/206 [01:26<00:12, 1.70it/s]
[*******************100%%
100%%
] 1 of 1 completed██████████████████████████████████████████████████████████████████████▋ | 186/206 [01:26<00:08, 2.39it/s]
[*******************100%%
100%%
] 1 of 1 completed████████████████████████████████████████████████████████████████████████ | 188/206 [01:27<00:06, 2.66it/s]
[*******************100%%
100%%
] 1 of 1 completed█████████████████████████████████████████████████████████████████████████▌ | 190/206 [01:28<00:05, 3.05it/s]
[*******************100%%
100%%
] 1 of 1 completed██████████████████████████████████████████████████████████████████████████▉ | 192/206 [01:28<00:04, 3.35it/s]
[*******************100%%
100%%
] 1 of 1 completed████████████████████████████████████████████████████████████████████████████▍ | 194/206 [01:29<00:03, 3.62it/s]
[*******************100%%
100%%
] 1 of 1 completed█████████████████████████████████████████████████████████████████████████████▊ | 196/206 [01:29<00:02, 3.52it/s]
[*******************100%%
100%%
] 1 of 1 completed███████████████████████████████████████████████████████████████████████████████▎ | 198/206 [01:30<00:02, 3.68it/s]
[*******************100%%
100%%
] 1 of 1 completed████████████████████████████████████████████████████████████████████████████████▋ | 200/206 [01:32<00:03, 1.71it/s]
[*******************100%%
100%%
] 1 of 1 completed██████████████████████████████████████████████████████████████████████████████████▏ | 202/206 [01:35<00:04, 1.11s/it]
[*******************100%%
100%%
] 1 of 1 completed███████████████████████████████████████████████████████████████████████████████████▌ | 204/206 [01:36<00:01, 1.57it/s]
[*******************100%%
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:18] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:19] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:18] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:19] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:19] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:19] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:19] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:24] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:24] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:25] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:26] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:26] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:26] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:26] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:27] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:30] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:33] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:33] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:33] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:34] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:34] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:34] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:37] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:37] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:37] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:39] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:40] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:40] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:42] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:42] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:42] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:42] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:43] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:45] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:47] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [16:39:53] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
Best parameters for XGBoost Regressor: {'learning_rate': 0.1, 'max_depth': 7, 'n_estimators': 200}
RandomForestRegressor model saved to RandomForestRegressor_model.pkl
XGBoostRegressor model saved to XGBoostRegressor_model.pkl
NeuralNetworkRegressor model saved to NeuralNetworkRegressormodel.h5
LinearRegression model saved to LinearRegression_model.pkl
SVR model saved to SVR_model.pkl
Random Forest Regressor Evaluation:
Mean Absolute Error (MAE): 0.0463
Mean Squared Error (MSE): 0.004919
Root Mean Squared Error (RMSE): 0.0701
R-squared (R²): 0.5492
Performing cross-validation for Random Forest Regressor...
Cross-validated MSE scores for Random Forest Regressor: [0.00566396 0.00564381 0.00702086 0.00683951 0.00689716]
Mean MSE: 0.006413
XGBoost Regressor Evaluation:
Mean Absolute Error (MAE): 0.0647
Mean Squared Error (MSE): 0.008441
Root Mean Squared Error (RMSE): 0.0919
R-squared (R²): 0.2264
Performing cross-validation for XGBoost Regressor...
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [17:26:00] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [17:26:00] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [17:26:00] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [17:26:00] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
C:\Users\siddh\AppData\Local\Programs\Python\Python311\Lib\site-packages\xgboost\core.py:158: UserWarning: [17:26:00] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0015a694724fa8361-1\xgboost\xgboost-ci-windows\src\learner.cc:740:
Parameters: { "use_label_encoder" } are not used.
warnings.warn(smsg, UserWarning)
Cross-validated MSE scores for XGBoost Regressor: [0.00864687 0.00873164 0.0098942 0.00981995 0.00988047]
Mean MSE: 0.009395
Neural Network Regressor Evaluation:
Mean Absolute Error (MAE): 0.0713
Mean Squared Error (MSE): 0.010740
Root Mean Squared Error (RMSE): 0.1036
R-squared (R²): 0.0157
Performing cross-validation for Neural Network Regressor...
Cross-validated MSE scores for Neural Network Regressor: [0.01081996 0.01061344 0.01215438 0.0121163 0.01199773]
Mean MSE: 0.011540
Linear Regression Evaluation:
Mean Absolute Error (MAE): 0.0713
Mean Squared Error (MSE): 0.010864
Root Mean Squared Error (RMSE): 0.1042
R-squared (R²): 0.0043
Performing cross-validation for Linear Regression...
Cross-validated MSE scores for Linear Regression: [0.01094967 0.01072214 0.01225533 0.01219192 0.01203032]
Mean MSE: 0.011630
Support Vector Regressor Evaluation:
Mean Absolute Error (MAE): 0.0714
Mean Squared Error (MSE): 0.010742
Root Mean Squared Error (RMSE): 0.1036
R-squared (R²): 0.0154
Performing cross-validation for Support Vector Regressor...
Cross-validated MSE scores for Support Vector Regressor: [0.01082714 0.01062151 0.01216097 0.01209016 0.01191799]
Mean MSE: 0.011524
Model performance metrics saved to model_performance_regression.json
Training completed.
Start Time = 2024-09-21 15:01:06.088522
End Time = 2024-09-21 18:53:57.767079
Guidance on model training:
Training with more stocks generally improves model generalization but increases training time.
Using data from longer periods (e.g., 10 years) can capture more market cycles but may include outdated patterns.
Balance between the number of stocks, data period, and computational resources for optimal performance.
PS C:\Users\siddh>
Congratulations on completing the model training! Here are some observations and comments based on your terminal output:
1. Training Overview:
Data and Training Duration:
You trained models using data from 206 stocks over a period of 5 years, aiming to predict 15 days into the future.
The training process took approximately 4 hours, which is reasonable given the dataset size and model complexity.
Initial Estimations:
The program estimated the training time to be 206 minutes, likely based on a rough calculation (1 minute per stock), but the actual time was longer due to factors like data fetching, processing overhead, and model training complexities.
2. Data Fetching and Preprocessing:
Data Retrieval:
Stock data was successfully fetched for all 206 stocks. The progress bar indicates efficient downloading with no failures.
Technical Indicators:
Calculated technical indicators for the stocks, which enriches the dataset and may improve model performance.
Data Preparation:
Label Encoder and Scaler were saved (label_encoder.pkl and scaler.pkl), ensuring consistent preprocessing for future predictions.
3. Model Training and Hyperparameter Tuning:
Models Trained:
Random Forest Regressor
XGBoost Regressor
Neural Network Regressor
Linear Regression
Support Vector Regressor (SVR)
Hyperparameter Optimization:
Conducted using GridSearchCV for Random Forest and XGBoost:
Random Forest Regressor Best Parameters:
max_depth: None
min_samples_split: 2
n_estimators: 200
XGBoost Regressor Best Parameters:
learning_rate: 0.1
max_depth: 7
n_estimators: 200
Warnings Noted:
Multiple warnings from XGBoost regarding the use_label_encoder parameter not being used:
Explanation:use_label_encoder is deprecated in recent versions of XGBoost.
Action: You can safely remove or update this parameter in your code to suppress these warnings.
Comments: The Random Forest Regressor performed the best among all models, explaining approximately 54.9% of the variance in the target variable.
XGBoost Regressor:
MAE: 0.0647
MSE: 0.008441
RMSE: 0.0919
R²: 0.2264
Mean Cross-Validated MSE: 0.009395
Comments: XGBoost showed moderate performance but was outperformed by Random Forest. The lower R² suggests it captured less of the variance.
Neural Network Regressor:
MAE: 0.0713
MSE: 0.010740
RMSE: 0.1036
R²: 0.0157
Mean Cross-Validated MSE: 0.011540
Comments: The Neural Network did not perform as well, potentially due to insufficient tuning or the need for more data/features.
Linear Regression & SVR:
MAE: Approximately 0.0713 - 0.0714
MSE: Around 0.010742 - 0.010864
R²: Very low (0.0043 for Linear Regression, 0.0154 for SVR)
Comments: Both models had low R² values, indicating they did not capture the underlying patterns in the data effectively.
5. Observations and Recommendations:
Random Forest Regressor as the Best Model:
Demonstrated the highest R² value, suggesting it is currently the most effective model for your data.
Model Performance Insights:
R² Values:
An R² of 0.5492 for the Random Forest indicates that while the model captures some of the underlying patterns, there is still room for improvement.
Error Metrics:
MAE and RMSE values provide a sense of the average prediction error, which can be significant in financial contexts.
Improving Model Performance:
Feature Engineering:
Explore adding more features such as:
Fundamental indicators: P/E ratio, EPS, revenue growth, etc.
Macro-economic indicators: Interest rates, GDP growth, unemployment rates.
Sentiment Analysis: News sentiment, social media trends.
Data Augmentation:
Increase the data period to more than 5 years to capture various market conditions, but be cautious of incorporating outdated patterns.
Hyperparameter Tuning for Other Models:
Apply hyperparameter optimization to Neural Network, SVR, and Linear Regression to potentially improve their performance.
Ensemble Methods:
Combine predictions from multiple models to reduce variance and potentially improve overall performance.
Addressing Warnings:
XGBoost Warnings:
Update your XGBoost code to remove the use_label_encoder parameter:
python
model = XGBRegressor(objective='reg:squarederror', ...)
Ensure you are using the latest version of XGBoost.
Appropriate Cross-Validation:
Time Series Consideration:
Use TimeSeriesSplit for cross-validation to respect the temporal order of data and prevent data leakage.
Example:
6. Computational Considerations:
Training Time Optimization:
Parallel Computing:
Utilize all available CPU cores by setting n_jobs=-1 in models like Random Forest and in GridSearchCV.
Hardware Acceleration:
If available, use GPUs for models that support it (e.g., Neural Networks with TensorFlow or PyTorch).
Efficient Code Practices:
Profile your code to identify bottlenecks.
Ensure data is loaded and processed efficiently (e.g., using vectorized operations with NumPy/Pandas).
7. Additional Metrics and Evaluation:
Financial Metrics:
Mean Absolute Percentage Error (MAPE):
Provides error as a percentage, which can be more interpretable in finance.
Profitability Metrics:
Simulate trading strategies based on predictions to evaluate potential returns.
Calculate metrics like Sharpe Ratio, Max Drawdown, Annualized Return.
Model Validation:
Out-of-Sample Testing:
Set aside the most recent data as a test set to evaluate model performance on unseen data.
Rolling Window Validation:
Use a rolling or expanding window approach to train and test the model in a way that mimics real-world forecasting.
8. Next Steps:
Model Deployment:
After refining your models, consider deploying them to make real-time predictions.
Continuous Learning:
Regularly update the models with new data to adapt to market changes.
Documentation and Version Control:
Keep detailed records of experiments, parameter settings, and results.
Use version control systems like Git to track changes in your codebase.
9. General Guidance on Model Training:
Balancing Data Quantity and Relevance:
More data can help but ensure it's relevant to current market conditions.
Understanding Overfitting and Underfitting:
Overfitting: Model learns noise. Mitigate with cross-validation and regularization.
Underfitting: Model is too simple. Address by adding complexity or features.
Monitoring Model Drift:
Be aware that models can become less effective over time due to changes in market dynamics.
10. Encouragement:
Achieving an R² of over 50% in stock price prediction is commendable given the high volatility and noise in financial markets. Continuous experimentation and refinement are key in machine learning projects, especially in complex domains like finance.
If you have specific questions or need assistance with any part of the process, feel free to ask. Keep up the great work!