Impute phone and sms NAs with 0

notes
Primoz 2022-09-01 09:57:21 +00:00
parent 3f7ec80c18
commit 86299d346b
2 changed files with 6 additions and 8 deletions

View File

@ -88,9 +88,8 @@ rapids_features <- function(sensor_data_files, time_segment, provider){
features <- call_features_of_type(calls_of_type, features_type, call_type, time_segment, requested_features)
call_features <- merge(call_features, features, all=TRUE)
}
# TODO: why isn't the next line properly replacing na values with 0
call_features <- call_features %>% mutate_at(vars(contains("countmostfrequentcontact") | contains("distinctcontacts") | contains("count") | contains("sumduration") | contains("minduration") | contains("maxduration") | contains("meanduration") | contains("modeduration")), list( ~ replace_na(., 0)))
# TODO: check if NaN values are filled
call_features[is.na(call_features)] = 0
# Fill NA values with 0
call_features <- call_features %>% mutate_all(~replace(., is.na(.), 0))
return(call_features)
}

View File

@ -65,9 +65,8 @@ rapids_features <- function(sensor_data_files, time_segment, provider){
features <- message_features_of_type(messages_of_type, message_type, time_segment, requested_features)
messages_features <- merge(messages_features, features, all=TRUE)
}
# TODO: why isn't the next line properly replacing na values with 0
messages_features <- messages_features %>% mutate_at(vars(contains("countmostfrequentcontact") | contains("distinctcontacts") | contains("count")), list( ~ replace_na(., 0)))
# TODO: check if NaN values are filled
messages_features[is.na(messages_features)] = 0
# Fill NA values with 0
messages_features <- messages_features %>% mutate_all(~replace(., is.na(.), 0))
return(messages_features)
}