Skip to content

Commit

Permalink
Delete old version of group_correlated_features()
Browse files Browse the repository at this point in the history
  • Loading branch information
kelly-sovacool committed Aug 17, 2021
1 parent dd382f3 commit fee7935
Showing 1 changed file with 0 additions and 52 deletions.
52 changes: 0 additions & 52 deletions R/corr_feats.R
Original file line number Diff line number Diff line change
Expand Up @@ -126,55 +126,3 @@ group_correlated_features <- function(features, corr_thresh = 1,
}
return(feat_groups)
}

#' Group correlated features
#'
#' @inheritParams run_ml
#' @inheritParams get_corr_feats
#' @return vector of where each element is a group of
#' correlated features separated by pipes (`|`)
#' @noRd
#' @author Begüm Topçuoğlu, \email{topcuoglu.begum@@gmail.com}
#' @author Zena Lapp, \email{zenalapp@@umich.edu}
group_correlated_features_OLD <- function(features, corr_thresh = 1,
group_neg_corr = TRUE, corr_method = "spearman") {
corr <- get_corr_feats(features,
corr_thresh = corr_thresh,
group_neg_corr = group_neg_corr,
corr_method = corr_method
)
corr <- dplyr::select_if(corr, !(names(corr) %in% c("corr")))

all_feats <- colnames(features)
corr_feats <- unique(c(corr$feature2, corr$feature1))
noncorr_feats <- all_feats[!all_feats %in% corr_feats]

grps <- as.list(noncorr_feats)
accounted_for <- rep(NA, length(all_feats))
af_length <- sum(!is.na(accounted_for))
c <- length(grps) + 1
for (i in corr_feats) {
if (i %in% accounted_for) next
feats <- unique(c(
i, corr$feature1[corr$feature2 == i],
corr$feature2[corr$feature1 == i]
))
new_feats <- TRUE
while (new_feats) {
len_feats <- length(feats)
for (j in feats) {
feats <- unique(c(
feats, j, corr$feature1[corr$feature2 == j],
corr$feature2[corr$feature1 == j]
))
}
new_feats <- length(feats) > len_feats
}
grps[[c]] <- feats
af_length_new <- sum(af_length, length(feats))
accounted_for[(af_length + 1):af_length_new] <- feats
af_length <- af_length_new
c <- c + 1
}
return(sapply(grps, paste, collapse = "|"))
}

0 comments on commit fee7935

Please sign in to comment.