################################################################# # THIS FILE CONTAINS THE CODE NECESSARY TO OBTAIN THE RESULTS # # OF EXPERIMENTS USED IN THE PAPER: # # Torgo,L and Lopes,E.: Utility-based Fraud Detection. In # # Proceedings of the 22nd IJCAI'2011 # ################################################################# # Author : Luis Torgo (ltorgo@dcc.fc.up.pt) Date: Mar 2011 # # License: GPL (>= 2) # ################################################################# library(DMwR) # Load in the code for the UOR algorithm source('UOR.R') source('auxFunc.R') # ===================================================== # Function to omitting the cost, benefit and utility # ===================================================== omitFunc <- function(dat,percOmit=0.5) { omitCases <- sample(1:nrow(dat), as.integer(nrow(dat)*percOmit)) dat[omitCases,3:5]<-NA dat } # ===================================================== # Main code # ===================================================== load('artifData.Rdata') percSup <- 0.8 # percentage of cases that are history (i.e. we know C,B,U) set.seed(1234) supCases <- sample(1:nrow(data),as.integer(nrow(data)*percSup)) descrVars <- 1:2 percOmit <- 0.0 # percentage of cases that are NA (C,B,U) # Historical data set histData <- as.data.frame(na.omit(omitFunc(data[supCases,],percOmit))) # The set of candidate cases for inspection inspData <- as.data.frame(data[-supCases,descrVars]) # ===================================================== # Experiments with Regression Trees(rpartXse) + ORh + linear utility rm <- learner('rpartXse',pars=list(se=0.5)) om <- learner('orhCall',pars=list()) urank <- UOR(histData,inspData,regrLearner=rm,outLearner=om) # or the line below save(urank, file='artDS_model_rpart_ORh.Rdata') # ===================================================== # Experiments with NNet + LOF + linear utility require(nnet) rm <- learner('nnet',pars=list(linout=T,trace=F,size=10,maxit=1000)) om <- learner('lofCall',pars=list(k=30)) urank <- UOR(histData,inspData,regrLearner=rm,outLearner=om) # or the line below save(urank,file='artDS_model_nnet_LOF.Rdata')