Univariate feature ranking for classification using chi-square tests

ranks features (predictors) using chi-square tests.
The table `idx`

= fscchi2(`Tbl`

,`ResponseVarName`

)`Tbl`

contains predictor variables and a response variable,
and `ResponseVarName`

is the name of the response variable in
`Tbl`

. The function returns `idx`

, which contains
the indices of predictors ordered by predictor importance, meaning
`idx(1)`

is the index of the most important predictor. You can use
`idx`

to select important predictors for classification
problems.

specifies additional options using one or more name-value pair arguments in addition to
any of the input argument combinations in the previous syntaxes. For example, you can
specify prior probabilities and observation weights.`idx`

= fscchi2(___,`Name,Value`

)

If you specify the response variable and predictor variables by using the input argument

`formula`

, then the variable names in the formula must be both variable names in`Tbl`

(`Tbl.Properties.VariableNames`

) and valid MATLAB identifiers.You can verify the variable names in

`Tbl`

by using the`isvarname`

function. The following code returns logical`1`

(`true`

) for each variable that has a valid variable name.If the variable names incellfun(@isvarname,Tbl.Properties.VariableNames)

`Tbl`

are not valid, then convert them by using the`matlab.lang.makeValidName`

function.Tbl.Properties.VariableNames = matlab.lang.makeValidName(Tbl.Properties.VariableNames);