- Hands-On Ensemble Learning with R
- Prabhanjan Narayanachar Tattar
- 459字
- 2021-07-23 19:10:51
US Crime
A study of the crime rate per million of the population among the 47 different states of the US is undertaken here, and an attempt is made to find its dependency on 13 variables. These include age distribution, indicator of southern states, average number of schooling years, and so on. As with the earlier datasets, we will also partition this one into the following chunks of R program:
> library(ACSWR) Warning message: package 'ACSWR' was built under R version 3.4.1 > data(usc) > str(usc) 'data.frame': 47 obs. of 14 variables: $ R : num 79.1 163.5 57.8 196.9 123.4 ... $ Age: int 151 143 142 136 141 121 127 131 157 140 ... $ S : int 1 0 1 0 0 0 1 1 1 0 ... $ Ed : int 91 113 89 121 121 110 111 109 90 118 ... $ Ex0: int 58 103 45 149 109 118 82 115 65 71 ... $ Ex1: int 56 95 44 141 101 115 79 109 62 68 ... $ LF : int 510 583 533 577 591 547 519 542 553 632 ... $ M : int 950 1012 969 994 985 964 982 969 955 1029 ... $ N : int 33 13 18 157 18 25 4 50 39 7 ... $ NW : int 301 102 219 80 30 44 139 179 286 15 ... $ U1 : int 108 96 94 102 91 84 97 79 81 100 ... $ U2 : int 41 36 33 39 20 29 38 35 28 24 ... $ W : int 394 557 318 673 578 689 620 472 421 526 ... $ X : int 261 194 250 167 174 126 168 206 239 174 ... > set.seed(12345) > Train_Test <- sample(c("Train","Test"),nrow(usc),replace = TRUE,prob=c(0.7,0.3)) > head(Train_Test) [1] "Test" "Test" "Test" "Test" "Train" "Train" > usc_Train <- usc[Train_Test=="Train",] > usc_TestX <- within(usc[Train_Test=="Test",],rm(R)) > usc_TestY <- usc[Train_Test=="Test","R"] > usc_Formula <- as.formula("R~.")
In each example discussed in this section thus far, we had a reason to believe that the observations are independent of each other. This assumption simply means that the regressands and regressors of one observation have no relationship with other observations' regressands and regressors. This is a simple and reasonable assumption. We have another class of observations/datasets where such assumptions are not practical. For example, the maximum temperature of a day is not completely independent of the previous day's temperature. If that were to be the case, we could have a scorchingly hot day, followed by winter, followed by another hot day, which in turn is followed by a very heavy rainy day. However, weather does not happen in this way as on successive days, the weather is dependent on previous days. In the next example, we consider the number of overseas visitors to New Zealand.
- 人工免疫算法改進及其應用
- 西門子PLC與InTouch綜合應用
- 小型電動機實用設計手冊
- 樂高創(chuàng)意機器人教程(中級 下冊 10~16歲) (青少年iCAN+創(chuàng)新創(chuàng)意實踐指導叢書)
- 工業(yè)機器人入門實用教程(KUKA機器人)
- 視覺檢測技術及智能計算
- 西門子S7-200 SMART PLC實例指導學與用
- Ruby on Rails敏捷開發(fā)最佳實踐
- Mastering Text Mining with R
- 計算機組裝與維修實訓
- 人工智能云平臺:原理、設計與應用
- Access 2007數據庫入門與實例應用金典
- 電機與電力拖動
- Learn T-SQL Querying
- Building Impressive Presentations with Impress.js