I have a dataset with mostly financial variables (120 features, 4k examples) which are mostly highly correlated and very noisy (technical indicators, for example) so I would like to select about max 20-30 for later use with model training (binary classification - increase / decrease).

I was thinking about using random forests for feature ranking. Is it a good idea to use them recursively? For example, let's say in the first round I drop the worst 20%, second too and so on until I get the desired number of features. Should I use cross-validation with RF? (It's intuitive for me not to use CV because that's pretty much what RF does already.)

Also if I go with random forests should I use them as classifiers for the binary or regressor for the actual increase / decrease to get feature importances?

By the way, the models I would like to try after feature selection are: SVM, neural nets, locally weighted regressions, and random forest. I'm mainly working in Python.

  • 2
    would like to connect to exchange insights. i am working on something similar – user670186 Nov 23 '15 at 9:18
  • is there any reason why no one suggested to just use the built-in attribute of RandomForestClassifier in sklearn called feature_importances_....? You'll see it in the link. – Candic3 Jan 4 '16 at 16:26
  • Beware because multicollinearity can distort feature importances and feature selection. check it out here – Candic3 Jan 4 '16 at 17:08
  • Beware of the default algorithms: parrt.cs.usfca.edu/doc/rf-importance/index.html – Tim Jun 1 at 7:12

For feature selection, we need a scoring function as well as a search method to optimize the scoring function.

You may use RF as a feature ranking method if you define some relevant importance score. RF will select features based on random with replacement method and group every subset in a separate subspace (called random subspace). One scoring function of importance could be based on assigning the accuracy of every tree for every feature in that random subspace. Then, you do this for every separate tree. Since, the source of generating the subspaces is random, you may put a threshold for computing the importance score.

Summary:

Step1: If feature X2 appears in 25% of the trees, then, score it. Otherwise, do not consider ranking the feature because we do not have sufficient information about its performance

Step2: Now, assign the performance score of every tree in which X2 appears to X2 and average the score. For example: perf(Tree1) = 0.85 perf(Tree2) = 0.70 perf(Tree3) = 0.30

Then, the importance of feature X2 = (0.85+0.70+0.30)/3 = 0.6167

You may consider a more advanced setting by including the split depth of the feature or the information gain value in the decision tree. There can be many ways to design a scoring function based on decision trees and RF.

Regarding the search method, your recursive method seems reasonable as a way to select the top ranked ones.

Finally, you may use RF either as a classifier or a regression model in selecting your features since both of them would supply you with a performance score. The score is indicative as it is based on the out-of-bag OOB samples and you may not consider cross-validation in a simpler setting.

  • Thanks for the input. Did want to point out that (0.85+0.70+0.30)/3 = 0.6167. – Hendy Dec 9 '13 at 3:16
  • 5
    If you are working with python, you can directly use the variable importance calculated in sklearn when calling a random forest. – Scratch Jan 10 '14 at 13:50

I have a dataset with mostly financial variables (120 features, 4k examples) which are mostly highly correlated and very noisy (technical indicators, for example) so I would like to select about max 20-30 for later use with model training (binary classification - increase / decrease).

4k examples is really not enough to estimate anything very sophisticated - you need to use the simplest possible models ( linear /logistic regression, linear svm) and small number of variables

Given that your data is noisy and correlated, PCA is probably your best bet [ it is effectively identifying the common signals averaging over the individual indicators]

L2 regularisation (for a linear model) will also help averaging out the noise [eg if you have n noisy copies of the same signal, l2 regularisation will encourage weights to be same - averaging those n variables]

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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