Entropy is used to help create an optimized decision tree. I created an entropy function called getBestEnt so that given the information it has received, it will return the highest information gain and the index of the best feature to use for the decision tree.
Here's an example:
hair=[1 1 2 3 2 2 2 1];
eyes=[1 1 1 1 2 1 2 2];
height=[1 2 1 1 1 2 2 1];
allFeat=[eyes hair height];
[big ind]=getBestEnt(class, allFeat)
note: big stands for best information gain
The ind determines the 1nd feature(eyes) as the best feature
Chun Zheng (2021). Entropy (https://www.mathworks.com/matlabcentral/fileexchange/14996-entropy), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!