stratified splitting the data

前端 未结 4 1113
礼貌的吻别
礼貌的吻别 2020-12-15 08:12

I have a large data set and like to fit different logistic regression for each City, one of the column in my data. The following 70/30 split works without considering City g

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-15 08:27

    Your code works just fine as is, if City is a column, simply run training data as train[,2]. You can do this easily for each one with a lambda function

    logReg<-function(ind) {
        reg<-glm(train[,ind]~WHATEVER)
        ....
        return(val) }
    

    Then run sapply over the vector of city indexes.

提交回复
热议问题