Finish the entropy function for categorical dataset.