I have 8 features for a classification problem. The target value tells if there was an anomaly or not.

I want to run some significance tests to rank each feature, as being a distinctive feature of anomalies.

Could you please suggest some significance tests for this in Python?


One of the easiest ways to do this is with a correlation matrix. Variables that are correlated with the value you are predicting will probably be good predictors. Here is a good answer on how to do that in Python:


However - be careful. If your variables are correlated with the response variable (the one you are predicting) AND they are correlated with each other it may be best to use just one of those variables instead of both.

The "best case" scenario is that you are predicting "y" which is correlated with "x" and "z" but "x" and "z" are not correlated at all with each other.

Because you are testing for anomalies (a binary response?) you can transform your predictor variables to be between 0 and 1 and then test the correlation between your transformed predictors and with your predictor variable.

If you want a significance test for which variables will be good predictors you will have to build some models. I know that in R the summary(...) function returns the statistical significance of regression model coefficients - there is probably a similar functionality in Python.

  • $\begingroup$ Thank you for the answer. I know about correlation matrix. But does that rank the features according to their importance or significance? $\endgroup$
    – Veronica
    Mar 2 '20 at 19:20
  • $\begingroup$ "Importance" is pretty subjective. "Significance" can be measured but only after the model is built. There is no easy way to get a list of the "most significant" or "most important" features - you have to do some detective work and use your own judgement. That is half of the fun! $\endgroup$
    – bstrain
    Mar 2 '20 at 22:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.