Prepare the data
数据来自UCIhttp://archive.ics.uci.edu/ml/machine-learning-databases/credit-screening,一个信a用卡的数据,具体各项变量名以及变量名代表的含义不明(应该是出于保护隐私的目的),本文会用logit,GBM,knn,xgboost来对数据进行分类预测,对比准确率
预计的准确率应该是:
xgboost > GBM > logit > knn
Download the data
dataset = read.table("http://archive.ics.uci.edu/ml/machine-learning-databases/credit-screening/crx.data", sep = ",", essay-header = F, na.strings = "?")
head(dataset)
Train and Test
分割数据的训练集和测试集,这里set.seed(123),设定70%的训练集,30%的测试集.
Change the variable into dummy variables
有时候,需要转化变量为哑变量,因为在一些挖掘场合,数据不能直接使用因子型的数据:
-
knn
-
glmnet
-
svm
-
xgboost
有些挖掘方法是可以使用因子变量的,比如:
-
logistic regression
-
raprt
-
GBM
-
randomforest
-