-
Notifications
You must be signed in to change notification settings - Fork 1
/
drug_health_plan.Rmd
442 lines (383 loc) · 19.1 KB
/
drug_health_plan.Rmd
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
---
title: "Drug and Health Plan Rating"
author: "Bowen Liu"
date: "March 3, 2016"
output:
html_document: default
pdf_document:
number_sections: yes
word_document: default
---
# Problem Description & Current State of Affairs
Medicare.gov released recent two years's data about "Drug and Health Plan" coverage around the country. The data inclues who, when, where, and how the plans were used. There are many plans with low ratings. And we want to find out how predictors such as political affiliation, income level, insurance rates, unemployment rates, hospital type, or happiness index contribute to the final rating of one specific type of plan. This is where we start to build the predicition modeling. It could be taken for reference for future plan upgrading or new plan release.
# Algorithms Used and Rationale
| Algorithms | Rationale |
|--------------|--------------------------------------------------------------|
|Logistic Regession, Naive Bayes, Decision Tree, ANN|Since the project is one supervised problem, we are going to apply multiple prediction models to the datasets. And we will choose the final one with the highest accuracy.|
# Drug and Health Plan with copay, deductible, coinsurance
- Origin: www.medicare.gov
- Data Points after preprocessing: 816 obs. of 5 variables
- variables: contract_id, mnthly_prm, ann_ddctble, copay_max, coin_max
```{r,cache=TRUE,warning=FALSE,message=FALSE}
drug_cost <- read.csv("./data/2015Med2000_flatfiles/vwPlanDrugsCostSharing.csv", stringsAsFactors = FALSE, na.strings = c("Information Not Available", ""))
# keep the copay, deductible, and coinsurance
colnames <- c("contract_id", "plan_id", "mnthly_prm", "ann_ddctbl", "copay_amt_inn_prefrd", "coins_amt_inn_prefrd")
drug_cost2 <- drug_cost[,colnames]
drug_cost3 <- drug_cost2
# split the range into standalone characters
drug_cost3$copay_low <- sapply(strsplit(drug_cost2$copay_amt_inn_prefrd, split="-"), '[', 1)
drug_cost3$copay_high <- sapply(strsplit(drug_cost2$copay_amt_inn_prefrd, split="-"), '[', 2)
drug_cost3$coin_low <- sapply(strsplit(drug_cost2$coins_amt_inn_prefrd, split="-"), '[', 1)
drug_cost3$coin_high <- sapply(strsplit(drug_cost2$coins_amt_inn_prefrd, split="-"), '[', 2)
# remove $ and %
library(gdata)
drug_cost3$copay_low <- gsub("^\\$", "", trim(drug_cost3$copay_low))
drug_cost3$copay_high <- gsub("^\\$", "", trim(drug_cost3$copay_high))
drug_cost3$coin_low <- gsub("%$", "", trim(drug_cost3$coin_low))
drug_cost3$coin_high <- gsub("%$", "", trim(drug_cost3$coin_high))
# drug_cost3 <- na.omit(drug_cost3)
#change NA to 0
drug_cost3$copay_low[is.na(drug_cost3$copay_low)] <- 0
drug_cost3$copay_high[is.na(drug_cost3$copay_high)] <- 0
drug_cost3$coin_low[is.na(drug_cost3$coin_low)] <- 0
drug_cost3$coin_high[is.na(drug_cost3$coin_high)] <- 0
# choose the maxium value
drug_cost3$copay_max <- apply(drug_cost3[, c("copay_low", "copay_high")], 1, max)
drug_cost3$coin_max <- apply(drug_cost3[, c("coin_low", "coin_low")], 1, max)
# subset the needed matrix
drug_cost4 <- drug_cost3[, c("contract_id", "mnthly_prm", "ann_ddctbl", "copay_max", "coin_max")]
# change the column type to numeric
drug_cost4$ann_ddctbl <- as.numeric(drug_cost4$ann_ddctbl)
drug_cost4$copay_max <- as.numeric(drug_cost4$copay_max)
drug_cost4$coin_max <- as.numeric(drug_cost4$coin_max)
drug_cost4$mnthly_prm <- as.numeric(drug_cost4$mnthly_prm)
# aggreate the drug_cost by contract id
drug_cost4_aggr1 <- aggregate(drug_cost4[,c("mnthly_prm", "ann_ddctbl")], by = list(drug_cost4$contract_id), FUN = mean)
drug_cost4_aggr2 <- aggregate(drug_cost4[,c("copay_max", "coin_max")], by = list(drug_cost4$contract_id), FUN = max)
drug_cost4_aggr <- merge(drug_cost4_aggr1, drug_cost4_aggr2, all = TRUE, by.x = "Group.1", by.y = "Group.1")
colnames(drug_cost4_aggr) <- c("contract_id", "mnthly_prm", "ann_ddctbl", "copay_max", "coin_max")
#write.csv(drug_cost4_aggr, file = "./data/internal_drugcost.csv")
str(drug_cost4_aggr)
tail(drug_cost4_aggr)
```
# Drug and Health Cost Tier Level
- Origin: www.medicare.gov
- Data Points after preprocessing: 585 obs. of 2 variables
- variables: contract_id, tier_label
```{r,cache=TRUE,warning=FALSE}
# load vwPlanDrugTierCost.csv
cost_tier <- read.csv("./data/2015Med2000_flatfiles/vwPlanDrugTierCost.csv", stringsAsFactors = FALSE)
# keep contract_id, plan_id, languange_id, tier_lable
colnames <- c("contract_id", "language_id", "tier_label")
cost_tier2 <- cost_tier[, colnames]
cost_tier2 <- cost_tier2[cost_tier2$language_id == "1", ]
cost_tier3 <- cost_tier2[, c("contract_id", "tier_label")]
# count unique tier numbers for each contract id
cost_tier4 <- aggregate(data = cost_tier3, tier_label ~ contract_id, function(x) length(unique(x)))
#write.csv(drug_cost4_aggr, file = "./data/internal_costtier.csv")
str(cost_tier4)
tail(cost_tier4)
```
# Durg and Health Plan Score Ratings
- Origin: www.medicare.gov
- Data Points after preprocessing: 1214 obs. of 3 variables
- variables: Contract_ID, Summary_Score, Star_Rating_Current
```{r,cache=TRUE,warning=FALSE}
# load rating data
ratingdata <- read.csv("./data/2015StarRatings_flatfiles/vwStarRating_SummaryScores.csv",na.strings = c("Plan too new to be measured", "Not enough data available"), stringsAsFactors = FALSE)
# remove Spanish Version
ratingdata2 <- ratingdata[ratingdata$lang_dscrptn=="English",]
# keep the columns of "Contract_ID", "Summary_Score", "Star_Rating_Current"
colnames <- c("Contract_ID", "Summary_Score", "Star_Rating_Current")
ratingdata2 <- ratingdata2[, colnames]
# split the string to get the rating number
ratingdata2$Star_Rating_Current <- sapply(strsplit(ratingdata2$Star_Rating_Current, split=" "), '[', 1)
#ratingdata2$Star_Rating_Previous <- sapply(strsplit(ratingdata2$Star_Rating_Previous, split=" "), '[', 1)
# remove NAs of the current 2015 year
ratingdata2_nocurrna <- ratingdata2[(!is.na(ratingdata2$Star_Rating_Current)), ]
# subset the rating data
ratingdata3 <- ratingdata2_nocurrna[ratingdata2_nocurrna$Summary_Score=="Overall Star Rating", 1:3]
#write.csv(ratingdata3, file = "./data/ratingdata.csv")
str(ratingdata2_nocurrna)
tail(ratingdata2_nocurrna)
#head(ratingdata3)
```
# Intermediate Data to Connect Contract and Zipcode
- Origin: www.medicare.gov
- Data Points after preprocessing: 364,847 obs. of 2 variables
- variables: Zip_Code, Contract_ID
```{r,cache=TRUE,warning=FALSE}
zip_contract <- read.csv("./data/2015Med2000_flatfiles/vwLocalContractServiceAreas.csv", stringsAsFactors = FALSE)
zip_contract2 <- unique(zip_contract[, c("Zip_Code", "Contract_ID")])
#write.csv(zip_contract2, file = "./data/internal_geography.csv")
str(zip_contract2)
tail(zip_contract2)
```
# Internal Features Combination: by contract_id
- Data Points after preprocessing: 227,432 obs. of 9 variables
- variables: contract_id, tier_label, mnthly_prm, ann_ddctbl, copay_max, coin_max, Summary_Score, Star_Rating_Current, Zip_Code
```{r,cache=TRUE,warning=FALSE}
cost <- merge(cost_tier4, drug_cost4_aggr, all = TRUE, by = "contract_id")
cost_rating <- merge(cost, ratingdata3, all = TRUE, by.x = "contract_id", by.y = "Contract_ID")
cost_rating_zip <- merge(cost_rating, zip_contract2, all = TRUE, by.x = "contract_id", by.y = "Contract_ID")
cost_rating_zip2 <- na.omit(cost_rating_zip)
str(cost_rating_zip2)
tail(cost_rating_zip)
#write.csv(cost_rating_zip2, file = "./data/internal_data.csv")
```
# Unemployment Rate
- Origin: http://zipatlas.com
- Data Points after preprocessing: 29,252 obs. of 3 variables
- variables: zipcode, polulation, unemployment_rate
```{r,cache=TRUE,warning=FALSE}
unemployment_data <- read.table("./data/unemployment.txt", stringsAsFactors = FALSE)
unemployment_data2 <- unemployment_data[, c(2, 6, 7)]
colnames(unemployment_data2) <- c("zipcode", "polulation", "unemployment_rate")
unemployment_data2$polulation <- as.numeric(gsub("[[:punct:]]", "", unemployment_data2$polulation))
unemployment_data2$unemployment_rate <- as.numeric(unemployment_data2$unemployment_rate)
#write.csv(cost_rating_zip2, file = "./data/external_unemploy.csv")
str(unemployment_data2)
tail(unemployment_data2)
```
# Total Income
- Origin: https://www.irs.gov/uac/SOI-Tax-Stats-Individual-Income-Tax-Statistics-2013-ZIP-Code-Data-(SOI)
- Data Points after preprocessing: 27,790 obs. of 2 variables
- variables: ZIPCODE, total_income
```{r,cache=TRUE,warning=FALSE}
income_data <- read.csv("./data/zipcode2013/zipcodenoagi13.csv", stringsAsFactors = FALSE)
income_data2 <- income_data[, c("ZIPCODE", "A02650")]
colnames(income_data2)[2] <- "total_income"
#write.csv(income_data2, file = "./data/external_income.csv")
str(income_data2)
tail(income_data2)
```
# Physician
- Origin: https://www.irs.gov/uac/SOI-Tax-Stats-Individual-Income-Tax-Statistics-2013-ZIP-Code-Data-(SOI)
- author: Yang Gu
- Data Points after preprocessing: 41,184. of 4 variables
- variables: count, experience, spec_count, zip_code
```{r,cache=TRUE,warning=FALSE,message=FALSE}
# creates number of doctors, average years of experience, and number of specializations BY COUNTY
# indexed by each zip code (e.g. 5 zip codes in one county would all have same info)
#read physician data set, select subset, remove non-complete rows
doctors <- read.csv('./data/physician.csv', stringsAsFactors = FALSE)
str(doctors)
myVars <- c("NPI", "Graduation.year","Primary.specialty","City", "State", "Zip.Code")
doctors <- doctors[myVars]
doctors <- doctors[complete.cases(doctors),]
str(doctors)
head(doctors)
#deal with zip code format
doctors$Zip.Code<- as.numeric(doctors$Zip.Code)
doctors$set<-ifelse(doctors$Zip.Code > 99999,1, 2)
#separate data by 9-digit and 5-digit formats
data <- split(doctors, doctors$set)
temp1<-data[[1]] #data with 9-digit zip Codes
#add leading zeros so all data has 9 digits: 1234567 --> 001234567
# take first 5 digits, then remove 0s: 00123 --> 123
library(stringr)
temp1$Zip.Code <-str_pad(temp1$Zip.Code, 9, pad = "0")
temp1$Zip.Code <-substr(temp1$Zip.Code,0,5)
temp1$Zip.Code <-substr(temp1$Zip.Code,regexpr("[^0]",temp1$Zip.Code),nchar(temp1$Zip.Code))
#recombine dataset separated by zip code
doctors <- rbind(temp1, data[[2]])
doctors$set <- NULL #remove dummy variable
#data cleaning & renaming
doctors[2]<-2016 - doctors$Graduation.year
names(doctors)[2] <- "experience"
names(doctors)[6] <- "zip_code"
head(doctors)
#combine geography information. Fill in zips w/o doctors w/ 0
geography <-read.csv('./data/geographyGood.csv', stringsAsFactors = FALSE)
#myVars <- c("CountyFIPSCode","zip_code")
#geography <- geography[myVars]
names(geography)[2] <- "CountyFIPSCode"
doctors <- merge(x=doctors, y=geography, by="zip_code")
doctors[is.na(doctors)] <- 0
doctors<- unique(doctors)
library(plyr)
#create dataset for number of doctors in each county
myVars <- c("NPI","CountyFIPSCode")
docNum <- doctors[myVars]
docNum <- ddply(docNum, .(CountyFIPSCode), mutate, count = length(unique(NPI)))
docNum$NPI<- NULL
docNum <- unique((docNum))
docNum <- docNum[complete.cases(docNum),]
#create dataset for average experience of doctors in each county
myVars <- c("experience","CountyFIPSCode")
yearDoc <- doctors[myVars]
yearDoc<- aggregate(yearDoc,by=list(yearDoc$CountyFIPSCode), FUN=mean, na.rm=TRUE)
yearDoc$Group.1 <-NULL
#join on county code
docNum <- merge(x=docNum, y=yearDoc, by="CountyFIPSCode", all.x = TRUE )
#create dataset for number of specialties in each county
myVars <- c("Primary.specialty","CountyFIPSCode")
docSpec <- doctors[myVars]
docSpec <- ddply(docSpec, .(CountyFIPSCode), mutate, count = length(unique(Primary.specialty)))
docSpec$Primary.specialty <- NULL
docSpec <- unique((docSpec))
names(docSpec)[2]<- "spec_count"
docNum <- merge(x=docNum, y=docSpec, by="CountyFIPSCode", all.x = TRUE )
#docNum$count<-ifelse(docNum$experience == 0,0, docNum$count)
#docNum$spec_count<-ifelse(docNum$experience == 0,0, docNum$spec_count)
geography <- merge(x = docNum, y = geography, all.y = TRUE)
geography[is.na(geography)] <- 0
docNum <- geography
docNum$StateCode <- docNum$StateName <- docNum$CountyName <- NULL
rm(docSpec, doctors, yearDoc, data)
temp <- docNum$zip_code
temp <- unique(temp)
n_occur <- data.frame(table(docNum$zip_code))
n_occur[n_occur$Freq > 1,]
dupes <- docNum[docNum$zip_code %in% n_occur$Var1[n_occur$Freq > 1],]
#write.csv(docNum, file = "./data/docByZip2.csv",row.names=FALSE)
physician <- read.csv(file = "./data/docByZip2.csv", stringsAsFactors = FALSE)
str(physician)
```
# External Features Combination: by zip code
- Origin:
- Data Points after preprocessing: 36,755 obs. of 6 variables
- variables: zip_code, experience, spec_count, unemployment_rate, average_income, avgerage_physician
```{r,cache=TRUE,warning=FALSE}
unemploy_Income <- merge(unemployment_data2, income_data2, all = TRUE, by.x = "zipcode", by.y = "ZIPCODE")
unemploy_Income_0na <- na.omit(unemploy_Income)
unemploy_Income_0na$average_income <- unemploy_Income_0na$total_income / unemploy_Income_0na$polulation
phy_unemploy_income <- merge(physician, unemploy_Income_0na, all = TRUE, by.x = "zip_code", by.y = "zipcode")
phy_unemploy_income_0na <- na.omit(phy_unemploy_income)
phy_unemploy_income_0na$average_physician = round(phy_unemploy_income_0na$polulation / (phy_unemploy_income_0na$count + 1))
str(phy_unemploy_income_0na)
#write.csv(phy_unemploy_income_0na, file = "./external_data_v2.csv")
```
# Combine Internal and External Data
- Data Points after preprocessing: 187,488 obs. of 14 variables
- variables: zip_code, experience, spec_count, unemployment_rate, average_income, avgerage_physician, contract_id, tier_label, mnthly_prm, ann_ddctbl, copay_max, coin_max, Star_Rating_Current
```{r,cache=TRUE,warning=FALSE}
final_data <- merge(phy_unemploy_income_0na, cost_rating_zip2, all = TRUE, by.x = "zip_code", by.y = "Zip_Code")
final_data <- na.omit(final_data)
colnames <- c('zip_code', 'experience', 'spec_count', 'unemployment_rate', 'average_income', 'average_physician', 'contract_id', 'tier_label', 'mnthly_prm', 'ann_ddctbl', 'copay_max', 'coin_max', 'Star_Rating_Current')
final_data2 <- final_data[, colnames]
str(final_data2)
tail(final_data2)
#write.csv(final_data2, file = "./data/final_data_v2.csv", row.names = FALSE)
```
# Combine Geographic Info
- Origin:
- Data Points after preprocessing: 132,083 obs. of 18 variables
- variables:
```{r,cache=TRUE,warning=FALSE}
geo <- read.csv(file = "./data/zip_codes_states.csv", stringsAsFactors = FALSE)
final_data3 <- merge(final_data2, geo, all.x = TRUE, by.x = "zip_code", by.y = "zip_code")
str(final_data3)
#final_data3 <- unique(final_data3)
#write.csv(final_data3, file = "./data/final_data_v3.csv", row.names = FALSE)
```
# Exploratory Plotting
```{r,cache=TRUE}
library(ggplot2)
library(gridExtra)
summary(final_data3)
plotdata <- final_data3
# external feature plotting
ggplot(data = plotdata, aes(factor(Star_Rating_Current), experience)) +
guides(fill=FALSE) +
labs(x="Rating Scores", y="Average Experience Years") +
geom_boxplot(aes(fill = factor(Star_Rating_Current)))
ggplot(data = plotdata, aes(factor(Star_Rating_Current), spec_count)) +
guides(fill=FALSE) +
labs(x="Rating Scores", y="Specialty Counts") +
geom_boxplot(aes(fill = factor(Star_Rating_Current)))
ggplot(data = plotdata, aes(factor(Star_Rating_Current), unemployment_rate)) +
guides(fill=FALSE) +
labs(x="Rating Scores", y="Unemployment Rate(%)") +
geom_boxplot(aes(fill = factor(Star_Rating_Current)))
ggplot(data = plotdata, aes(factor(Star_Rating_Current), average_income)) +
guides(fill=FALSE) +
labs(x="Rating Scores", y="Average Income(,000$)") +
geom_boxplot(aes(fill = factor(Star_Rating_Current)))
ggplot(data = plotdata, aes(factor(Star_Rating_Current), average_physician)) +
#theme(legend.position="bottom", legend.title=element_blank()) +
guides(fill=FALSE) +
labs(x="Rating Scores", y="Average Citizens per Physician") +
geom_boxplot(aes(fill = factor(Star_Rating_Current)))
# external feature plotting
ggplot(data = plotdata, aes(factor(Star_Rating_Current), tier_label)) +
guides(fill=FALSE) +
labs(x="Rating Scores", y="Tiers") +
geom_boxplot(aes(fill = factor(Star_Rating_Current)))
ggplot(data = plotdata, aes(factor(Star_Rating_Current), mnthly_prm)) +
guides(fill=FALSE) +
labs(x="Rating Scores", y="Monthly Premium") +
geom_boxplot(aes(fill = factor(Star_Rating_Current)))
ggplot(data = plotdata, aes(factor(Star_Rating_Current), ann_ddctbl)) +
guides(fill=FALSE) +
labs(x="Rating Scores", y="Annualy Deductible") +
geom_boxplot(aes(fill = factor(Star_Rating_Current)))
ggplot(data = plotdata, aes(factor(Star_Rating_Current), copay_max)) +
guides(fill=FALSE) +
labs(x="Rating Scores", y="Maxium Copayment") +
geom_boxplot(aes(fill = factor(Star_Rating_Current)))
ggplot(data = plotdata, aes(factor(Star_Rating_Current), coin_max)) +
#theme(legend.position="bottom", legend.title=element_blank()) +
guides(fill=FALSE) +
labs(x="Rating Scores", y="Maxium Coinsurance") +
geom_boxplot(aes(fill = factor(Star_Rating_Current)))
ggplot(data = plotdata, aes(factor(Star_Rating_Current))) +
guides(fill=FALSE) +
geom_bar(aes(fill = factor(Star_Rating_Current)))
# explore the clustering of
```
# Split the dataset for modeling
```{r,cache=TRUE,warning=FALSE}
final_data3 <- read.csv(file = './data/final_data_v3.csv')
# remove neutral 4 points, and change the label into 1 and 0
final_data3_rm4 <- final_data3[final_data3$Star_Rating_Current != 4, ]
# transfer the label into binary value
final_data3_rm4$sentiment <- as.factor(ifelse(final_data3_rm4$Star_Rating_Current > 4,1,0))
# subset the need columns for modeling
colnames <- c('experience', 'spec_count', 'unemployment_rate', 'average_income', 'average_physician', 'tier_label', 'mnthly_prm', 'ann_ddctbl', 'copay_max', 'coin_max', 'sentiment')
final_data3_rm4 <- final_data3_rm4[, colnames]
str(final_data3_rm4)
# subset the train and test data sets
set.seed(510)
sample_size <- floor(0.8 * nrow(final_data3_rm4))
training_index <- sample(seq_len(nrow(final_data3_rm4)), size = sample_size)
train <- final_data3_rm4[training_index,]
test <- final_data3_rm4[-training_index,]
```
# Logistic Regression
```{r,cache=TRUE,warning=FALSE}
# train the model
logsitic_regression_model <- glm(formula = sentiment ~ ., family = binomial(link = 'logit'), data = train)
summary(logsitic_regression_model)
# evaluate the model
library(caret)
lr_pred <- predict(logsitic_regression_model, newdata = test, type = "response")
lr_pred <- ifelse(lr_pred >= 0.5, 1, 0)
# evaluation <- cbind(test, pred)
# evaluation$correct <- ifelse(evaluation$sentiment == evaluation$pred,1,0)
# sum(evaluation$correct) / nrow(evaluation)
confusionMatrix(data = lr_pred, test[, 'sentiment'])
```
# Neural Network
```{r,cache=TRUE,warning=FALSE}
library (nnet)
# train the model
neural_network_model <- nnet(formula = sentiment ~ ., data =train, decay = 0.5, size = 6)
summary(neural_network_model)
# evaluate the model
nn_pred <- predict(neural_network_model, newdata = test)
nn_pred <- ifelse(nn_pred >= 0.5, 1, 0)
# confusion matrix
confusionMatrix(data = nn_pred, test[, 'sentiment'])
```
```{r,cache=TRUE,warning=FALSE,include=FALSE}
# Decision Tree
library(C50)
# train the model
decision_tree_model <- C5.0.default(x = train[, -11], y = train$sentiment)
dt_pred <- predict(decision_tree_model, newdata = test[,colnames])
summary(decision_tree_model)
# evaluate the model
# confusion matrix
confusionMatrix(data = dt_pred, test[, 'sentiment'])
```