Identify correlated features

get_corr_feats(
  features,
  corr_thresh = 1,
  group_neg_corr = TRUE,
  corr_method = "spearman"
)

Arguments

features

Features used for machine learning.

corr_thresh

For feature importance, group correlations above or equal to corr_thresh (range 0 to 1; default: 1).

group_neg_corr

Whether to group negatively correlated features together (e.g. c(0,1) and c(1,0)).

corr_method

correlation method. options or the same as those supported by stats::cor: spearman, pearson, kendall. (default: spearman)

Value

Dataframe of correlated features where the columns are feature1, feature2, and the correlation between those two features (anything exceeding corr_thresh).

Author

Begüm Topçuoğlu, topcuoglu.begum@gmail.com

Zena Lapp, zenalapp@umich.edu

Examples

set.seed(0) mat <- matrix(runif(100), nrow = 20) rownames(mat) <- 1:nrow(mat) colnames(mat) <- 1:ncol(mat) get_corr_feats(mat, 0.4)
#> feature1 feature2 corr #> 1 1 3 -0.4225564 #> 2 3 5 -0.5729323