inTrainingSample(nlcv)
inTrainingSample()所属R语言包:nlcv
Function to define a learning sample based on balanced sampling
基于平衡取样函数来定义一个学习样本
译者:生物统计家园网 机器人LoveR
描述----------Description----------
This function takes in a factor with class labels of the total dataset, draws a sample (balanced with respect to the different levels of the factor) and returns a logical vector indicating whether the observation is in the learning sample (TRUE) or not (FALSE).
此功能需要在总集类标签的一个因素,绘制一个样本(平衡方面因素的不同水平),并返回一个逻辑的向量,观察是否是在学习样本(TRUE)或不(FALSE)。
用法----------Usage----------
inTrainingSample(y, propTraining = 2/3, classdist = c("balanced", "unbalanced"))
参数----------Arguments----------
参数:y
factor with the class labels for the total data set
因子为总数据集类的标签
参数:propTraining
proportion of the data that should be in a training set; the default value is 2/3.
的数据,应该在训练集,默认值是2/3的比例。
参数:classdist
distribution of classes; allows to indicate whether your distribution 'balanced' or 'unbalanced'. The sampling strategy for each run is adapted accordingly.
类分布;允许表明,无论是你的发行的“平衡”或“不平衡”。为每个运行的取样策略相应调整。
值----------Value----------
logical vector indicating for each observation in y whether the observation is in the learning sample (TRUE) or not (FALSE)
逻辑向量表示每个观察在y观察是否是在学习样本(TRUE)或不(FALSE)
作者(S)----------Author(s)----------
Willem Talloen and Tobias Verbeke
举例----------Examples----------
### this example demonstrates the logic of sampling in case of unbalanced distribution of classes[#这个例子演示了类分布不平衡的情况下,抽样逻辑]
y <- factor(c(rep("A", 21), rep("B", 80)))
nlcv:::inTrainingSample(y, 2/3, "unbalanced")
table(y[nlcv:::inTrainingSample(y, 2/3, "unbalanced")]) # should be 14, 14 (for A, B resp.)[应该是14,14(甲,乙RESP。)]
table(y[!nlcv:::inTrainingSample(y, 2/3, "unbalanced")]) # should be 7, 66 (for A, B resp.) [应该是7,66(甲,乙RESP。)]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|