R. A. Liaw द्वारा R में रैंडम फ़ॉरेस्ट पैकेज मूल कोड का एक पोर्ट है जो कुछ शेष फोरट्रान कोड और R आवरण कोड के सी-कोड (अनुवादित) का मिश्रण है। ब्रेक पॉइंट के पार और mtry वैरिएबल्स में ओवरऑल बेस्ट स्प्लिट तय करने के लिए, कोड gini-gain के समान स्कोरिंग फ़ंक्शन का उपयोग करता है:
GiniGain(N,X)=Gini(N)−|N1||N|Gini(N1)−|N2||N|Gini(N2)
XNN1N2N|.|
Gini(N)=1−∑Kk=1p2kK
Gini(N)
|N2||N|Gini(N2)∝|N2|Gini(N2)=|N2|(1−∑Kk=1p2k)=|N2|∑nclass22,k|N2|2
nclass1,k|N2|
1−
|N1|∑Kk=1p21,k+|N2|∑Kk=1p22,k=|N1|∑Kk=1nclass21,k|N1|2+|N2|∑Kk=1nclass22,k|N2|2
=∑Kk=1nclass22,k1|N1|−1+∑Kk=1nclass22,k1|N1|−2
=nominator1/denominator1+nominator2/denominator2
The implementation also allows for classwise up/down weighting of samples. Also very important when the implementation update this modified gini-gain, moving a single sample from one node to the other is very efficient. The sample can be substracted from nominators/denominators of one node and added to the others.
I wrote a prototype-RF some months ago, ignorantly recomputing from scratch gini-gain for every break-point and that was slower :)
If several splits scores are best, a random winner is picked.
This answer was based on inspecting source file "randomForest.x.x.tar.gz/src/classTree.c" line 209-250