<commit_before>earth_BI <- function(n_boot, BIModelOutput, inputs, verbose=FALSE) {
  
  attach(inputs)
  
  earth_BI_obj <- vector('list', length(inputs))
  names(earth_BI_obj) <- names(inputs)
  
  for (i in names(earth_BI_obj)) {
   
    earth_BI_obj_i <- vector('list', 3)
    names(earth_BI_obj_i) <- c('LDW', 'HDW', 'MAT')
      
    for (j in names(earth_BI_obj_i)) {
    
      earth_BI_obj_ij <- vector('list', 15)
      
      for (k in seq_along(earth_BI_obj_ij) ) {
      
        earth_BI_obj_ijk <- vector('list', 2)
        
        BIModelOutputSS <- subset(BIModelOutput, CTAbbr == i & SSAbbr == j & Timestep == k * 10)
        BIModelOutputSS <- merge(BIModelOutputSS, get(sprintf('%sParams', i)), by.x=1, by.y=0)
        
        if(verbose) cat('Model: ')
        
        earth_BI_obj_ijk[[1]] <- earth(Area ~ ., data=BIModelOutputSS[-1:-4], degree=3)
        
        earth_BI_obj_ijk[[1]]$fitted.values <- NA
        
        if(verbose) cat(sprintf('%s %s %s \n', i, j, k))
        
        earth_BI_obj_ijk[[2]] <- mclapply(integer(n_boot), eval.parent(substitute(function(...) {
          x <- earth(Area ~ ., 
            data=BIModelOutputSS[sample(seq_len(nrow(BIModelOutputSS)), replace=TRUE), -1:-4], 
            degree=3)
          x$fitted.values <- NA
          x
          })), mc.cores=detectCores() / ceiling(n_boot / detectCores()))
        
        earth_BI_obj_ij[[k]] <- earth_BI_obj_ijk
        
      }

      earth_BI_obj_i[[j]] <- earth_BI_obj_ij
    
    }
    
    earth_BI_obj[[i]] <- earth_BI_obj_i
  
  }
  
  return(earth_BI_obj)
  
}  

<commit_msg>changes and bug fixes to earth_BI.r<commit_after>earth_BI <- function(n_boot, BIModelOutput, inputs, dir, verbose=FALSE) {
    
  for (i in names(inputs)) {
      
    for (j in c('LDW', 'HDW', 'MAT')) {
          
      for (k in 1:15) {
      
        earth_BI_obj_ijk <- vector('list', 2)
        
        BIModelOutputSS <- subset(BIModelOutput, CTAbbr == i & SSAbbr == j & Timestep == k * 10)
        BIModelOutputSS <- merge(BIModelOutputSS, inputs[[i]], by.x=1, by.y=0)
        
        if(verbose) cat('Model: ')
        
        earth_BI_obj_ijk[[1]] <- earth(qlogis(((Area / (1000 / 3)) * .998) + .001) ~ ., 
          data=BIModelOutputSS[-1:-4], degree=3)
        
        earth_BI_obj_ijk[[1]]$fitted.values <- NA
        
        if(verbose) cat(sprintf('%s %s %s \n', i, j, k))
        
        earth_BI_obj_ijk[[2]] <- mclapply(integer(n_boot), eval.parent(substitute(function(...) {
          x <- earth(qlogis(((Area / (1000 / 3)) * .998) + .001) ~ ., 
            data=BIModelOutputSS[sample(seq_len(nrow(BIModelOutputSS)), replace=TRUE), -1:-4], 
            degree=3)
          x$fitted.values <- NA
          x
          })), mc.cores=detectCores() / ceiling(n_boot / detectCores()))
        
        save('earth_BI_obj_ijk', file=sprintf('%s/%s_%s_%s.rda', dir, i, j, k))
        
      }
    
    }
      
  }
  
}  


{'fraction_non_alphanumeric': 0.1637228260869565, 'fraction_numerical': 0.019021739130434784, 'mean_word_length': 2.0934873949579833, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '856213', 'n_tokens_mistral': 1167, 'n_tokens_neox': 1101, 'n_words': 176}