I am a complete beginner in the field of machine learning. For a project, I have to use a customized loss function in the Random Forest Classification. I have used scikit till now. Suggestions on implementing this through scikit will be more helpful.
Asked
Active
Viewed 4,237 times
3
-
To avoid confusion, it should be pointed out that vanilla Decision Trees and Random Forests do not optimise an explicit loss function in the common sense of the word. You do have a choice, however, over the _split criterion_, which is used to determine when and where to split an internal tree node. – ngmir May 10 '23 at 07:27
1 Answers
3
Loss functions (Gini impurity and entropy in case of classification trees) are implemented in _tree.pyx cython file in scikit (they're called criteria in the source). You can start by modifying/adding to these functions. If you add your custom loss function (criterion) to the cython file, you also need to expose it in the tree.py python file (look at the CRITERIA_CLF and CRITERIA_REG lists).

Ando Saabas
- 1,967
- 14
- 12