A machine learning model developed in Jupyter Notebook using Python that predicts the next-day market trends. The project uses a random forest classification model to make predictions of whether tomorrow's closing price is higher or lower than the previous day. This project was made to learn about machine learning and its concepts like feature engineering, handling overfitting/underfitting, and evaluating model performance.
NOTE: pandas-ta went closed-source and may not be publicly available
- Forward Feature Selection: The feature engineering process individually adds on indicators with the highest precision score after each run.
- Classification Model: The model predicts up (positive) or down (negative) which is easier to predict, but also harder to capitalize on the predictions it outputs since magnitude is not predicted.
- Random Forest Algorithm: This algorithm aggregates the mode of many many decision trees to train and make a prediction.
To run the project in your local environment, follow these steps:
- Clone the repository to your local machine.
- Run all the cells above program.
- Adjust tickers, time frame, confidence, and features to your own liking.
- Run the program cell and view your results.
| Equity | Symbol | Accuracy Score | Precision Score | Recall Score | F1 Score | Bullish Frequency | Bearish Frequency | Positive Rate | Negative Rate | Positive Predictions | Negative Predictions | Total Predictions |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Visa Inc. | V | 0.512113 | 0.568662 | 0.402242 | 0.471189 | 0.540377 | 0.459623 | 0.382234 | 0.617766 | 568 | 918 | 1486 |
| International Business Machines | IBM | 0.535666 | 0.557429 | 0.662078 | 0.605263 | 0.537685 | 0.462315 | 0.638627 | 0.361373 | 949 | 537 | 1486 |
| Procter & Gamble Company (The) | PG | 0.505384 | 0.546900 | 0.433249 | 0.483486 | 0.534320 | 0.465680 | 0.423284 | 0.576716 | 629 | 857 | 1486 |
| NVIDIA Corporation | NVDA | 0.481157 | 0.541176 | 0.339483 | 0.417234 | 0.547106 | 0.452894 | 0.343203 | 0.656797 | 510 | 976 | 1486 |
| Coca-Cola Company (The) | KO | 0.499327 | 0.533795 | 0.393359 | 0.452941 | 0.526918 | 0.473082 | 0.388291 | 0.611709 | 577 | 909 | 1486 |
| Chevron Corporation | CVX | 0.506729 | 0.533648 | 0.572152 | 0.552230 | 0.531629 | 0.468371 | 0.569987 | 0.430013 | 847 | 639 | 1486 |
| Meta Platforms, Inc. | META | 0.503946 | 0.533499 | 0.460385 | 0.494253 | 0.526494 | 0.473506 | 0.454340 | 0.545660 | 403 | 484 | 887 |
| Johnson & Johnson | JNJ | 0.502692 | 0.532995 | 0.274510 | 0.362381 | 0.514805 | 0.485195 | 0.265141 | 0.734859 | 394 | 1092 | 1486 |
| Amazon.com, Inc. | AMZN | 0.496635 | 0.528340 | 0.336340 | 0.411024 | 0.522207 | 0.477793 | 0.332436 | 0.667564 | 494 | 992 | 1486 |
| Pepsico, Inc. | PEP | 0.495289 | 0.526971 | 0.327320 | 0.403816 | 0.522207 | 0.477793 | 0.324361 | 0.675639 | 482 | 1004 | 1486 |
| 3M Company | MMM | 0.520861 | 0.524070 | 0.633598 | 0.573653 | 0.508748 | 0.491252 | 0.615074 | 0.384926 | 914 | 572 | 1486 |
| Verizon Communications Inc. | VZ | 0.524226 | 0.523288 | 0.515520 | 0.519375 | 0.498654 | 0.501346 | 0.491252 | 0.508748 | 730 | 756 | 1486 |
| UnitedHealth Group Incorporated | UNH | 0.491925 | 0.523148 | 0.431847 | 0.473133 | 0.528264 | 0.471736 | 0.436070 | 0.563930 | 648 | 838 | 1486 |
| Walmart Inc. | WMT | 0.490579 | 0.521739 | 0.486692 | 0.503607 | 0.530956 | 0.469044 | 0.495289 | 0.504711 | 736 | 750 | 1486 |
| Lockheed Martin Corporation | LMT | 0.499327 | 0.520930 | 0.574359 | 0.546341 | 0.524899 | 0.475101 | 0.578735 | 0.421265 | 860 | 626 | 1486 |
| Cisco Systems, Inc. | CSCO | 0.498654 | 0.516706 | 0.560155 | 0.537554 | 0.520188 | 0.479812 | 0.563930 | 0.436070 | 838 | 648 | 1486 |
| Intel Corporation | INTC | 0.516151 | 0.516484 | 0.444595 | 0.477850 | 0.497981 | 0.502019 | 0.428668 | 0.571332 | 637 | 849 | 1486 |
| Oracle Corporation | ORCL | 0.475774 | 0.514870 | 0.348428 | 0.415604 | 0.534993 | 0.465007 | 0.362046 | 0.637954 | 538 | 948 | 1486 |
| Microsoft Corporation | MSFT | 0.479139 | 0.511811 | 0.411914 | 0.456461 | 0.530956 | 0.469044 | 0.427322 | 0.572678 | 635 | 851 | 1486 |
| Wells Fargo & Company | WFC | 0.494616 | 0.502755 | 0.483444 | 0.492910 | 0.508075 | 0.491925 | 0.488560 | 0.511440 | 726 | 760 | 1486 |
| Goldman Sachs Group, Inc. (The) | GS | 0.475774 | 0.495522 | 0.429495 | 0.460152 | 0.520188 | 0.479812 | 0.450875 | 0.549125 | 670 | 816 | 1486 |
| Boeing Company (The) | BA | 0.500000 | 0.492596 | 0.685440 | 0.573234 | 0.489906 | 0.510094 | 0.681696 | 0.318304 | 1013 | 473 | 1486 |
| AT&T Inc. | T | 0.477793 | 0.490476 | 0.404450 | 0.443329 | 0.514132 | 0.485868 | 0.423957 | 0.576043 | 630 | 856 | 1486 |
| Exxon Mobil Corporation | XOM | 0.472409 | 0.481739 | 0.363041 | 0.414051 | 0.513459 | 0.486541 | 0.386945 | 0.613055 | 575 | 911 | 1486 |
| Pfizer, Inc. | PFE | 0.508748 | 0.476106 | 0.382646 | 0.424290 | 0.473082 | 0.526918 | 0.380215 | 0.619785 | 565 | 921 | 1486 |
| Walt Disney Company (The) | DIS | 0.494616 | 0.473684 | 0.426778 | 0.449010 | 0.482503 | 0.517497 | 0.434724 | 0.565276 | 646 | 840 | 1486 |
| Equity | Symbol | Accuracy Score | Precision Score | Recall Score | F1 Score | Bullish Frequency | Bearish Frequency | Positive Rate | Negative Rate | Positive Predictions | Negative Predictions | Total Predictions |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| NVIDIA Corporation | NVDA | 0.569473 | 0.672878 | 0.408291 | 0.508210 | 0.544832 | 0.455168 | 0.330595 | 0.669405 | 483 | 978 | 1461 |
| Chevron Corporation | CVX | 0.637919 | 0.669333 | 0.641124 | 0.654925 | 0.535934 | 0.464066 | 0.513347 | 0.486653 | 750 | 711 | 1461 |
| Procter & Gamble Company (The) | PG | 0.596851 | 0.664948 | 0.495519 | 0.567865 | 0.534565 | 0.465435 | 0.398357 | 0.601643 | 582 | 879 | 1461 |
| Oracle Corporation | ORCL | 0.564682 | 0.652361 | 0.390746 | 0.488746 | 0.532512 | 0.467488 | 0.318960 | 0.681040 | 466 | 995 | 1461 |
| Coca-Cola Company (The) | KO | 0.617385 | 0.649645 | 0.594805 | 0.621017 | 0.527036 | 0.472964 | 0.482546 | 0.517454 | 705 | 756 | 1461 |
| International Business Machines | IBM | 0.613963 | 0.646518 | 0.625159 | 0.635659 | 0.538672 | 0.461328 | 0.520876 | 0.479124 | 761 | 700 | 1461 |
| Lockheed Martin Corporation | LMT | 0.595483 | 0.644407 | 0.505236 | 0.566398 | 0.522930 | 0.477070 | 0.409993 | 0.590007 | 599 | 862 | 1461 |
| Walmart Inc. | WMT | 0.590007 | 0.643200 | 0.516710 | 0.573058 | 0.532512 | 0.467488 | 0.427789 | 0.572211 | 625 | 836 | 1461 |
| Pepsico, Inc. | PEP | 0.628337 | 0.642857 | 0.648755 | 0.645793 | 0.522245 | 0.477755 | 0.527036 | 0.472964 | 770 | 691 | 1461 |
| Microsoft Corporation | MSFT | 0.574264 | 0.634752 | 0.462532 | 0.535127 | 0.529774 | 0.470226 | 0.386037 | 0.613963 | 564 | 897 | 1461 |
| Verizon Communications Inc. | VZ | 0.618754 | 0.633540 | 0.559671 | 0.594319 | 0.498973 | 0.501027 | 0.440794 | 0.559206 | 644 | 817 | 1461 |
| 3M Company | MMM | 0.632444 | 0.633420 | 0.658143 | 0.645545 | 0.508556 | 0.491444 | 0.528405 | 0.471595 | 772 | 689 | 1461 |
| Exxon Mobil Corporation | XOM | 0.592060 | 0.633333 | 0.502646 | 0.560472 | 0.517454 | 0.482546 | 0.410678 | 0.589322 | 600 | 861 | 1461 |
| Johnson & Johnson | JNJ | 0.598905 | 0.632686 | 0.521333 | 0.571637 | 0.513347 | 0.486653 | 0.422998 | 0.577002 | 618 | 843 | 1461 |
| Visa Inc. | V | 0.587269 | 0.631124 | 0.557962 | 0.592292 | 0.537303 | 0.462697 | 0.475017 | 0.524983 | 694 | 767 | 1461 |
| Pfizer, Inc. | PFE | 0.632444 | 0.629752 | 0.548991 | 0.586605 | 0.475017 | 0.524983 | 0.414100 | 0.585900 | 605 | 856 | 1461 |
| AT&T Inc. | T | 0.587269 | 0.628521 | 0.476636 | 0.542141 | 0.512663 | 0.487337 | 0.388775 | 0.611225 | 568 | 893 | 1461 |
| Amazon.com, Inc. | AMZN | 0.560575 | 0.627660 | 0.387139 | 0.478896 | 0.521561 | 0.478439 | 0.321697 | 0.678303 | 470 | 991 | 1461 |
| Wells Fargo & Company | WFC | 0.599589 | 0.626935 | 0.540721 | 0.580645 | 0.512663 | 0.487337 | 0.442163 | 0.557837 | 646 | 815 | 1461 |
| Cisco Systems, Inc. | CSCO | 0.601643 | 0.625532 | 0.581028 | 0.602459 | 0.519507 | 0.480493 | 0.482546 | 0.517454 | 705 | 756 | 1461 |
| Intel Corporation | INTC | 0.609856 | 0.619414 | 0.554483 | 0.585153 | 0.496235 | 0.503765 | 0.444216 | 0.555784 | 649 | 812 | 1461 |
| Goldman Sachs Group, Inc. (The) | GS | 0.581109 | 0.612557 | 0.527009 | 0.566572 | 0.519507 | 0.480493 | 0.446954 | 0.553046 | 653 | 808 | 1461 |
| UnitedHealth Group Incorporated | UNH | 0.566051 | 0.612313 | 0.478544 | 0.537226 | 0.526352 | 0.473648 | 0.411362 | 0.588638 | 601 | 860 | 1461 |
| Boeing Company (The) | BA | 0.616701 | 0.606757 | 0.625348 | 0.615912 | 0.491444 | 0.508556 | 0.506502 | 0.493498 | 740 | 721 | 1461 |
| Walt Disney Company (The) | DIS | 0.610541 | 0.602963 | 0.574859 | 0.588576 | 0.484600 | 0.515400 | 0.462012 | 0.537988 | 675 | 786 | 1461 |
| Meta Platforms, Inc. | META | 0.540603 | 0.578082 | 0.465784 | 0.515892 | 0.525522 | 0.474478 | 0.423434 | 0.576566 | 365 | 497 | 862 |