| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794 |
- <!DOCTYPE html>
- <html>
- <head>
- <title>Deep Learning in R</title>
- <meta charset="utf-8">
- <meta name="author" content="metya" />
- <meta name="date" content="2018-12-19" />
- <script src="libs/htmlwidgets/htmlwidgets.js"></script>
- <script src="libs/viz/viz.js"></script>
- <link href="libs/DiagrammeR-styles/styles.css" rel="stylesheet" />
- <script src="libs/grViz-binding/grViz.js"></script>
- <link href="libs/pagedtable/css/pagedtable.css" rel="stylesheet" />
- <script src="libs/pagedtable/js/pagedtable.js"></script>
- <link rel="stylesheet" href="xaringan-themer.css" type="text/css" />
- </head>
- <body>
- <textarea id="source">
- class: center, middle, inverse, title-slide
- # Deep Learning in R
- ## ░<br/>Обзор фреймворков с примерами
- ### metya
- ### 2018-12-19
- ---
- class: center, middle
- background-color: #8d6e63
- #Disclaimer
- Цель доклада не дать понимание, что такое глубокое обучение и детально разобрать как работать с ним и обучать современные модели, а скорее показать, как просто можно начать тем, кто давно хотел и чесались руки, но все было никак не взяться
- ---
- # Deep Learning
- ## Что это?
- --
- * Когда у нас есть исскуственная нейронная сеть
- --
- * Когда скрытых слоев в этой сети больше чем два
- --
- 
- .footnotes[[1] https://machinelearningmastery.com/what-is-deep-learning/]
- ---
- ## Как это математически
- 
- ???
- На самом деле это конечно самый простой юнит, самый базовый.
- ---
- background-image: url(https://3qeqpr26caki16dnhd19sv6by6v-wpengine.netdna-ssl.com/wp-content/uploads/2016/08/Why-Deep-Learning-1024x742.png)
- ???
- Image credit: [Andrew Ng](http://www.slideshare.net/ExtractConf)
- ---
- class: inverse, center, middle, title-slide
- # Frameworks
- ---
- 
- .footnotes[
- [1] https://towardsdatascience.com/deep-learning-framework-power-scores-2018-23607ddf297a
- ]
- ---
- ## Нас интересуют только те, что есть в R через API
- --
- * ###TensorFlow
- --
- * ###theano
- --
- * ###Keras
- --
- * ###CNTK
- --
- * ###MXNet
- --
- * ###ONNX
- ---
- ## Есть еше несколько пакетов
- * darch (removed from cran)
- * deepnet
- * deepr
- * H2O (interface) ([Tutorial](https://htmlpreview.github.io/?https://github.com/ledell/sldm4-h2o/blob/master/sldm4-deeplearning-h2o.html))
- ???
- Вода это по большей части МЛ фреймворк, с недавних пор, где появился модуль про глубокое обучение. Есть неплохой туториал для р пакета. Умеет в поиск гиперпараметров, кроссвалидацию и прочие нужные для МЛ штуки для сеток, очевидно это работает только для маленьких сетей)
- Но они р специфичны, кроме воды, и соотвественно медленные, да и умеют довольно мало. Новые годные архитектуры сетей туда не имплементированы.
- ---
- 
- https://www.tensorflow.org/
- https://tensorflow.rstudio.com/
- - Делает Google
- - Самый популярный, имеет тучу туториалов и книг
- - Имеет самый большой спрос у продакшн систем
- - Имеет API во множество языков
- - Имеет статический граф вычислений, что бывает неудобно, зато оптимизированно
- - Примерно с лета имеет фичу **eager execution**, которая почти нивелирует это неудобство. Но почти не считается
- - Доступен в R как самостоятельно, так и как бэкэнд Keras
- ---
- 
- http://www.deeplearning.net/software/theano/
- - Делался силами университета Монреаль с 2007
- - Один из самый старых фреймворков, но почти почил в забытьи
- - Придумали идею абстракции вычислительных графов (статических) для оптимизации и вычисления нейронных сетей
- - В R доступен как бэкенд через Keras
- ---
- 
- https://cntk.ai/
- - Делается силами Майкрософт
- - Имеет половинчатые динамические вычислительные графы (на самом деле динамические тензоры скорее)
- - Доступен как бэкенд Keras так и как самостоятельный бэкенд с биндингами в R через reticulate package, что значит нужно иметь python версию фреймворка
- ---
- 
- https://keras.io/
- https://keras.rstudio.com/
- https://tensorflow.rstudio.com/keras/
- - Высокоуровневый фреймворк над другими такими бэкэндами как Theano, CNTK, Tensorflow, и еще некоторые на подходе
- - Делается Франсуа Шолле, который написал книгу Deep Learning in R
- - Очень простой код
- - Один и тот же код работает на разных бэкендах, что теоретически может быть полезно (нет)
- - Есть очень много блоков нейросетей из современных State-of-the-Art работ
- - Нивелирует боль статических вычислительных графов (не совсем)
- - Уже давно дефолтом поставляется вместе с TensorFlow как его часть, но можно использовать и отдельно
- ---
- <img src="https://raw.githubusercontent.com/dmlc/dmlc.github.io/master/img/logo-m/mxnetR.png" style=width:30% />
- https://mxnet.apache.org/
- https://github.com/apache/incubator-mxnet/tree/master/R-package
- - Является проектом Apache
- - Сочетает в себе динамические и статические графы
- - Тоже имеет зоопарк предобученных моделей
- - Как и TensorFlow поддерживается многими языками, что может быть очень полезно
- - Довольно разумный и хороший фреймворк, непонятно, почему не пользуется популярностью
- ---
- 
- https://onnx.ai/
- https://onnx.ai/onnx-r/
- - Предоставляет открытый формат представления вычислительных графов, чтобы можно было обмениваться запускать одни и теже, экспортированные в этот формат, модели с помощью разных фреймворков и своего рантайма
- - Можно работать из R
- - Изначально делался Microsoft вместе с Facebook
- - Поддерживает кучу фреймворков нативно и конвертацию в ML и TF, Keras
- ---
- class: inverse, middle, center
- # Deep Learning with MXNet
- ---
- ## Установка
- В Windows и MacOS в R
- ```r
- # Windows and MacOs
- cran <- getOption("repos")
- cran["dmlc"] <- "https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/R/CRAN/GPU/cu92"
- options(repos = cran)
- install.packages("mxnet")
- ```
- Linux bash
- ```bash
- # On linux
- git clone --recursive https://github.com/apache/incubator-mxnet.git mxnet
- cd mxnet/docs/install
- ./install_mxnet_ubuntu_python.sh
- ./install_mxnet_ubuntu_r.sh
- cd incubator-mxnet
- make rpkg
- ```
- ---
- ## Загрузка и обработка данных
- ```r
- df <- readRDS('data.rds')
- set.seed(100) #set seed to reproduce results
- ```
- ```r
- #transform and split train on x and y
- train_ind <- sample(1:77, 60) # random split data
- x_train <- as.matrix(df[train_ind, 2:8]) # train data
- y_train <- unlist(df[train_ind, 9]) # train labels
- x_val <- as.matrix(df[-train_ind, 2:8]) # test validation data
- y_val <- unlist(df[-train_ind, 9]) # validation labels
- ```
- ---
- ## Задания архитектуры сети
- ```r
- require(mxnet)
- # define graph
- data <- mx.symbol.Variable("data") # define variable node
- fc1 <- mx.symbol.FullyConnected(data, num_hidden = 1) # define one layer perceptron
- linreg <- mx.symbol.LinearRegressionOutput(fc1) # output node
- # define learing parameters
- initializer <- mx.init.normal(sd = 0.1)
- optimizer <- mx.opt.create("sgd",
- learning.rate = 1e-6,
- momentum = 0.9)
- # define logger for logging train proccess
- logger <- mx.metric.logger()
- epoch.end.callback <- mx.callback.log.train.metric(
- period = 4, # number of batches when metrics call
- logger = logger)
- # num of epoch
- n_epoch <- 20
- ```
- ---
- ## Построим граф модели
- ```r
- # plot our model
- graph.viz(linreg)
- ```
- <div id="htmlwidget-33d7656478955a07fef5" style="width:504px;height:288px;" class="grViz html-widget"></div>
- <script type="application/json" data-for="htmlwidget-33d7656478955a07fef5">{"x":{"diagram":"digraph {\n\ngraph [layout = \"dot\",\n rankdir = \"TD\"]\n\n\n\n \"1\" [label = \"data\ndata\", shape = \"oval\", penwidth = \"2\", color = \"#8dd3c7\", style = \"filled\", fontcolor = \"black\", fillcolor = \"#8DD3C7FF\"] \n \"2\" [label = \"FullyConnected\nfullyconnected9\n1\", shape = \"box\", penwidth = \"2\", color = \"#fb8072\", style = \"filled\", fontcolor = \"black\", fillcolor = \"#FB8072FF\"] \n \"3\" [label = \"LinearRegressionOutput\nlinearregressionoutput9\", shape = \"box\", penwidth = \"2\", color = \"#b3de69\", style = \"filled\", fontcolor = \"black\", fillcolor = \"#B3DE69FF\"] \n\"1\"->\"2\" [color = \"black\", fontcolor = \"black\"] \n\"2\"->\"3\" [color = \"black\", fontcolor = \"black\"] \n}","config":{"engine":"dot","options":null}},"evals":[],"jsHooks":[]}</script>
- ---
- ## Обучим
- ```r
- model <- mx.model.FeedForward.create(
- symbol = linreg, # our model
- X = x_train, # our data
- y = y_train, # our label
- ctx = mx.cpu(), # engine
- num.round = n_epoch, # number of epoch
- initializer = initializer, # inizialize weigths
- optimizer = optimizer, # sgd optimizer
- eval.data = list(data = x_val, label = y_val), # evaluation on evey epoch
- eval.metric = mx.metric.rmse, # metric
- array.batch.size = 15,
- epoch.end.callback = epoch.end.callback) # logger
- ```
- 
- ---
- ## Построим кривую обучения
- ```r
- rmse_log <- data.frame(RMSE = c(logger$train, logger$eval), dataset = c(rep("train", length(logger$train)), rep("val", length(logger$eval))),epoch = 1:n_epoch)
- library(ggplot2)
- ggplot(rmse_log, aes(epoch, RMSE, group = dataset, colour = dataset)) + geom_point() + geom_line()
- ```
- <!-- -->
- ---
- class: inverse, center, middle
- # Deep Learning with Keras
- ---
- ## Установка
- ```r
- install.packages("keras")
- keras::install_keras(tensorflow = 'gpu')
- ```
- ### Загрузка нужных нам пакетов
- ```r
- require(keras) # Neural Networks
- require(tidyverse) # Data cleaning / Visualization
- require(knitr) # Table printing
- require(rmarkdown) # Misc. output utilities
- require(ggridges) # Visualization
- ```
- ---
- ## Загрузка данных
- ```r
- activityLabels <- read.table("Deep_Learning_in_R_files/HAPT Data Set/activity_labels.txt",
- col.names = c("number", "label"))
- activityLabels %>% kable(align = c("c", "l"))
- ```
- number label
- -------- -------------------
- 1 WALKING
- 2 WALKING_UPSTAIRS
- 3 WALKING_DOWNSTAIRS
- 4 SITTING
- 5 STANDING
- 6 LAYING
- 7 STAND_TO_SIT
- 8 SIT_TO_STAND
- 9 SIT_TO_LIE
- 10 LIE_TO_SIT
- 11 STAND_TO_LIE
- 12 LIE_TO_STAND
- ---
- ```r
- labels <- read.table("Deep_Learning_in_R_files/HAPT Data Set/RawData/labels.txt",
- col.names = c("experiment", "userId", "activity", "startPos", "endPos"))
- dataFiles <- list.files("Deep_Learning_in_R_files/HAPT Data Set/RawData")
- labels %>%
- head(50) %>%
- paged_table()
- ```
- <div data-pagedtable="false">
- <script data-pagedtable-source type="application/json">
- {"columns":[{"label":[""],"name":["_rn_"],"type":[""],"align":["left"]},{"label":["experiment"],"name":[1],"type":["int"],"align":["right"]},{"label":["userId"],"name":[2],"type":["int"],"align":["right"]},{"label":["activity"],"name":[3],"type":["int"],"align":["right"]},{"label":["startPos"],"name":[4],"type":["int"],"align":["right"]},{"label":["endPos"],"name":[5],"type":["int"],"align":["right"]}],"data":[{"1":"1","2":"1","3":"5","4":"250","5":"1232","_rn_":"1"},{"1":"1","2":"1","3":"7","4":"1233","5":"1392","_rn_":"2"},{"1":"1","2":"1","3":"4","4":"1393","5":"2194","_rn_":"3"},{"1":"1","2":"1","3":"8","4":"2195","5":"2359","_rn_":"4"},{"1":"1","2":"1","3":"5","4":"2360","5":"3374","_rn_":"5"},{"1":"1","2":"1","3":"11","4":"3375","5":"3662","_rn_":"6"},{"1":"1","2":"1","3":"6","4":"3663","5":"4538","_rn_":"7"},{"1":"1","2":"1","3":"10","4":"4539","5":"4735","_rn_":"8"},{"1":"1","2":"1","3":"4","4":"4736","5":"5667","_rn_":"9"},{"1":"1","2":"1","3":"9","4":"5668","5":"5859","_rn_":"10"},{"1":"1","2":"1","3":"6","4":"5860","5":"6786","_rn_":"11"},{"1":"1","2":"1","3":"12","4":"6787","5":"6977","_rn_":"12"},{"1":"1","2":"1","3":"1","4":"7496","5":"8078","_rn_":"13"},{"1":"1","2":"1","3":"1","4":"8356","5":"9250","_rn_":"14"},{"1":"1","2":"1","3":"1","4":"9657","5":"10567","_rn_":"15"},{"1":"1","2":"1","3":"1","4":"10750","5":"11714","_rn_":"16"},{"1":"1","2":"1","3":"3","4":"13191","5":"13846","_rn_":"17"},{"1":"1","2":"1","3":"2","4":"14069","5":"14699","_rn_":"18"},{"1":"1","2":"1","3":"3","4":"14869","5":"15492","_rn_":"19"},{"1":"1","2":"1","3":"2","4":"15712","5":"16377","_rn_":"20"},{"1":"1","2":"1","3":"3","4":"16530","5":"17153","_rn_":"21"},{"1":"1","2":"1","3":"2","4":"17298","5":"17970","_rn_":"22"},{"1":"2","2":"1","3":"5","4":"251","5":"1226","_rn_":"23"},{"1":"2","2":"1","3":"7","4":"1227","5":"1432","_rn_":"24"},{"1":"2","2":"1","3":"4","4":"1433","5":"2221","_rn_":"25"},{"1":"2","2":"1","3":"8","4":"2222","5":"2377","_rn_":"26"},{"1":"2","2":"1","3":"5","4":"2378","5":"3304","_rn_":"27"},{"1":"2","2":"1","3":"11","4":"3305","5":"3572","_rn_":"28"},{"1":"2","2":"1","3":"6","4":"3573","5":"4435","_rn_":"29"},{"1":"2","2":"1","3":"10","4":"4436","5":"4619","_rn_":"30"},{"1":"2","2":"1","3":"4","4":"4620","5":"5452","_rn_":"31"},{"1":"2","2":"1","3":"9","4":"5453","5":"5689","_rn_":"32"},{"1":"2","2":"1","3":"6","4":"5690","5":"6467","_rn_":"33"},{"1":"2","2":"1","3":"12","4":"6468","5":"6709","_rn_":"34"},{"1":"2","2":"1","3":"1","4":"7624","5":"8252","_rn_":"35"},{"1":"2","2":"1","3":"1","4":"8618","5":"9576","_rn_":"36"},{"1":"2","2":"1","3":"1","4":"9991","5":"10927","_rn_":"37"},{"1":"2","2":"1","3":"1","4":"11311","5":"12282","_rn_":"38"},{"1":"2","2":"1","3":"3","4":"13129","5":"13379","_rn_":"39"},{"1":"2","2":"1","3":"3","4":"13495","5":"13927","_rn_":"40"},{"1":"2","2":"1","3":"2","4":"14128","5":"14783","_rn_":"41"},{"1":"2","2":"1","3":"3","4":"15037","5":"15684","_rn_":"42"},{"1":"2","2":"1","3":"2","4":"15920","5":"16598","_rn_":"43"},{"1":"2","2":"1","3":"3","4":"16847","5":"17471","_rn_":"44"},{"1":"2","2":"1","3":"2","4":"17725","5":"18425","_rn_":"45"},{"1":"3","2":"2","3":"5","4":"298","5":"1398","_rn_":"46"},{"1":"3","2":"2","3":"7","4":"1399","5":"1555","_rn_":"47"},{"1":"3","2":"2","3":"4","4":"1686","5":"2627","_rn_":"48"},{"1":"3","2":"2","3":"8","4":"2628","5":"2769","_rn_":"49"},{"1":"3","2":"2","3":"5","4":"2770","5":"3904","_rn_":"50"}],"options":{"columns":{"min":{},"max":[10]},"rows":{"min":[10],"max":[10]},"pages":{}}}
- </script>
- </div>
- ---
- ## TLDR
- #### Потому что очень много препроцессинга и всего такого, мы просто загрузим уже готовый результат
- ```r
- allObservations <- read_rds("allObservations.rds")
- allObservations %>% dim()
- ```
- ```
- ## [1] 1214 5
- ```
- ---
- ## Посмотрим на данные
- ```r
- allObservations %>%
- mutate(recording_length = map_int(data,nrow)) %>%
- ggplot(aes(x = recording_length, y = activityName)) +
- geom_density_ridges(alpha = 0.8)
- ```
- <!-- -->
- ---
- ## Отфильтруем
- ```r
- desiredActivities <- c("STAND_TO_SIT", "SIT_TO_STAND", "SIT_TO_LIE", "LIE_TO_SIT", "STAND_TO_LIE","LIE_TO_STAND")
- filteredObservations <- allObservations %>%
- filter(activityName %in% desiredActivities) %>%
- mutate(observationId = 1:n())
- filteredObservations %>% paged_table()
- ```
- <div data-pagedtable="false">
- <script data-pagedtable-source type="application/json">
- {"columns":[{"label":["experiment"],"name":[1],"type":["int"],"align":["right"]},{"label":["userId"],"name":[2],"type":["int"],"align":["right"]},{"label":["activity"],"name":[3],"type":["int"],"align":["right"]},{"label":["data"],"name":[4],"type":["list"],"align":["right"]},{"label":["activityName"],"name":[5],"type":["fctr"],"align":["left"]},{"label":["observationId"],"name":[6],"type":["int"],"align":["right"]}],"data":[{"1":"1","2":"1","3":"7","4":"<data.frame [160 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"1"},{"1":"2","2":"1","3":"7","4":"<data.frame [206 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"2"},{"1":"3","2":"2","3":"7","4":"<data.frame [157 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"3"},{"1":"4","2":"2","3":"7","4":"<data.frame [160 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"4"},{"1":"5","2":"3","3":"7","4":"<data.frame [142 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"5"},{"1":"6","2":"3","3":"7","4":"<data.frame [190 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"6"},{"1":"7","2":"4","3":"7","4":"<data.frame [236 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"7"},{"1":"8","2":"4","3":"7","4":"<data.frame [178 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"8"},{"1":"9","2":"5","3":"7","4":"<data.frame [165 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"9"},{"1":"10","2":"5","3":"7","4":"<data.frame [235 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"10"},{"1":"11","2":"6","3":"7","4":"<data.frame [185 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"11"},{"1":"12","2":"6","3":"7","4":"<data.frame [151 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"12"},{"1":"13","2":"7","3":"7","4":"<data.frame [114 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"13"},{"1":"14","2":"7","3":"7","4":"<data.frame [90 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"14"},{"1":"15","2":"8","3":"7","4":"<data.frame [111 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"15"},{"1":"16","2":"8","3":"7","4":"<data.frame [129 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"16"},{"1":"17","2":"9","3":"7","4":"<data.frame [118 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"17"},{"1":"18","2":"9","3":"7","4":"<data.frame [132 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"18"},{"1":"19","2":"10","3":"7","4":"<data.frame [133 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"19"},{"1":"20","2":"10","3":"7","4":"<data.frame [112 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"20"},{"1":"22","2":"11","3":"7","4":"<data.frame [141 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"21"},{"1":"23","2":"11","3":"7","4":"<data.frame [172 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"22"},{"1":"24","2":"12","3":"7","4":"<data.frame [175 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"23"},{"1":"25","2":"12","3":"7","4":"<data.frame [190 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"24"},{"1":"26","2":"13","3":"7","4":"<data.frame [138 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"25"},{"1":"27","2":"13","3":"7","4":"<data.frame [250 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"26"},{"1":"28","2":"14","3":"7","4":"<data.frame [298 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"27"},{"1":"29","2":"14","3":"7","4":"<data.frame [177 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"28"},{"1":"30","2":"15","3":"7","4":"<data.frame [144 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"29"},{"1":"31","2":"15","3":"7","4":"<data.frame [138 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"30"},{"1":"32","2":"16","3":"7","4":"<data.frame [180 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"31"},{"1":"33","2":"16","3":"7","4":"<data.frame [175 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"32"},{"1":"34","2":"17","3":"7","4":"<data.frame [142 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"33"},{"1":"35","2":"17","3":"7","4":"<data.frame [154 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"34"},{"1":"36","2":"18","3":"7","4":"<data.frame [307 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"35"},{"1":"37","2":"18","3":"7","4":"<data.frame [227 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"36"},{"1":"38","2":"19","3":"7","4":"<data.frame [179 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"37"},{"1":"39","2":"19","3":"7","4":"<data.frame [163 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"38"},{"1":"40","2":"20","3":"7","4":"<data.frame [201 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"39"},{"1":"41","2":"20","3":"7","4":"<data.frame [219 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"40"},{"1":"42","2":"21","3":"7","4":"<data.frame [177 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"41"},{"1":"43","2":"21","3":"7","4":"<data.frame [140 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"42"},{"1":"44","2":"22","3":"7","4":"<data.frame [214 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"43"},{"1":"45","2":"22","3":"7","4":"<data.frame [119 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"44"},{"1":"46","2":"23","3":"7","4":"<data.frame [143 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"45"},{"1":"47","2":"23","3":"7","4":"<data.frame [222 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"46"},{"1":"48","2":"24","3":"7","4":"<data.frame [171 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"47"},{"1":"49","2":"24","3":"7","4":"<data.frame [187 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"48"},{"1":"50","2":"25","3":"7","4":"<data.frame [138 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"49"},{"1":"51","2":"25","3":"7","4":"<data.frame [219 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"50"},{"1":"52","2":"26","3":"7","4":"<data.frame [129 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"51"},{"1":"53","2":"26","3":"7","4":"<data.frame [151 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"52"},{"1":"54","2":"27","3":"7","4":"<data.frame [168 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"53"},{"1":"55","2":"27","3":"7","4":"<data.frame [188 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"54"},{"1":"56","2":"28","3":"7","4":"<data.frame [259 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"55"},{"1":"57","2":"28","3":"7","4":"<data.frame [162 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"56"},{"1":"58","2":"29","3":"7","4":"<data.frame [157 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"57"},{"1":"59","2":"29","3":"7","4":"<data.frame [169 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"58"},{"1":"60","2":"30","3":"7","4":"<data.frame [113 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"59"},{"1":"61","2":"30","3":"7","4":"<data.frame [216 <U+00D7> 6]>","5":"STAND_TO_SIT","6":"60"},{"1":"1","2":"1","3":"8","4":"<data.frame [165 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"61"},{"1":"2","2":"1","3":"8","4":"<data.frame [156 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"62"},{"1":"3","2":"2","3":"8","4":"<data.frame [142 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"63"},{"1":"4","2":"2","3":"8","4":"<data.frame [139 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"64"},{"1":"5","2":"3","3":"8","4":"<data.frame [110 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"65"},{"1":"6","2":"3","3":"8","4":"<data.frame [183 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"66"},{"1":"7","2":"4","3":"8","4":"<data.frame [130 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"67"},{"1":"8","2":"4","3":"8","4":"<data.frame [143 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"68"},{"1":"9","2":"5","3":"8","4":"<data.frame [126 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"69"},{"1":"10","2":"5","3":"8","4":"<data.frame [129 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"70"},{"1":"11","2":"6","3":"8","4":"<data.frame [114 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"71"},{"1":"12","2":"6","3":"8","4":"<data.frame [132 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"72"},{"1":"13","2":"7","3":"8","4":"<data.frame [93 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"73"},{"1":"14","2":"7","3":"8","4":"<data.frame [74 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"74"},{"1":"15","2":"8","3":"8","4":"<data.frame [74 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"75"},{"1":"16","2":"8","3":"8","4":"<data.frame [114 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"76"},{"1":"16","2":"8","3":"8","4":"<data.frame [117 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"77"},{"1":"17","2":"9","3":"8","4":"<data.frame [106 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"78"},{"1":"18","2":"9","3":"8","4":"<data.frame [97 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"79"},{"1":"19","2":"10","3":"8","4":"<data.frame [89 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"80"},{"1":"20","2":"10","3":"8","4":"<data.frame [78 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"81"},{"1":"22","2":"11","3":"8","4":"<data.frame [132 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"82"},{"1":"23","2":"11","3":"8","4":"<data.frame [132 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"83"},{"1":"24","2":"12","3":"8","4":"<data.frame [104 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"84"},{"1":"25","2":"12","3":"8","4":"<data.frame [138 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"85"},{"1":"26","2":"13","3":"8","4":"<data.frame [142 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"86"},{"1":"27","2":"13","3":"8","4":"<data.frame [159 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"87"},{"1":"28","2":"14","3":"8","4":"<data.frame [136 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"88"},{"1":"29","2":"14","3":"8","4":"<data.frame [140 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"89"},{"1":"30","2":"15","3":"8","4":"<data.frame [110 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"90"},{"1":"31","2":"15","3":"8","4":"<data.frame [153 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"91"},{"1":"32","2":"16","3":"8","4":"<data.frame [109 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"92"},{"1":"33","2":"16","3":"8","4":"<data.frame [109 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"93"},{"1":"34","2":"17","3":"8","4":"<data.frame [153 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"94"},{"1":"35","2":"17","3":"8","4":"<data.frame [158 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"95"},{"1":"36","2":"18","3":"8","4":"<data.frame [182 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"96"},{"1":"37","2":"18","3":"8","4":"<data.frame [176 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"97"},{"1":"38","2":"19","3":"8","4":"<data.frame [135 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"98"},{"1":"39","2":"19","3":"8","4":"<data.frame [122 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"99"},{"1":"40","2":"20","3":"8","4":"<data.frame [182 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"100"},{"1":"41","2":"20","3":"8","4":"<data.frame [121 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"101"},{"1":"42","2":"21","3":"8","4":"<data.frame [146 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"102"},{"1":"43","2":"21","3":"8","4":"<data.frame [118 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"103"},{"1":"44","2":"22","3":"8","4":"<data.frame [104 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"104"},{"1":"45","2":"22","3":"8","4":"<data.frame [106 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"105"},{"1":"45","2":"22","3":"8","4":"<data.frame [92 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"106"},{"1":"46","2":"23","3":"8","4":"<data.frame [121 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"107"},{"1":"47","2":"23","3":"8","4":"<data.frame [150 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"108"},{"1":"48","2":"24","3":"8","4":"<data.frame [109 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"109"},{"1":"49","2":"24","3":"8","4":"<data.frame [124 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"110"},{"1":"50","2":"25","3":"8","4":"<data.frame [152 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"111"},{"1":"51","2":"25","3":"8","4":"<data.frame [173 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"112"},{"1":"52","2":"26","3":"8","4":"<data.frame [182 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"113"},{"1":"53","2":"26","3":"8","4":"<data.frame [102 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"114"},{"1":"54","2":"27","3":"8","4":"<data.frame [98 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"115"},{"1":"55","2":"27","3":"8","4":"<data.frame [101 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"116"},{"1":"56","2":"28","3":"8","4":"<data.frame [138 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"117"},{"1":"57","2":"28","3":"8","4":"<data.frame [121 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"118"},{"1":"58","2":"29","3":"8","4":"<data.frame [175 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"119"},{"1":"59","2":"29","3":"8","4":"<data.frame [134 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"120"},{"1":"60","2":"30","3":"8","4":"<data.frame [151 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"121"},{"1":"61","2":"30","3":"8","4":"<data.frame [128 <U+00D7> 6]>","5":"SIT_TO_STAND","6":"122"},{"1":"1","2":"1","3":"9","4":"<data.frame [192 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"123"},{"1":"2","2":"1","3":"9","4":"<data.frame [237 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"124"},{"1":"3","2":"2","3":"9","4":"<data.frame [225 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"125"},{"1":"4","2":"2","3":"9","4":"<data.frame [154 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"126"},{"1":"5","2":"3","3":"9","4":"<data.frame [151 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"127"},{"1":"6","2":"3","3":"9","4":"<data.frame [170 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"128"},{"1":"7","2":"4","3":"9","4":"<data.frame [224 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"129"},{"1":"8","2":"4","3":"9","4":"<data.frame [235 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"130"},{"1":"9","2":"5","3":"9","4":"<data.frame [220 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"131"},{"1":"10","2":"5","3":"9","4":"<data.frame [259 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"132"},{"1":"11","2":"6","3":"9","4":"<data.frame [158 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"133"},{"1":"12","2":"6","3":"9","4":"<data.frame [158 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"134"},{"1":"13","2":"7","3":"9","4":"<data.frame [257 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"135"},{"1":"14","2":"7","3":"9","4":"<data.frame [189 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"136"},{"1":"15","2":"8","3":"9","4":"<data.frame [166 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"137"},{"1":"16","2":"8","3":"9","4":"<data.frame [147 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"138"},{"1":"17","2":"9","3":"9","4":"<data.frame [204 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"139"},{"1":"18","2":"9","3":"9","4":"<data.frame [161 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"140"},{"1":"19","2":"10","3":"9","4":"<data.frame [181 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"141"},{"1":"20","2":"10","3":"9","4":"<data.frame [159 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"142"},{"1":"22","2":"11","3":"9","4":"<data.frame [185 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"143"},{"1":"23","2":"11","3":"9","4":"<data.frame [198 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"144"},{"1":"24","2":"12","3":"9","4":"<data.frame [173 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"145"},{"1":"25","2":"12","3":"9","4":"<data.frame [182 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"146"},{"1":"26","2":"13","3":"9","4":"<data.frame [226 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"147"},{"1":"27","2":"13","3":"9","4":"<data.frame [212 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"148"},{"1":"28","2":"14","3":"9","4":"<data.frame [289 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"149"},{"1":"29","2":"14","3":"9","4":"<data.frame [172 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"150"},{"1":"30","2":"15","3":"9","4":"<data.frame [202 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"151"},{"1":"31","2":"15","3":"9","4":"<data.frame [205 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"152"},{"1":"32","2":"16","3":"9","4":"<data.frame [195 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"153"},{"1":"33","2":"16","3":"9","4":"<data.frame [181 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"154"},{"1":"34","2":"17","3":"9","4":"<data.frame [312 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"155"},{"1":"35","2":"17","3":"9","4":"<data.frame [202 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"156"},{"1":"36","2":"18","3":"9","4":"<data.frame [251 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"157"},{"1":"37","2":"18","3":"9","4":"<data.frame [199 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"158"},{"1":"38","2":"19","3":"9","4":"<data.frame [176 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"159"},{"1":"39","2":"19","3":"9","4":"<data.frame [203 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"160"},{"1":"40","2":"20","3":"9","4":"<data.frame [297 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"161"},{"1":"41","2":"20","3":"9","4":"<data.frame [281 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"162"},{"1":"42","2":"21","3":"9","4":"<data.frame [202 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"163"},{"1":"43","2":"21","3":"9","4":"<data.frame [212 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"164"},{"1":"44","2":"22","3":"9","4":"<data.frame [136 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"165"},{"1":"45","2":"22","3":"9","4":"<data.frame [159 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"166"},{"1":"46","2":"23","3":"9","4":"<data.frame [213 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"167"},{"1":"47","2":"23","3":"9","4":"<data.frame [219 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"168"},{"1":"48","2":"24","3":"9","4":"<data.frame [234 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"169"},{"1":"49","2":"24","3":"9","4":"<data.frame [206 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"170"},{"1":"50","2":"25","3":"9","4":"<data.frame [199 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"171"},{"1":"51","2":"25","3":"9","4":"<data.frame [181 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"172"},{"1":"52","2":"26","3":"9","4":"<data.frame [185 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"173"},{"1":"53","2":"26","3":"9","4":"<data.frame [213 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"174"},{"1":"54","2":"27","3":"9","4":"<data.frame [227 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"175"},{"1":"55","2":"27","3":"9","4":"<data.frame [225 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"176"},{"1":"56","2":"28","3":"9","4":"<data.frame [226 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"177"},{"1":"57","2":"28","3":"9","4":"<data.frame [201 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"178"},{"1":"58","2":"29","3":"9","4":"<data.frame [326 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"179"},{"1":"59","2":"29","3":"9","4":"<data.frame [201 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"180"},{"1":"60","2":"30","3":"9","4":"<data.frame [183 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"181"},{"1":"61","2":"30","3":"9","4":"<data.frame [292 <U+00D7> 6]>","5":"SIT_TO_LIE","6":"182"},{"1":"1","2":"1","3":"10","4":"<data.frame [197 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"183"},{"1":"2","2":"1","3":"10","4":"<data.frame [184 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"184"},{"1":"3","2":"2","3":"10","4":"<data.frame [278 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"185"},{"1":"4","2":"2","3":"10","4":"<data.frame [142 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"186"},{"1":"5","2":"3","3":"10","4":"<data.frame [224 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"187"},{"1":"6","2":"3","3":"10","4":"<data.frame [197 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"188"},{"1":"7","2":"4","3":"10","4":"<data.frame [215 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"189"},{"1":"8","2":"4","3":"10","4":"<data.frame [210 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"190"},{"1":"9","2":"5","3":"10","4":"<data.frame [256 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"191"},{"1":"10","2":"5","3":"10","4":"<data.frame [203 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"192"},{"1":"11","2":"6","3":"10","4":"<data.frame [173 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"193"},{"1":"12","2":"6","3":"10","4":"<data.frame [165 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"194"},{"1":"13","2":"7","3":"10","4":"<data.frame [146 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"195"},{"1":"14","2":"7","3":"10","4":"<data.frame [123 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"196"},{"1":"15","2":"8","3":"10","4":"<data.frame [160 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"197"},{"1":"16","2":"8","3":"10","4":"<data.frame [136 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"198"},{"1":"16","2":"8","3":"10","4":"<data.frame [165 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"199"},{"1":"17","2":"9","3":"10","4":"<data.frame [177 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"200"},{"1":"18","2":"9","3":"10","4":"<data.frame [128 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"201"},{"1":"19","2":"10","3":"10","4":"<data.frame [169 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"202"},{"1":"20","2":"10","3":"10","4":"<data.frame [114 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"203"},{"1":"22","2":"11","3":"10","4":"<data.frame [179 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"204"},{"1":"23","2":"11","3":"10","4":"<data.frame [222 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"205"},{"1":"24","2":"12","3":"10","4":"<data.frame [178 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"206"},{"1":"25","2":"12","3":"10","4":"<data.frame [179 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"207"},{"1":"26","2":"13","3":"10","4":"<data.frame [190 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"208"},{"1":"27","2":"13","3":"10","4":"<data.frame [193 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"209"},{"1":"28","2":"14","3":"10","4":"<data.frame [226 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"210"},{"1":"29","2":"14","3":"10","4":"<data.frame [147 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"211"},{"1":"30","2":"15","3":"10","4":"<data.frame [166 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"212"},{"1":"31","2":"15","3":"10","4":"<data.frame [169 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"213"},{"1":"32","2":"16","3":"10","4":"<data.frame [184 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"214"},{"1":"33","2":"16","3":"10","4":"<data.frame [183 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"215"},{"1":"34","2":"17","3":"10","4":"<data.frame [211 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"216"},{"1":"35","2":"17","3":"10","4":"<data.frame [271 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"217"},{"1":"36","2":"18","3":"10","4":"<data.frame [245 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"218"},{"1":"37","2":"18","3":"10","4":"<data.frame [165 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"219"},{"1":"38","2":"19","3":"10","4":"<data.frame [197 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"220"},{"1":"39","2":"19","3":"10","4":"<data.frame [150 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"221"},{"1":"40","2":"20","3":"10","4":"<data.frame [156 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"222"},{"1":"41","2":"20","3":"10","4":"<data.frame [192 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"223"},{"1":"42","2":"21","3":"10","4":"<data.frame [204 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"224"},{"1":"43","2":"21","3":"10","4":"<data.frame [196 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"225"},{"1":"44","2":"22","3":"10","4":"<data.frame [185 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"226"},{"1":"45","2":"22","3":"10","4":"<data.frame [161 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"227"},{"1":"45","2":"22","3":"10","4":"<data.frame [157 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"228"},{"1":"46","2":"23","3":"10","4":"<data.frame [174 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"229"},{"1":"47","2":"23","3":"10","4":"<data.frame [171 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"230"},{"1":"48","2":"24","3":"10","4":"<data.frame [210 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"231"},{"1":"49","2":"24","3":"10","4":"<data.frame [180 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"232"},{"1":"50","2":"25","3":"10","4":"<data.frame [280 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"233"},{"1":"51","2":"25","3":"10","4":"<data.frame [215 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"234"},{"1":"52","2":"26","3":"10","4":"<data.frame [162 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"235"},{"1":"53","2":"26","3":"10","4":"<data.frame [174 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"236"},{"1":"54","2":"27","3":"10","4":"<data.frame [154 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"237"},{"1":"55","2":"27","3":"10","4":"<data.frame [149 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"238"},{"1":"58","2":"29","3":"10","4":"<data.frame [237 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"239"},{"1":"59","2":"29","3":"10","4":"<data.frame [170 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"240"},{"1":"60","2":"30","3":"10","4":"<data.frame [167 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"241"},{"1":"61","2":"30","3":"10","4":"<data.frame [239 <U+00D7> 6]>","5":"LIE_TO_SIT","6":"242"},{"1":"1","2":"1","3":"11","4":"<data.frame [288 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"243"},{"1":"2","2":"1","3":"11","4":"<data.frame [268 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"244"},{"1":"3","2":"2","3":"11","4":"<data.frame [418 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"245"},{"1":"4","2":"2","3":"11","4":"<data.frame [205 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"246"},{"1":"5","2":"3","3":"11","4":"<data.frame [216 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"247"},{"1":"6","2":"3","3":"11","4":"<data.frame [235 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"248"},{"1":"7","2":"4","3":"11","4":"<data.frame [332 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"249"},{"1":"8","2":"4","3":"11","4":"<data.frame [319 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"250"},{"1":"9","2":"5","3":"11","4":"<data.frame [346 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"251"},{"1":"10","2":"5","3":"11","4":"<data.frame [315 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"252"},{"1":"11","2":"6","3":"11","4":"<data.frame [313 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"253"},{"1":"12","2":"6","3":"11","4":"<data.frame [280 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"254"},{"1":"13","2":"7","3":"11","4":"<data.frame [206 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"255"},{"1":"14","2":"7","3":"11","4":"<data.frame [200 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"256"},{"1":"15","2":"8","3":"11","4":"<data.frame [211 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"257"},{"1":"16","2":"8","3":"11","4":"<data.frame [196 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"258"},{"1":"17","2":"9","3":"11","4":"<data.frame [188 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"259"},{"1":"18","2":"9","3":"11","4":"<data.frame [259 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"260"},{"1":"19","2":"10","3":"11","4":"<data.frame [229 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"261"},{"1":"20","2":"10","3":"11","4":"<data.frame [153 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"262"},{"1":"22","2":"11","3":"11","4":"<data.frame [193 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"263"},{"1":"23","2":"11","3":"11","4":"<data.frame [187 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"264"},{"1":"24","2":"12","3":"11","4":"<data.frame [205 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"265"},{"1":"25","2":"12","3":"11","4":"<data.frame [167 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"266"},{"1":"26","2":"13","3":"11","4":"<data.frame [195 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"267"},{"1":"27","2":"13","3":"11","4":"<data.frame [191 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"268"},{"1":"28","2":"14","3":"11","4":"<data.frame [342 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"269"},{"1":"29","2":"14","3":"11","4":"<data.frame [264 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"270"},{"1":"30","2":"15","3":"11","4":"<data.frame [194 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"271"},{"1":"31","2":"15","3":"11","4":"<data.frame [263 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"272"},{"1":"32","2":"16","3":"11","4":"<data.frame [235 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"273"},{"1":"33","2":"16","3":"11","4":"<data.frame [192 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"274"},{"1":"34","2":"17","3":"11","4":"<data.frame [238 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"275"},{"1":"35","2":"17","3":"11","4":"<data.frame [336 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"276"},{"1":"36","2":"18","3":"11","4":"<data.frame [297 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"277"},{"1":"37","2":"18","3":"11","4":"<data.frame [244 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"278"},{"1":"38","2":"19","3":"11","4":"<data.frame [256 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"279"},{"1":"39","2":"19","3":"11","4":"<data.frame [320 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"280"},{"1":"40","2":"20","3":"11","4":"<data.frame [425 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"281"},{"1":"41","2":"20","3":"11","4":"<data.frame [365 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"282"},{"1":"42","2":"21","3":"11","4":"<data.frame [313 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"283"},{"1":"43","2":"21","3":"11","4":"<data.frame [274 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"284"},{"1":"44","2":"22","3":"11","4":"<data.frame [173 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"285"},{"1":"45","2":"22","3":"11","4":"<data.frame [139 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"286"},{"1":"46","2":"23","3":"11","4":"<data.frame [253 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"287"},{"1":"47","2":"23","3":"11","4":"<data.frame [260 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"288"},{"1":"48","2":"24","3":"11","4":"<data.frame [494 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"289"},{"1":"49","2":"24","3":"11","4":"<data.frame [248 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"290"},{"1":"50","2":"25","3":"11","4":"<data.frame [185 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"291"},{"1":"51","2":"25","3":"11","4":"<data.frame [241 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"292"},{"1":"52","2":"26","3":"11","4":"<data.frame [178 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"293"},{"1":"53","2":"26","3":"11","4":"<data.frame [167 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"294"},{"1":"54","2":"27","3":"11","4":"<data.frame [216 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"295"},{"1":"55","2":"27","3":"11","4":"<data.frame [165 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"296"},{"1":"58","2":"29","3":"11","4":"<data.frame [234 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"297"},{"1":"59","2":"29","3":"11","4":"<data.frame [187 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"298"},{"1":"60","2":"30","3":"11","4":"<data.frame [156 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"299"},{"1":"61","2":"30","3":"11","4":"<data.frame [249 <U+00D7> 6]>","5":"STAND_TO_LIE","6":"300"},{"1":"1","2":"1","3":"12","4":"<data.frame [191 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"301"},{"1":"2","2":"1","3":"12","4":"<data.frame [242 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"302"},{"1":"3","2":"2","3":"12","4":"<data.frame [181 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"303"},{"1":"4","2":"2","3":"12","4":"<data.frame [181 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"304"},{"1":"5","2":"3","3":"12","4":"<data.frame [184 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"305"},{"1":"6","2":"3","3":"12","4":"<data.frame [167 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"306"},{"1":"7","2":"4","3":"12","4":"<data.frame [166 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"307"},{"1":"8","2":"4","3":"12","4":"<data.frame [171 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"308"},{"1":"9","2":"5","3":"12","4":"<data.frame [173 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"309"},{"1":"10","2":"5","3":"12","4":"<data.frame [142 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"310"},{"1":"11","2":"6","3":"12","4":"<data.frame [186 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"311"},{"1":"12","2":"6","3":"12","4":"<data.frame [254 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"312"},{"1":"13","2":"7","3":"12","4":"<data.frame [206 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"313"},{"1":"14","2":"7","3":"12","4":"<data.frame [170 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"314"},{"1":"15","2":"8","3":"12","4":"<data.frame [173 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"315"},{"1":"17","2":"9","3":"12","4":"<data.frame [168 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"316"},{"1":"18","2":"9","3":"12","4":"<data.frame [149 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"317"},{"1":"19","2":"10","3":"12","4":"<data.frame [118 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"318"},{"1":"20","2":"10","3":"12","4":"<data.frame [137 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"319"},{"1":"22","2":"11","3":"12","4":"<data.frame [139 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"320"},{"1":"23","2":"11","3":"12","4":"<data.frame [196 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"321"},{"1":"24","2":"12","3":"12","4":"<data.frame [207 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"322"},{"1":"25","2":"12","3":"12","4":"<data.frame [188 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"323"},{"1":"26","2":"13","3":"12","4":"<data.frame [259 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"324"},{"1":"27","2":"13","3":"12","4":"<data.frame [197 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"325"},{"1":"28","2":"14","3":"12","4":"<data.frame [289 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"326"},{"1":"29","2":"14","3":"12","4":"<data.frame [197 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"327"},{"1":"30","2":"15","3":"12","4":"<data.frame [201 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"328"},{"1":"31","2":"15","3":"12","4":"<data.frame [159 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"329"},{"1":"32","2":"16","3":"12","4":"<data.frame [146 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"330"},{"1":"33","2":"16","3":"12","4":"<data.frame [156 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"331"},{"1":"34","2":"17","3":"12","4":"<data.frame [200 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"332"},{"1":"35","2":"17","3":"12","4":"<data.frame [238 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"333"},{"1":"36","2":"18","3":"12","4":"<data.frame [206 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"334"},{"1":"37","2":"18","3":"12","4":"<data.frame [192 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"335"},{"1":"38","2":"19","3":"12","4":"<data.frame [161 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"336"},{"1":"39","2":"19","3":"12","4":"<data.frame [140 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"337"},{"1":"40","2":"20","3":"12","4":"<data.frame [172 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"338"},{"1":"41","2":"20","3":"12","4":"<data.frame [158 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"339"},{"1":"42","2":"21","3":"12","4":"<data.frame [206 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"340"},{"1":"43","2":"21","3":"12","4":"<data.frame [196 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"341"},{"1":"44","2":"22","3":"12","4":"<data.frame [257 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"342"},{"1":"46","2":"23","3":"12","4":"<data.frame [176 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"343"},{"1":"47","2":"23","3":"12","4":"<data.frame [161 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"344"},{"1":"48","2":"24","3":"12","4":"<data.frame [322 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"345"},{"1":"49","2":"24","3":"12","4":"<data.frame [196 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"346"},{"1":"50","2":"25","3":"12","4":"<data.frame [323 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"347"},{"1":"51","2":"25","3":"12","4":"<data.frame [187 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"348"},{"1":"52","2":"26","3":"12","4":"<data.frame [244 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"349"},{"1":"53","2":"26","3":"12","4":"<data.frame [183 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"350"},{"1":"54","2":"27","3":"12","4":"<data.frame [125 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"351"},{"1":"55","2":"27","3":"12","4":"<data.frame [153 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"352"},{"1":"56","2":"28","3":"12","4":"<data.frame [181 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"353"},{"1":"57","2":"28","3":"12","4":"<data.frame [167 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"354"},{"1":"58","2":"29","3":"12","4":"<data.frame [179 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"355"},{"1":"59","2":"29","3":"12","4":"<data.frame [145 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"356"},{"1":"60","2":"30","3":"12","4":"<data.frame [159 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"357"},{"1":"61","2":"30","3":"12","4":"<data.frame [147 <U+00D7> 6]>","5":"LIE_TO_STAND","6":"358"}],"options":{"columns":{"min":{},"max":[10]},"rows":{"min":[10],"max":[10]},"pages":{}}}
- </script>
- </div>
- ---
- ## Разделим на трейн тест
- ```r
- set.seed(100) # seed for reproducibility
- ## get all users
- userIds <- allObservations$userId %>% unique()
- ## randomly choose 24 (80% of 30 individuals) for training
- trainIds <- sample(userIds, size = 24)
- ## set the rest of the users to the testing set
- testIds <- setdiff(userIds,trainIds)
- ## filter data.
- trainData <- filteredObservations %>%
- filter(userId %in% trainIds)
- testData <- filteredObservations %>%
- filter(userId %in% testIds)
- ```
- ---
- layout: true
- ## Посмотрим на графики активности по классам
- ---
- ```r
- unpackedObs <- 1:nrow(trainData) %>%
- map_df(function(rowNum){
- dataRow <- trainData[rowNum, ]
- dataRow$data[[1]] %>%
- mutate(
- activityName = dataRow$activityName,
- observationId = dataRow$observationId,
- time = 1:n() )
- }) %>%
- gather(reading, value, -time, -activityName, -observationId) %>%
- separate(reading, into = c("type", "direction"), sep = "_") %>%
- mutate(type = ifelse(type == "a", "acceleration", "gyro"))
- ```
- ---
- ```r
- unpackedObs %>%
- ggplot(aes(x = time, y = value, color = direction)) +
- geom_line(alpha = 0.2) +
- geom_smooth(se = FALSE, alpha = 0.7, size = 0.5) +
- facet_grid(type ~ activityName, scales = "free_y") +
- theme_minimal() +
- theme( axis.text.x = element_blank() )
- ```
- <img src="Deep_Learning_in_R_files/figure-html/unnamed-chunk-17-1.svg" style="display: block; margin: auto;" />
- ---
- layout: true
- ## Подготовка данных к обучению
- ---
- ```r
- padSize <- trainData$data %>%
- map_int(nrow) %>%
- quantile(p = 0.98) %>%
- ceiling()
- padSize
- ```
- ```
- ## 98%
- ## 334
- ```
- ```r
- convertToTensor <- . %>%
- map(as.matrix) %>%
- pad_sequences(maxlen = padSize)
- trainObs <- trainData$data %>% convertToTensor()
- testObs <- testData$data %>% convertToTensor()
- dim(trainObs)
- ```
- ```
- ## [1] 286 334 6
- ```
- ---
- ```r
- # one hot encoding
- oneHotClasses <- . %>%
- {. - 7} %>% # bring integers down to 0-6 from 7-12
- to_categorical() # One-hot encode
- trainY <- trainData$activity %>% oneHotClasses()
- testY <- testData$activity %>% oneHotClasses()
- ```
- ---
- layout:true
- ## Наконец то сетка!
- ---
- ```r
- input_shape <- dim(trainObs)[-1]
- num_classes <- dim(trainY)[2]
- filters <- 24 # number of convolutional filters to learn
- kernel_size <- 8 # how many time-steps each conv layer sees.
- dense_size <- 48 # size of our penultimate dense layer.
- ```
- ---
- ```r
- model <- keras_model_sequential() # define type of class model
- model %>% layer_conv_1d( # add first convolutions layer
- filters = filters, # num of filters
- kernel_size = kernel_size, # kernel size
- input_shape = input_shape,
- padding = "valid", # to fill padding with zero
- activation = "relu") %>% # activation fiucntion on the end of layer
- layer_batch_normalization() %>% # batch norm
- layer_spatial_dropout_1d(0.15) %>% # dropout 15% neurons
- layer_conv_1d(filters = filters/2, # second convolution layer with half of num filters
- kernel_size = kernel_size,
- activation = "relu") %>%
- layer_global_average_pooling_1d() %>% # to average all verctor representation in one featuremap
- layer_batch_normalization() %>%
- layer_dropout(0.2) %>% # dropout 20% neurons
- layer_dense(dense_size, # fullyconected layer perceptron
- activation = "relu") %>%
- layer_batch_normalization() %>%
- layer_dropout(0.25) %>%
- layer_dense(num_classes, # one more fully connected layer size of num classes
- activation = "softmax", # our loss function for multyply classification
- name = "dense_output")
- ```
- ---
- ### Выведем описание нашей сетки
- ```r
- summary(model)
- ```
- 
- ---
- layout:true
- ## Обучим же наконец
- ---
- ## Компиляция графа
- ```r
- model %>% compile(
- loss = "categorical_crossentropy", # our loss function
- optimizer = "rmsprop", # our optimizer alrorithm
- metrics = "accuracy" # our metric
- )
- ```
- ---
- ## train
- ```r
- trainHistory <- model %>%
- fit(
- x = trainObs, y = trainY, # data
- epochs = 350, # num epoch
- validation_data = list(testObs, testY), # validation tests on each epoch
- callbacks = list(
- callback_model_checkpoint("best_model.h5",
- save_best_only = TRUE))) # update train history and save model
- ```
- ---
- 
- ---
- 
- ---
- layout:true
- ## Предсказание
- ---
- ## Подготовка теста
- ```r
- # one-hot ecnoding labels for predict
- oneHotToLabel <- activityLabels %>%
- mutate(number = number - 7) %>%
- filter(number >= 0) %>%
- mutate(class = paste0("V",number + 1)) %>%
- select(-number)
- ```
- ## Выбор лучшей модели
- ```r
- bestModel <- load_model_hdf5("best_model.h5")
- ```
- ---
- ## Еще немного кода
- ```r
- tidyPredictionProbs <- bestModel %>%
- predict(testObs) %>%
- as_data_frame() %>%
- mutate(obs = 1:n()) %>%
- gather(class, prob, -obs) %>%
- right_join(oneHotToLabel, by = "class")
- predictionPerformance <- tidyPredictionProbs %>%
- group_by(obs) %>%
- summarise(
- highestProb = max(prob),
- predicted = label[prob == highestProb]
- ) %>%
- mutate(
- truth = testData$activityName,
- correct = truth == predicted
- )
- ```
- ---
- ```r
- predictionPerformance %>% paged_table()
- ```
- <div data-pagedtable="false">
- <script data-pagedtable-source type="application/json">
- {"columns":[{"label":["obs"],"name":[1],"type":["int"],"align":["right"]},{"label":["highestProb"],"name":[2],"type":["dbl"],"align":["right"]},{"label":["predicted"],"name":[3],"type":["fctr"],"align":["left"]},{"label":["truth"],"name":[4],"type":["fctr"],"align":["left"]},{"label":["correct"],"name":[5],"type":["lgl"],"align":["right"]}],"data":[{"1":"1","2":"0.5235093","3":"STAND_TO_SIT","4":"STAND_TO_SIT","5":"TRUE"},{"1":"2","2":"0.7429348","3":"STAND_TO_SIT","4":"STAND_TO_SIT","5":"TRUE"},{"1":"3","2":"0.9417344","3":"STAND_TO_SIT","4":"STAND_TO_SIT","5":"TRUE"},{"1":"4","2":"0.9636050","3":"STAND_TO_SIT","4":"STAND_TO_SIT","5":"TRUE"},{"1":"5","2":"0.9972581","3":"STAND_TO_SIT","4":"STAND_TO_SIT","5":"TRUE"},{"1":"6","2":"0.9886600","3":"STAND_TO_SIT","4":"STAND_TO_SIT","5":"TRUE"},{"1":"7","2":"0.8171908","3":"SIT_TO_STAND","4":"STAND_TO_SIT","5":"FALSE"},{"1":"8","2":"0.9819133","3":"STAND_TO_SIT","4":"STAND_TO_SIT","5":"TRUE"},{"1":"9","2":"0.9207168","3":"STAND_TO_SIT","4":"STAND_TO_SIT","5":"TRUE"},{"1":"10","2":"0.5373349","3":"STAND_TO_SIT","4":"STAND_TO_SIT","5":"TRUE"},{"1":"11","2":"0.9969481","3":"STAND_TO_SIT","4":"STAND_TO_SIT","5":"TRUE"},{"1":"12","2":"0.9679638","3":"STAND_TO_SIT","4":"STAND_TO_SIT","5":"TRUE"},{"1":"13","2":"0.9976879","3":"SIT_TO_STAND","4":"SIT_TO_STAND","5":"TRUE"},{"1":"14","2":"0.9947354","3":"SIT_TO_STAND","4":"SIT_TO_STAND","5":"TRUE"},{"1":"15","2":"0.9846317","3":"SIT_TO_STAND","4":"SIT_TO_STAND","5":"TRUE"},{"1":"16","2":"0.9583181","3":"SIT_TO_STAND","4":"SIT_TO_STAND","5":"TRUE"},{"1":"17","2":"0.9918798","3":"SIT_TO_STAND","4":"SIT_TO_STAND","5":"TRUE"},{"1":"18","2":"0.9962373","3":"SIT_TO_STAND","4":"SIT_TO_STAND","5":"TRUE"},{"1":"19","2":"0.5915999","3":"SIT_TO_STAND","4":"SIT_TO_STAND","5":"TRUE"},{"1":"20","2":"0.9856395","3":"SIT_TO_STAND","4":"SIT_TO_STAND","5":"TRUE"},{"1":"21","2":"0.9853276","3":"SIT_TO_STAND","4":"SIT_TO_STAND","5":"TRUE"},{"1":"22","2":"0.6484483","3":"LIE_TO_STAND","4":"SIT_TO_STAND","5":"FALSE"},{"1":"23","2":"0.9904292","3":"SIT_TO_STAND","4":"SIT_TO_STAND","5":"TRUE"},{"1":"24","2":"0.9951174","3":"SIT_TO_STAND","4":"SIT_TO_STAND","5":"TRUE"},{"1":"25","2":"0.9345155","3":"SIT_TO_LIE","4":"SIT_TO_LIE","5":"TRUE"},{"1":"26","2":"0.9346985","3":"SIT_TO_LIE","4":"SIT_TO_LIE","5":"TRUE"},{"1":"27","2":"0.8282700","3":"SIT_TO_LIE","4":"SIT_TO_LIE","5":"TRUE"},{"1":"28","2":"0.4446574","3":"STAND_TO_LIE","4":"SIT_TO_LIE","5":"FALSE"},{"1":"29","2":"0.9600595","3":"SIT_TO_LIE","4":"SIT_TO_LIE","5":"TRUE"},{"1":"30","2":"0.9273394","3":"SIT_TO_LIE","4":"SIT_TO_LIE","5":"TRUE"},{"1":"31","2":"0.4244703","3":"STAND_TO_LIE","4":"SIT_TO_LIE","5":"FALSE"},{"1":"32","2":"0.8656624","3":"STAND_TO_LIE","4":"SIT_TO_LIE","5":"FALSE"},{"1":"33","2":"0.9675164","3":"SIT_TO_LIE","4":"SIT_TO_LIE","5":"TRUE"},{"1":"34","2":"0.9878884","3":"SIT_TO_LIE","4":"SIT_TO_LIE","5":"TRUE"},{"1":"35","2":"0.9726661","3":"SIT_TO_LIE","4":"SIT_TO_LIE","5":"TRUE"},{"1":"36","2":"0.9835377","3":"SIT_TO_LIE","4":"SIT_TO_LIE","5":"TRUE"},{"1":"37","2":"0.8140901","3":"LIE_TO_SIT","4":"LIE_TO_SIT","5":"TRUE"},{"1":"38","2":"0.8645245","3":"LIE_TO_SIT","4":"LIE_TO_SIT","5":"TRUE"},{"1":"39","2":"0.9283405","3":"LIE_TO_STAND","4":"LIE_TO_SIT","5":"FALSE"},{"1":"40","2":"0.9598847","3":"LIE_TO_SIT","4":"LIE_TO_SIT","5":"TRUE"},{"1":"41","2":"0.9766055","3":"LIE_TO_SIT","4":"LIE_TO_SIT","5":"TRUE"},{"1":"42","2":"0.6702896","3":"LIE_TO_STAND","4":"LIE_TO_SIT","5":"FALSE"},{"1":"43","2":"0.7475867","3":"STAND_TO_SIT","4":"LIE_TO_SIT","5":"FALSE"},{"1":"44","2":"0.6041491","3":"SIT_TO_STAND","4":"LIE_TO_SIT","5":"FALSE"},{"1":"45","2":"0.9565383","3":"LIE_TO_SIT","4":"LIE_TO_SIT","5":"TRUE"},{"1":"46","2":"0.7668063","3":"LIE_TO_SIT","4":"LIE_TO_SIT","5":"TRUE"},{"1":"47","2":"0.9975970","3":"LIE_TO_SIT","4":"LIE_TO_SIT","5":"TRUE"},{"1":"48","2":"0.9129800","3":"LIE_TO_SIT","4":"LIE_TO_SIT","5":"TRUE"},{"1":"49","2":"0.5405371","3":"STAND_TO_SIT","4":"STAND_TO_LIE","5":"FALSE"},{"1":"50","2":"0.3918574","3":"LIE_TO_STAND","4":"STAND_TO_LIE","5":"FALSE"},{"1":"51","2":"0.6076084","3":"STAND_TO_LIE","4":"STAND_TO_LIE","5":"TRUE"},{"1":"52","2":"0.7430704","3":"STAND_TO_LIE","4":"STAND_TO_LIE","5":"TRUE"},{"1":"53","2":"0.9855121","3":"STAND_TO_LIE","4":"STAND_TO_LIE","5":"TRUE"},{"1":"54","2":"0.6805021","3":"STAND_TO_LIE","4":"STAND_TO_LIE","5":"TRUE"},{"1":"55","2":"0.9350494","3":"STAND_TO_LIE","4":"STAND_TO_LIE","5":"TRUE"},{"1":"56","2":"0.6553332","3":"STAND_TO_LIE","4":"STAND_TO_LIE","5":"TRUE"},{"1":"57","2":"0.9363784","3":"STAND_TO_LIE","4":"STAND_TO_LIE","5":"TRUE"},{"1":"58","2":"0.9984127","3":"STAND_TO_LIE","4":"STAND_TO_LIE","5":"TRUE"},{"1":"59","2":"0.9998779","3":"STAND_TO_LIE","4":"STAND_TO_LIE","5":"TRUE"},{"1":"60","2":"0.9920494","3":"STAND_TO_LIE","4":"STAND_TO_LIE","5":"TRUE"},{"1":"61","2":"0.8970848","3":"LIE_TO_STAND","4":"LIE_TO_STAND","5":"TRUE"},{"1":"62","2":"0.9540750","3":"LIE_TO_STAND","4":"LIE_TO_STAND","5":"TRUE"},{"1":"63","2":"0.7527739","3":"LIE_TO_SIT","4":"LIE_TO_STAND","5":"FALSE"},{"1":"64","2":"0.5927992","3":"LIE_TO_SIT","4":"LIE_TO_STAND","5":"FALSE"},{"1":"65","2":"0.8900657","3":"LIE_TO_STAND","4":"LIE_TO_STAND","5":"TRUE"},{"1":"66","2":"0.9679322","3":"LIE_TO_STAND","4":"LIE_TO_STAND","5":"TRUE"},{"1":"67","2":"0.4529986","3":"SIT_TO_STAND","4":"LIE_TO_STAND","5":"FALSE"},{"1":"68","2":"0.8696935","3":"SIT_TO_LIE","4":"LIE_TO_STAND","5":"FALSE"},{"1":"69","2":"0.6704690","3":"SIT_TO_STAND","4":"LIE_TO_STAND","5":"FALSE"},{"1":"70","2":"0.7199435","3":"LIE_TO_SIT","4":"LIE_TO_STAND","5":"FALSE"},{"1":"71","2":"0.6397786","3":"LIE_TO_STAND","4":"LIE_TO_STAND","5":"TRUE"},{"1":"72","2":"0.7789361","3":"LIE_TO_STAND","4":"LIE_TO_STAND","5":"TRUE"}],"options":{"columns":{"min":{},"max":[10]},"rows":{"min":[10],"max":[10]},"pages":{}}}
- </script>
- </div>
- ---
- layout:true
- ## Визуализация ошибок
- ---
- ```r
- predictionPerformance %>%
- mutate(result = ifelse(correct, 'Correct', 'Incorrect')) %>%
- ggplot(aes(highestProb)) +
- geom_histogram(binwidth = 0.01) +
- geom_rug(alpha = 0.5) +
- facet_grid(result~.) +
- ggtitle("Probabilities associated with prediction by correctness")
- ```
- <!-- -->
- ---
- ```r
- predictionPerformance %>%
- group_by(truth, predicted) %>%
- summarise(count = n()) %>%
- mutate(good = truth == predicted) %>%
- ggplot(aes(x = truth, y = predicted)) +
- geom_point(aes(size = count, color = good)) +
- geom_text(aes(label = count),
- hjust = 0, vjust = 0,
- nudge_x = 0.1, nudge_y = 0.1) +
- guides(color = FALSE, size = FALSE) +
- theme_minimal()
- ```
- <!-- -->
- ---
- layout:false
- class: inverse, middle, center
- # Заключение
- ---
- background-image: url(https://images.manning.com/720/960/resize/book/a/4e5e97f-4e8d-4d97-a715-f6c2b0eb95f5/Allaire-DLwithR-HI.png)
- ---
- class: center, middle
- # Спасибо!
- Слайды сделаны с помощью R package [**xaringan**](https://github.com/yihui/xaringan).
- Веб версию слайдов можно найти на https://metya.github.io/DeepLearning_in_R/
- Код можно посмотреть здесь https://github.com/metya/DeepLearning_in_R/
- </textarea>
- <script src="https://remarkjs.com/downloads/remark-latest.min.js"></script>
- <script>var slideshow = remark.create({
- "highlightStyle": "github",
- "highlightLines": true,
- "countIncrementalSlides": false
- });
- if (window.HTMLWidgets) slideshow.on('afterShowSlide', function (slide) {
- window.dispatchEvent(new Event('resize'));
- });
- (function() {
- var d = document, s = d.createElement("style"), r = d.querySelector(".remark-slide-scaler");
- if (!r) return;
- s.type = "text/css"; s.innerHTML = "@page {size: " + r.style.width + " " + r.style.height +"; }";
- d.head.appendChild(s);
- })();</script>
- <script>
- (function() {
- var i, text, code, codes = document.getElementsByTagName('code');
- for (i = 0; i < codes.length;) {
- code = codes[i];
- if (code.parentNode.tagName !== 'PRE' && code.childElementCount === 0) {
- text = code.textContent;
- if (/^\\\((.|\s)+\\\)$/.test(text) || /^\\\[(.|\s)+\\\]$/.test(text) ||
- /^\$\$(.|\s)+\$\$$/.test(text) ||
- /^\\begin\{([^}]+)\}(.|\s)+\\end\{[^}]+\}$/.test(text)) {
- code.outerHTML = code.innerHTML; // remove <code></code>
- continue;
- }
- }
- i++;
- }
- })();
- </script>
- <!-- dynamically load mathjax for compatibility with self-contained -->
- <script>
- (function () {
- var script = document.createElement('script');
- script.type = 'text/javascript';
- script.src = 'https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-MML-AM_CHTML';
- if (location.protocol !== 'file:' && /^https?:/.test(script.src))
- script.src = script.src.replace(/^https?:/, '');
- document.getElementsByTagName('head')[0].appendChild(script);
- })();
- </script>
- </body>
- </html>
|