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爲特徵值的namespa

按照p=0.7劃分,訓練集佔70%,測試集佔30%,對劃分的結果進行描述describe可知code

訓練集 均值21.45  測試集均值21.75 blog

可是有一點疑問,測試集最小5個數值均小於測試集最小值???,如何更均勻??it

相關文章
相關標籤/搜索