My training dataset has 1500 features - all numeric. (But only about 200 data points). I want to create additional features and then use the exhaustive list for feature selection.
For creating additional features, I considered generating all 2-way interactions between the features. I ran the following code in R - but it is taking a lot of time. For 1500 features, selecting all 2-way products will result in about 1.2 million features. After about 2 hours of running, the result had only about 300k features generated. Is there a more efficient way to generate this? Could this be done faster?
Here is the relevant code:
for(i in 1:ncol(train)){
for(j in i:ncol(train)){
two_way_features <- cbind(two_way_features,train[,i]*train[,j])
}}
EDIT: Apologies - I didn't add in the context. We are running an online campaign - sent to 200 companies. 6 measures were observed post the campaign. I have about 1500 features (including both about the campaign and about the companies). The aim is to learn from this. (And unfortunately, in B2B space, there's only so much we can do to get data. While I can try to get more features, can't expand to more than 200 customers/companies).
Learning from this data, we would like to predict the 6 measures for another set of 100 companies (on whom we plan to run the campaign post thanksgiving).
The entire dataset is numeric(both the measured target variables and the feature vectors). All of them are non-negative. No categorical variables too.
For now, glmnet is what I am doing. After playing with glmnet for a while with the given feature vectors, the cross-validation score hasn't been improving. I am trying to investigate if combination of feature vectors provide a better CV score. Given that there's really limited data points, I haven't explored outside glmnet. (strictly LASSO).
y ~ .^2
will consider all variables and their first-order interaction. It then depends on what model you want to use to perform feature selection. Formulae are not always efficient in R, but loops aren't either. If your question is specifically about feature selection with such irregular data set, please clarify. Otherwise, it will be migrated to Stack Overflow (no need to cross-post). $\endgroup$