Rank discrete features by mutual information with a class label, and bound the error of any classifier that uses a feature.
Implement three functions (all information in bits):
mi_rank(X, y): X is an integer array of shape (N, D), y an integer array of shape (N,). For each feature compute the plug-in mutual information from the empirical joint distribution of the pairs . Return (order, mi) where mi is a float array of shape (D,) in feature order and order is a list of feature indices sorted by decreasing MI (ties keep the lower index first).fano_bounds(joint): joint is a joint pmf (or count table) of shape (|X|, |Y|), normalize it first. With and the number of columns, return (weak, tight):
weak ;tight = the smallest with , where is the binary entropy; accurate to .bayes_error(joint): the error of the best possible classifier, .Return plain floats from fano_bounds and bayes_error.