Applied Supervised Learning with R by Karthik Ramasubramanian and Jojo Moolayil

Applied Supervised Learning with R by Karthik Ramasubramanian and Jojo Moolayil

Author:Karthik Ramasubramanian and Jojo Moolayil
Language: eng
Format: epub
Publisher: Packt Publishing Pvt. Ltd.
Published: 2019-05-30T00:00:00+00:00


Reduce the number of distinct locations in the variable. This can be done by tagging all the locations that are not a part of the location_list list as Others:df_new$new_location <- factor(ifelse(df_new$Location %in% location_list,df_new$Location,"Others"))

Delete the old Location variable using the following command:df_new$Location <- NULL

To ensure that the fifth step was correctly performed, we can create a temporary DataFrame and summarize the frequency of records against the new location variable we created:temp <- df_new %>% mutate(loc = as.character(new_location)) %>% group_by(as.character(loc)) %>% summarise(Rain = sum(ifelse(RainTomorrow =="Yes",1,0)), cnt=n()) %>% mutate(pct = Rain/cnt) %>% arrange(desc(pct))



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.