Member-only story
Random forest is an algorithm in supervised machine learning that can give very respectable results. It is based on the premise of linking several decision trees together and then averaging their results to come up with one distinctive result, as seen in the diagram below:-
There are a number of ways that the random forest algorithm can be made, but I have selected one algorithm, written in Jax, that requires three classes and several ancillary functions. One thing that is unique about this particular algorithm is the fact that it uses recursion, which is the practice of calling a function within itself. Below is the sequence of events that take place within the operation of the decision tree and then the random forest classes:-
The first class that has been prepared is the Node. The Node class is comprised of two functions:-
Before the random forest algorithm can be implemented, the decision trees must be created in the DecisionTree class:-