zoukankan      html  css  js  c++  java
  • R语言-数据处理-样本集划分

    library(caret)

     1 > sIndex<-createDataPartition(outp$V1,p=0.7,list=FALSE)
     2 > outpTrain<-outp[sIndex]
     3 > outpTest<-outp[-sIndex]
     4 > describe(outpTrain)
     5 outpTrain 
     6        n  missing distinct     Info     Mean      Gmd      .05      .10 
     7      139        0      125        1    21.45    3.894    16.11    17.41 
     8      .25      .50      .75      .90      .95 
     9    19.19    21.66    23.54    25.62    27.20 
    10 
    11 lowest : 12.04 12.62 13.03 14.45 14.61, highest: 27.70 27.95 28.16 29.45 31.30
    12 > describe(outpTest)
    13 outpTest 
    14        n  missing distinct     Info     Mean      Gmd      .05      .10 
    15       56        0       55        1    21.75    3.586    16.99    17.48 
    16      .25      .50      .75      .90      .95 
    17    19.39    21.66    23.50    24.91    27.08 
    18 
    19 lowest : 15.75 16.03 16.78 17.06 17.41, highest: 26.15 26.97 27.41 28.58 32.30

    PS:根据因变量特征值进行数据分区,outp$V1 其中outp为因变量列表,V1为特征值的name

    按照p=0.7划分,训练集占70%,测试集占30%,对划分的结果进行描述describe可知

    训练集 均值21.45  测试集均值21.75

    但是有一点疑问,测试集最小5个数值均小于测试集最小值???,如何更均匀??

  • 相关阅读:
    bzoj 1858 线段树
    bzoj 1877 最小费用流
    bzoj 1833 数位dp
    Codeforces Round #285 (Div. 1) B
    HDU2028 Lowest Common Multiple Plus
    HDU5706 GirlCat
    HDU2022 海选女主角
    687E: TOF
    687D: Dividing Kingdom II
    687D: Dividing Kingdom II
  • 原文地址:https://www.cnblogs.com/qianheng/p/10804421.html
Copyright © 2011-2022 走看看