Categories &

Functions List

Function Reference: fscmrmr

statistics: idx = fscmrmr (Tbl, ResponseVarName)

statistics: idx = fscmrmr (Tbl, formula)

statistics: idx = fscmrmr (Tbl, Y)

statistics: idx = fscmrmr (X, Y)

statistics: idx = fscmrmr (…, name, value)

statistics: [idx, scores] = fscmrmr (…)

Rank the predictors for classification by minimum redundancy and maximum relevance.

idx = fscmrmr (X, Y) ranks the predictors, the columns of the matrix X, by how much they tell about the class labels Y and how little they repeat each other, both measured by mutual information. idx is a row vector of column indices, from the most important predictor to the least.

X is a real matrix of type double or single with one row per observation. Y holds one class label per row of X: a numeric or logical vector, a categorical vector, a cell array of character vectors, a string array, or a character matrix with one row per observation.

idx = fscmrmr (Tbl, ResponseVarName) takes the predictors and the class labels from the table Tbl: ResponseVarName names the variable holding the labels and every other variable is a predictor. idx = fscmrmr (Tbl, formula) names them with a model formula instead, 'Y ~ x1 + x2', which holds main effects only, and ranks only the predictors it names, idx indexing them in the order the table holds them. idx = fscmrmr (Tbl, Y) takes the predictors from the table and the labels from Y. A logical, categorical, text or string variable of the table is a categorical predictor; an ordinal categorical one is continuous, its categories in their order.

[idx, scores] = fscmrmr (…) also returns the score of each predictor, a row vector in the order of the predictors. The score is the value on which the predictor was chosen, as described below, so a larger score marks a more important predictor when it was chosen, but the scores need not decrease along idx.

The relevance of a predictor is its mutual information with the class labels, and its redundancy the mean of its mutual information with each predictor already ranked. The predictors are ranked in six steps, after Ding and Peng:

  1. The predictor of largest relevance is ranked first. Its score is its relevance.
  2. Of the predictors left, those of nonzero relevance and zero redundancy are ranked next, the one of largest relevance first. Each scores its relevance.
  3. Step 2 is repeated until no such predictor is left.
  4. Of the predictors left, the one of nonzero relevance whose relevance divided by its redundancy is the largest is ranked next. It scores that quotient.
  5. Step 4 is repeated until every predictor left has zero relevance.
  6. The predictors of zero relevance are ranked last, in the order of the columns, each scoring 0.

Predictors of equal value keep the order of the columns at every step.

Mutual information is in nats. Between two categorical variables it is the plain estimate from their table of weighted counts. Where one variable is continuous it is the adaptive partitioning estimate of Darbellay and Vajda. The continuous variables are replaced by their ranks, so the estimate does not change under an increasing transformation of either. The observations are divided into rectangular cells, starting from a single cell, and a cell is split into 2 by 2 cells while it shows dependence. A cell is tested by dividing it at the quantiles of the strips it spans into 2 by 2 and into 4 by 4 parts and comparing the weighted count of each part with the count the strips predict, by a chi-square statistic with 3 and 15 degrees of freedom at the 3% level; the cell stays whole only when neither statistic is significant. The estimate is then the sum over the cells of P(A,B) log (P(A,B) / (P(A) P(B))), P(A) and P(B) being the shares of the strips the cell spans. A categorical variable is not divided: its categories are its strips, and the cells along each category are tested and split on their own, with 1 and 3 degrees of freedom. Equal values are never parted, the quantiles moving to the nearest change of value.

Each estimate uses the observations known for both of its variables. Their weights are scaled within each class so that the class carries its prior probability, and over all so that they sum to the number of those observations; the quantiles and the counts are taken by weight. The empirical prior, the default, is the weighted share of each class among those observations, which leaves the weights as given. An observation whose class label is missing is left out of every estimate.

The following Name-Value pairs are supported:

NameValue
'CategoricalPredictors'The categorical predictors: a vector of their indices, a logical vector with one value per predictor, or 'all'. With a table they are added to those the table makes categorical, and they may also be named. The default is none for a matrix.
'ClassNames'The classes to use, in the type of Y. Observations of other classes are left out, and the order of the names is the order of a 'Prior' vector. The default is every class of Y, sorted.
'Prior'The prior probabilities of the classes: 'empirical', the default; 'uniform'; a vector with one nonnegative value per class, in the order of the classes; or a structure with the fields ClassNames and ClassProbs. The values are normalized to sum to 1.
'UseMissing'false, the default, to estimate each mutual information on the observations known for both variables, or true to use every observation, the missing values of a categorical predictor forming one more category and those of a continuous predictor one more strip, which is never divided but whose cells are split along the other variable as the cells of a category are.
'Verbose'A nonnegative integer. The default, 0, prints nothing; 1 or more prints the time taken by the mutual information and by the ranking.
'Weights'The observation weights, a nonnegative finite vector of type double or single with one value per row, or with a table the name of one of its variables, which is then no predictor. The default is equal weights.

The option names are not case sensitive but must be given in full. With a matrix, the categorical predictors cannot be named, the predictors having no names, as in MATLAB.

MATLAB documents the same six steps and the same estimator, but R2024a follows neither exactly. Its scores and its order depart from the steps once redundancy enters, at times ranking a predictor of nonzero relevance after those of none. Its estimator does not test a cell on 4 by 4 parts, so it scores 0 a predictor whose classes alternate in equal blocks, which this estimate finds, and it falls short of the class entropy on some predictors that separate the classes. It first cuts a continuous variable into 256 bins, which is not done here, and it ranks the predictors of zero relevance in random order.

References:

  1. C. Ding and H. Peng, "Minimum redundancy feature selection from microarray gene expression data", Journal of Bioinformatics and Computational Biology, 3(2):185-205, 2005.
  2. G. A. Darbellay and I. Vajda, "Estimation of the information by an adaptive partitioning of the observation space", IEEE Transactions on Information Theory, 45(4):1315-1321, 1999.

See also: fscchi2, fsrftest, relieff, sequentialfs

Source Code: fscmrmr