Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Tokyo.R#73 LT

koriakane
October 20, 2018
510

Tokyo.R#73 LT

10/20開催のTokyo.R #73のLT資料です。

koriakane

October 20, 2018
Tweet

Transcript

  1. 

  2.  • IL9;J GD • GD!,2K@ *0-=& #Q 3 $<8

    A# • 1.+,4?6FBE$N7 C 5 • '"C M >%$P $,2  P /0).(H:&%$ O 
  3.     • 56? ;>.402*C   

    • :!;>*B'D  =)(' '&;> % ? &$+ • ,4/0D+A@8 +$ 7" %#'<  E9"1-3 &D&$
  4.     • nbyimVY Zm_Y o Zm_W Y

    Zp zr eetW • imY ? E H Z • olVgb_v aou eetW • czmo cxrdhTPS PRU PSW • mw fbo. o s h_ b _v kW • ? FH LLL E :E L :? & 4 2 22 = & E • ? FH LLL E :E L :? & AF : : • ? FH LLL E :E L :? &= 7 / O = & E
  5. 1 1

  6.  • 7.%25 "-+)&'/5 0"# • 3*($4 5 56" !

       • 51 ,51  ! !% "%  
  7. •   library(tidyverse) SAWANO <- read_csv("RECOMMEND_sawano.csv") SAWANO %>% group_by(TITLE)

    %>% summarise(weight = sum(WEIGHT), count = n()) %>% arrange(desc(weight, count))
  8. /

  9.  • 1 ) ( rank <- SAWANO %>% group_by(TITLE)

    %>% summarise(weight = sum(WEIGHT), count = n()) %>% arrange(desc(weight, count)) ggplot(rank, aes(x = count)) + geom_histogram(bins = 19, alpha = 0.8) + theme_bw() + guides(fill = "none")
  10.   • mn t J • _dr lso g

    38::8E g f 54 g h • y f _ f n p m b b e chJ • g OR b KK y m a K • D - : 9 C 8B: :CA B E % % % 6 2 . 2 .1 . 2 / 2 2 . 2 . 2 % / 2 % / 2 2 . /D8E 7 2 . 2 2 /0 /0 2 /. . 1
  11.   •  # σʔλΛɺIDºۂ໊ͷmatrixʹ͢Δ SAWANO_mtx <- SAWANO %>%

    select(ID, TITLE, WEIGHT) %>% tidyr::spread(key = TITLE, value = WEIGHT, fill = NA, convert = FALSE, drop = TRUE) SAWANO_mtx <- as.matrix(SAWANO_mtx[,-1]) # ίαΠϯྨࣅ౓Λࢉग़͢Δؔ਺ͷ࡞੒ʢࢀߟαΠτͷؔ਺ͦͷ··ʣ get_dist <- function (v1, v2){ #NAൺ཰Λߟྀͨ͠scaleXΛ࡞Δ na.idx <- is.na(v1) | is.na(v2) v1a <- v1[!na.idx] v2a <- v2[!na.idx] scaleX <- length(v1) / length(v1a) return(v1a %*% v2a / (sqrt(sum(v1a^2))*sqrt(sum(v2a^2)))/scaleX) }
  12. ( ) •  # ίαΠϯྨࣅ౓ͷࢉग़ɻࣗ෼ͷϨίʔυ͸আ֎͢Δɻ cosSongOF <- apply(sawano_mtx[-81,], MARGIN

    = 2, FUN= function(x) get_dist(x,sawano_mtx[-81,"Song of.."])) # ݟ΍͍͢Α͏ʹdata.frameʹ͢Δ cosSongOF <- data.frame(title = as.character(colnames(sawano_mtx)), x = cosSongOF) # ͓͢͢Ίۂ10ۂදࣔ cosSongOF %>% arrange(desc(x)) %>% filter(!is.nan(x)) %>% head(n = 10)
  13.  nY T nY e m k nY nY )

    nY m i l nY A Zlah nY CG ( , nY A Zlah nY m i l nY )
  14.  • 3") !13")  2' • 3%+.+  #(

    -$ • *,3  04&$ 3/2' 
  15. !