Reference :-
https://towardsdatascience.com/regression-tree-in-python-from-scratch-9b7b64c815e3 <----- (This can be sufficient for Random Forest as well as Decision Tree too)
Requirement :-
See KNN as Classifier and Regressor, in models.py, where the mode can be switched by changing the boolean value of the "classify" argument.