且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

R中逻辑回归建模中的子集

更新时间:2022-03-03 09:24:41

您正在拆分列.如果您阅读帮助页面:

You are splitting on the columns. If you read the help page:

用法:

  sample.split( Y, SplitRatio = 2/3, group = NULL )
  Arguments:

   Y: Vector of data labels. If there are only a few labels (as is
      expected) than relative ratio of data in both subsets will be
      the same.

您正在提供整个数据框,它作为一个列表读取.因此,如果您有一个因变量,例如 y ,它将是:

You are providing the whole data frame, which it reads as a list.So if you have a dependent variable, for example y , it would be:

split <-sample.split(df1$y, SplitRatio = 0.5)
training <- df1[split,]
testing <- df1[!split,]

split <-sample.split(1:nrow(df1), SplitRatio = 0.5)
training <- df1[split,]
testing <- df1[!split,]