Nền tảng Machine Learning theo Tidy

Machine Learning trong tidyverse

Dmitriy (Dima) Gorenshteyn

Lead Data Scientist, Memorial Sloan Kettering Cancer Center

Cốt lõi của Machine Learning theo Tidy

Machine Learning trong tidyverse

Cốt lõi của Machine Learning theo Tidy

Machine Learning trong tidyverse

Quy trình với cột danh sách

Machine Learning trong tidyverse

Bộ dữ liệu Gapminder

  • Gói dslabs
  • Quan sát: 77 quốc gia, 52 năm mỗi quốc gia (1960–2011)
  • Thuộc tính:
    • year
    • infant_mortality
    • life_expectancy
    • fertility
    • population
    • gdpPercap
Machine Learning trong tidyverse

Quy trình với cột danh sách

Machine Learning trong tidyverse

Bước 1: Tạo cột danh sách - Lồng dữ liệu

Machine Learning trong tidyverse

Bước 1: Tạo cột danh sách - Lồng dữ liệu

Machine Learning trong tidyverse

Lồng theo quốc gia

library(tidyverse)
nested <- gapminder %>%
          group_by(country) %>%
          nest() 

Machine Learning trong tidyverse

Xem tibble đã lồng

Machine Learning trong tidyverse

Xem tibble đã lồng

> nested$data[[4]]
# A tibble: 52 x 6
    year infant_mortality life_expectancy fertility population gdpPercap
   <int>            <dbl>           <dbl>     <dbl>      <dbl>     <int>
 1  1960             37.3            68.8      2.70    7065525      7415
 2  1961             35.0            69.7      2.79    7105654      7781
 3  1962             32.9            69.5      2.80    7151077      7937
 4  1963             31.2            69.6      2.82    7199962      8209
 5  1964             29.7            70.1      2.80    7249855      8652
 6  1965             28.3            69.9      2.70    7298794      8893
Machine Learning trong tidyverse

Bước 3: Làm phẳng cột danh sách - unnest()

Machine Learning trong tidyverse

Bước 3: Làm phẳng cột danh sách - unnest()

nested %>% 
  unnest(data)

# A tibble: 4,004 x 7
   country  year infant_mortality life_expectancy fertility population   ...
   <fct>   <int>            <dbl>           <dbl>     <dbl>      <dbl>   ...
 1 Algeria  1960              148            47.5      7.65   11124892   ...
 2 Algeria  1961              148            48.0      7.65   11404859   ...
 3 Algeria  1962              148            48.6      7.65   11690152   ...
 4 Algeria  1963              148            49.1      7.65   11985130   ...
 5 Algeria  1964              149            49.6      7.65   12295973   ...
 6 Algeria  1965              149            50.1      7.66   12626953   ...
Machine Learning trong tidyverse

Bắt đầu nào!

Machine Learning trong tidyverse

Preparing Video For Download...