RandomForestRegressor Model – Up to 99% Accurate Forex Prediction
It splits the data into training and testing sets using train_test_split, with 80% of the data used for training and 20% for testing.
It creates a RandomForestRegressor model with 100 decision trees (n_estimators=100) and trains it on the training data.
It makes predictions for the test data using the trained model.
It calculates the model’s accuracy using two metrics: R-squared (r2) and Mean Squared Error (MSE).
It calculates the accuracy percentage by multiplying the R-squared score by 100.
It prints the R-squared score, Mean Squared Error, and accuracy percentage to evaluate the model’s performance.
It predicts the next date and price based on the last known price. It uses the last known price in the dataset to make a one-day-ahead prediction. The date is parsed and incremented by one day, and the predicted price is formatted to have four decimal places.
It prints the last known date, the predicted next date, and the predicted next price.
The program is developed in Python. You will need to install Python 3.10. All instructions included.