0
votes

I am asked to implement a Random Forest Classifier, which to my understanding is just a bunch of Decision Trees, on which the test data is ran through after training and the classification is then determined by majority voting of all the trees.

This is all well and good, and I even understand that entropy determines which feature to use next. What I am struggling to understand, is that for numeric data, how do I determine the conditions?

An example, is whether a person will play golf depending on weather conditions. Given 3 features (outlook, humidity, wind), and a classification label (play -> yes or no), we first start with outlook:

Outlook -> Overcast (pure), Sunny, Rain

From Sunny, choose Humidity next: High, Normal (pure)

From Outlook to Rain, choose Wind (last feature): Weak (pure), Strong

Essentially, in this case the values of the features are taken individually. But what happens, when I have a dataset with a bunch of decimals?

(Some of) the data:

enter image description here

In this case I would start by first looking at the label (0 or 1), then progress to the feature with the highest entropy in each. But how do I know the conditions of going to a leaf node? Or even, how many children a parent have? A poor diagram to aid my question:

enter image description here

1

1 Answers

0
votes

For a theoretical answer to your question, I would start by recommending this excellent visual tutorial.

http://www.r2d3.us/visual-intro-to-machine-learning-part-1/

In terms of implementation, there are several ways to go into it. You could try the following algorithm (inspired by this answer):

For each column (feature) in your dataset, start by sorting it. At every point where you have a class change, split your dataset. Say, for example, that your data points change from class 0 to 1 when feature A is equal to 5. All data points with A < 5 will belong to class 0, and the ones with A > 5 will belong to class 1. In case your dataset is not as simple, you can then proceed in the way you would proceed with a categorical decision tree, for example, by calculating the entropy at each splitting candidate. You then calculate the data points that arrive at each children node, and proceed recursively.