Problem 1

trndata <- read.csv("C:/Users/51634/Desktop/清华课程/高级应用数理统计/hw4/hw02-trn-data.csv")
tstdata <- read.csv("C:/Users/51634/Desktop/清华课程/高级应用数理统计/hw4/hw02-tst-data.csv")

##Use ROC curve

library(pROC)
## Type 'citation("pROC")' for a citation.
## 
## 载入程序包:'pROC'
## The following objects are masked from 'package:stats':
## 
##     cov, smooth, var
##Set train data
trn1<-sub("dodgerblue",1,trndata$y)
trndata$y<-trn1
trn0<-sub("darkorange",0,trn1)
trndata$y<-trn0 ##Transfer text to number
trndata$y<-as.numeric(trndata$y)
##Set test data
tst1<-sub("dodgerblue",1,tstdata$y)
tstdata$y<-tst1
tst0<-sub("darkorange",0,tst1)
tstdata$y<-tst0
tstdata$y<- as.numeric(tstdata$y)