- Advanced Machine Learning with R
- Cory Lesmeister Dr. Sunil Kumar Chinnamgari
- 318字
- 2021-06-24 14:24:33
Descriptive statistics
Traditionally, we could use the base R summary() function to identify some basic statistics. Now, and recently I might add, I like to use the package sjmisc and its descr() function. It produces a more readable output, and you can assign that output to a dataframe. What works well is to create that dataframe, save it as a .csv, and explore it at your leisure. It automatically selects numeric features only. It also fits well with tidyverse so that you can incorporate dplyr functions such as group_by() and filter(). Here's an example in our case where we examine the descriptive stats for the infantry of the Confederate Army. The output will consist of the following:
- var: feature name
- type: integer
- n: number of observations
- NA.prc: percent of missing values
- mean
- sd: standard deviation
- se: standard error
- md: median
- trimmed: trimmed mean
- range
- skew
gettysburg %>%
dplyr::filter(army == "Confederate" & type == "Infantry") %>%
sjmisc::descr() -> descr_stats
readr::write_csv(descr_stats, 'descr_stats.csv')
The following is abbreviated output from the preceding code saved to a spreadsheet:

In this one table, we can discern some rather interesting tidbits. In particular is the percent of missing values per feature. If you modify the precious code to examine the Union Army, you'll find that there're no missing values. The reason the usurpers from the South had missing values is based on a couple of factors; either shoddy staff work in compiling the numbers on July 3rd or the records were lost over the years. Note that, for the number of men captured, if you remove the missing value, all other values are zero, so we could just replace the missing value with it. The Rebels did not report troops as captured, but rather as missing, in contrast with the Union.
Once you feel comfortable with the descriptive statistics, move on to exploring the categorical features in the next section.
- Arduino入門基礎(chǔ)教程
- FPGA從入門到精通(實戰(zhàn)篇)
- Learning AngularJS Animations
- The Applied AI and Natural Language Processing Workshop
- INSTANT ForgedUI Starter
- Artificial Intelligence Business:How you can profit from AI
- 計算機維修與維護技術(shù)速成
- 筆記本電腦使用、維護與故障排除從入門到精通(第5版)
- Machine Learning with Go Quick Start Guide
- 計算機組裝維修與外設(shè)配置(高等職業(yè)院校教改示范教材·計算機系列)
- Java Deep Learning Cookbook
- 圖解計算機組裝與維護
- Angular 6 by Example
- Learning Less.js
- 分布式存儲系統(tǒng):核心技術(shù)、系統(tǒng)實現(xiàn)與Go項目實戰(zhàn)