-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREFINE CHOLERA DATA ANALYSIS.R
More file actions
87 lines (49 loc) · 1.85 KB
/
Copy pathREFINE CHOLERA DATA ANALYSIS.R
File metadata and controls
87 lines (49 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
{
library(tidyverse)
library(skimr)
library(countrycode)
library(modelStudio)
library(DALEX)
library(tidymodels)
library(xgboost)
}
# LOAD AND READ DATASET ---------------------------------------------------
cholera_reported_cases <- read.csv("C:/Users/PC-005/Downloads/Reported-Cases-Till-2016.csv")
cholera_reported_cases%>%
glimpse()%>%
skim()
cholera_death_cases <- read.csv("C:/Users/PC-005/Downloads/Number-of-Deaths-Till-2016.csv")
cholera_death_cases%>%
glimpse()%>%
skim()
# CONVERT CHARACTER COLUMN WITH REPORTED/DEATH CASES TO NUMERIC USING FIX FUNCTION --------
fix(cholera_reported_cases)
restructure_cholera_reportedcases <- fix(cholera_reported_cases)
restructure_cholera_reportedcases%>%
glimpse()%>%
skim()
fix(cholera_death_cases)
restructure_cholera_deathcases <- fix(cholera_death_cases)
restructure_cholera_deathcases%>%
glimpse()%>%
skim()
cholera_combine_dataset <- merge(restructure_cholera_reportedcases,restructure_cholera_deathcases)
cholera_combine_dataset%>%
drop_na()%>%
glimpse()%>%
skim()
# CREATE AN XGBOOST MODEL -------------------------------------------------
cholera_xgboost_model <- boost_tree(learn_rate = 0.3) %>%
set_mode("regression") %>%
set_engine("xgboost") %>%
fit(Number.of.reported.deaths.from.cholera ~ ., data = cholera_combine_dataset )
cholera_xgboost_model
# CHOLERA EXPLAINER -------------------------------------------------------
cholera_explainer <- DALEX::explain(
model = cholera_xgboost_model,
data = cholera_combine_dataset ,
y = cholera_combine_dataset$Number.of.reported.deaths.from.cholera,
label = "XGBoost Model for Cholera"
)
# RUN THE MODELSTUDIO FOR CHOLERA DATASET --------------------------------
modelStudio::modelStudio(cholera_explainer)