library(dplyr)
library(deepSentimentR)
data("sentiment140_train")
sentiment140_train %>%
freq_by_polarity(user_list = c("", "mcraddictal"),
start_date_time = lubridate::as_datetime("2009-05-30"),
end_date_time = lubridate::as_datetime("2009-06-03"),
keyword_list = c(""))
#> $raw
#> # A tibble: 8 x 14
#> polarity id date query user text nouns adjectives
#> <chr> <int> <dttm> <chr> <chr> <chr> <int> <int>
#> 1 Negative 1.99e9 2009-06-01 16:44:55 NO_Q… mcra… @oy_… 2 1
#> 2 Negative 1.99e9 2009-06-01 06:34:38 NO_Q… mcra… @hem… 3 2
#> 3 Negative 1.97e9 2009-05-30 05:32:26 NO_Q… mcra… @wes… 1 2
#> 4 Positive 1.98e9 2009-05-31 17:31:47 NO_Q… mcra… nd I… 3 1
#> 5 Negative 1.98e9 2009-05-31 15:39:18 NO_Q… mcra… @CRs… 3 1
#> 6 Negative 1.97e9 2009-05-30 13:19:07 NO_Q… mcra… @oy_… 2 2
#> 7 Positive 1.97e9 2009-05-30 01:31:51 NO_Q… mcra… @kit… 2 1
#> 8 Positive 1.98e9 2009-05-31 00:06:28 NO_Q… mcra… @sca… 5 1
#> # … with 6 more variables: prepositions <int>, articles <int>,
#> # pronouns <int>, verbs <int>, adverbs <int>, interjections <int>
#>
#> $frequency
#> # A tibble: 2 x 2
#> polarity counts
#> <fct> <int>
#> 1 Negative 5
#> 2 Positive 3
#>
#> $plot
time_series()
#> $raw
#> # A tibble: 50,000 x 14
#> polarity id date query user text nouns adjectives
#> <chr> <int> <dttm> <chr> <chr> <chr> <int> <int>
#> 1 Negative 2.01e9 2009-06-03 09:26:56 NO_Q… Nina… n fe… 3 0
#> 2 Positive 1.93e9 2009-05-27 05:45:38 NO_Q… RBCK… @ong… 14 1
#> 3 Negative 2.05e9 2009-06-06 02:27:00 NO_Q… t3ll… an m… 4 2
#> 4 Negative NA 2009-06-19 18:58:49 NO_Q… Joyc… nd n… 7 0
#> 5 Positive 2.07e9 2009-06-07 17:56:22 NO_Q… Shau… @yan… 4 3
#> 6 Positive 1.56e9 2009-04-19 19:00:50 NO_Q… shor… @ust… 4 1
#> 7 Positive 1.84e9 2009-05-18 12:35:39 NO_Q… molt… orni… 5 0
#> 8 Negative 2.07e9 2009-06-07 21:14:40 NO_Q… chel… Pod … 3 0
#> 9 Negative NA 2009-06-17 07:38:41 NO_Q… call… an't… 6 1
#> 10 Negative NA 2009-06-25 08:50:36 NO_Q… Love… " wi… 2 0
#> # … with 49,990 more rows, and 6 more variables: prepositions <int>,
#> # articles <int>, pronouns <int>, verbs <int>, adverbs <int>,
#> # interjections <int>
#>
#> $date_counts
#> # A tibble: 73 x 3
#> date polarity count
#> <date> <fct> <int>
#> 1 2009-04-07 Negative 265
#> 2 2009-04-07 Positive 336
#> 3 2009-04-18 Negative 225
#> 4 2009-04-18 Positive 271
#> 5 2009-04-19 Negative 407
#> 6 2009-04-19 Positive 578
#> 7 2009-04-20 Negative 218
#> 8 2009-04-20 Positive 313
#> 9 2009-04-21 Negative 131
#> 10 2009-04-21 Positive 203
#> # … with 63 more rows
#>
#> $day_counts
#> # A tibble: 53 x 3
#> day polarity count
#> <int> <fct> <int>
#> 1 1 Negative 1278
#> 2 1 Positive 1828
#> 3 2 Negative 1357
#> 4 2 Positive 1996
#> 5 3 Negative 1096
#> 6 3 Positive 1611
#> 7 4 Negative 427
#> 8 4 Positive 604
#> 9 5 Negative 440
#> 10 5 Positive 670
#> # … with 43 more rows
#>
#> $plot_date
#>
#> $plot_day
bigram_network()
#> $raw
#> # A tibble: 354 x 14
#> polarity id date query user text nouns adjectives
#> <chr> <int> <dttm> <chr> <chr> <chr> <int> <int>
#> 1 Positive 217 2009-05-25 17:29:39 mcdo… Mami… mgg … 7 2
#> 2 Positive 2140 2009-05-20 02:38:17 nike Chet… ew n… 4 2
#> 3 Negative 224 2009-05-25 17:34:51 chen… QCWo… ife?… 9 3
#> 4 Positive 569 2009-06-07 21:38:16 kind… rach… @lon… 8 2
#> 5 Positive 2546 2009-06-08 00:13:48 kind… k8tb… " lo… 7 1
#> 6 Positive 1019 2009-05-11 05:21:25 lebr… unde… atch… 3 1
#> 7 Negative 2110 2009-05-18 01:14:35 Malc… blin… @por… 7 3
#> 8 Positive 256 2009-05-27 23:59:18 goog… maex… " am… 3 1
#> 9 Negative 413 2009-06-02 03:17:04 time… Jaso… " ha… 11 4
#> 10 Positive 1003 2009-05-11 03:18:59 kind… Happ… y Ki… 1 0
#> # … with 344 more rows, and 6 more variables: prepositions <int>,
#> # articles <int>, pronouns <int>, verbs <int>, adverbs <int>,
#> # interjections <int>
#>
#> $bigram_counts
#> # A tibble: 982 x 3
#> word1 word2 counts
#> <chr> <chr> <int>
#> 1 time warner 25
#> 2 http bit.ly 24
#> 3 ime warner 7
#> 4 malcolm gladwell 7
#> 5 bobby flay 6
#> 6 http tinyurl.com 6
#> 7 twitter api 6
#> 8 warner cable 6
#> 9 love love 5
#> 10 museum 2 5
#> # … with 972 more rows
#>
#> $plot
word_cor_network()
#> $raw
#> # A tibble: 354 x 14
#> polarity id date query user text nouns adjectives
#> <chr> <int> <dttm> <chr> <chr> <chr> <int> <int>
#> 1 Positive 217 2009-05-25 17:29:39 mcdo… Mami… mgg … 7 2
#> 2 Positive 2140 2009-05-20 02:38:17 nike Chet… ew n… 4 2
#> 3 Negative 224 2009-05-25 17:34:51 chen… QCWo… ife?… 9 3
#> 4 Positive 569 2009-06-07 21:38:16 kind… rach… @lon… 8 2
#> 5 Positive 2546 2009-06-08 00:13:48 kind… k8tb… " lo… 7 1
#> 6 Positive 1019 2009-05-11 05:21:25 lebr… unde… atch… 3 1
#> 7 Negative 2110 2009-05-18 01:14:35 Malc… blin… @por… 7 3
#> 8 Positive 256 2009-05-27 23:59:18 goog… maex… " am… 3 1
#> 9 Negative 413 2009-06-02 03:17:04 time… Jaso… " ha… 11 4
#> 10 Positive 1003 2009-05-11 03:18:59 kind… Happ… y Ki… 1 0
#> # … with 344 more rows, and 6 more variables: prepositions <int>,
#> # articles <int>, pronouns <int>, verbs <int>, adverbs <int>,
#> # interjections <int>
#>
#> $word_cors
#> # A tibble: 5,256 x 3
#> item1 item2 correlation
#> <chr> <chr> <dbl>
#> 1 flay bobby 1
#> 2 bobby flay 1
#> 3 korea north 0.911
#> 4 north korea 0.911
#> 5 star trek 0.893
#> 6 trek star 0.893
#> 7 api twitter 0.879
#> 8 twitter api 0.879
#> 9 gladwell malcolm 0.820
#> 10 malcolm gladwell 0.820
#> # … with 5,246 more rows
#>
#> $plot
predict_polarity_keras(model_load_path = system.file("extdata",
"train_no_glove_lstm.rds",
package = "deepSentimentR",
mustWork = TRUE))
#> $raw
#> # A tibble: 354 x 14
#> polarity id date query user text nouns adjectives
#> <chr> <int> <dttm> <chr> <chr> <chr> <int> <int>
#> 1 Positive 217 2009-05-25 17:29:39 mcdo… Mami… mgg … 7 2
#> 2 Positive 2140 2009-05-20 02:38:17 nike Chet… ew n… 4 2
#> 3 Negative 224 2009-05-25 17:34:51 chen… QCWo… ife?… 9 3
#> 4 Positive 569 2009-06-07 21:38:16 kind… rach… @lon… 8 2
#> 5 Positive 2546 2009-06-08 00:13:48 kind… k8tb… " lo… 7 1
#> 6 Positive 1019 2009-05-11 05:21:25 lebr… unde… atch… 3 1
#> 7 Negative 2110 2009-05-18 01:14:35 Malc… blin… @por… 7 3
#> 8 Positive 256 2009-05-27 23:59:18 goog… maex… " am… 3 1
#> 9 Negative 413 2009-06-02 03:17:04 time… Jaso… " ha… 11 4
#> 10 Positive 1003 2009-05-11 03:18:59 kind… Happ… y Ki… 1 0
#> # … with 344 more rows, and 6 more variables: prepositions <int>,
#> # articles <int>, pronouns <int>, verbs <int>, adverbs <int>,
#> # interjections <int>
#>
#> $predictions
#> # A tibble: 354 x 15
#> polarity id date query user text nouns adjectives
#> <dbl> <int> <dttm> <chr> <chr> <chr> <int> <int>
#> 1 1 217 2009-05-25 17:29:39 mcdo… Mami… mgg … 7 2
#> 2 1 2140 2009-05-20 02:38:17 nike Chet… ew n… 4 2
#> 3 0 224 2009-05-25 17:34:51 chen… QCWo… ife?… 9 3
#> 4 1 569 2009-06-07 21:38:16 kind… rach… @lon… 8 2
#> 5 1 2546 2009-06-08 00:13:48 kind… k8tb… " lo… 7 1
#> 6 1 1019 2009-05-11 05:21:25 lebr… unde… atch… 3 1
#> 7 0 2110 2009-05-18 01:14:35 Malc… blin… @por… 7 3
#> 8 1 256 2009-05-27 23:59:18 goog… maex… " am… 3 1
#> 9 0 413 2009-06-02 03:17:04 time… Jaso… " ha… 11 4
#> 10 1 1003 2009-05-11 03:18:59 kind… Happ… y Ki… 1 0
#> # … with 344 more rows, and 7 more variables: prepositions <int>,
#> # articles <int>, pronouns <int>, verbs <int>, adverbs <int>,
#> # interjections <int>, pred_polarity[,1] <int>
#>
#> $confusion_matrix
#> # A tibble: 4 x 3
#> polarity pred_polarity count
#> <fct> <fct> <int>
#> 1 0 0 135
#> 2 0 1 40
#> 3 1 0 34
#> 4 1 1 145
#>
#> $true_negative
#> [1] 135
#>
#> $true_positive
#> [1] 145
#>
#> $false_positive
#> [1] 40
#>
#> $false_negative
#> [1] 34
#>
#> $precision
#> [1] 0.7837838
#>
#> $recall
#> [1] 0.8100559
#>
#> $f1
#> [1] 0.7967033
#>
#> $accuracy
#> [1] 0.7909605
#>
#> $plot
predict_polarity_keras(model_load_path = system.file("extdata",
"train_glove_lstm.rds",
package = "deepSentimentR",
mustWork = TRUE))
#> $raw
#> # A tibble: 354 x 14
#> polarity id date query user text nouns adjectives
#> <chr> <int> <dttm> <chr> <chr> <chr> <int> <int>
#> 1 Positive 217 2009-05-25 17:29:39 mcdo… Mami… mgg … 7 2
#> 2 Positive 2140 2009-05-20 02:38:17 nike Chet… ew n… 4 2
#> 3 Negative 224 2009-05-25 17:34:51 chen… QCWo… ife?… 9 3
#> 4 Positive 569 2009-06-07 21:38:16 kind… rach… @lon… 8 2
#> 5 Positive 2546 2009-06-08 00:13:48 kind… k8tb… " lo… 7 1
#> 6 Positive 1019 2009-05-11 05:21:25 lebr… unde… atch… 3 1
#> 7 Negative 2110 2009-05-18 01:14:35 Malc… blin… @por… 7 3
#> 8 Positive 256 2009-05-27 23:59:18 goog… maex… " am… 3 1
#> 9 Negative 413 2009-06-02 03:17:04 time… Jaso… " ha… 11 4
#> 10 Positive 1003 2009-05-11 03:18:59 kind… Happ… y Ki… 1 0
#> # … with 344 more rows, and 6 more variables: prepositions <int>,
#> # articles <int>, pronouns <int>, verbs <int>, adverbs <int>,
#> # interjections <int>
#>
#> $predictions
#> # A tibble: 354 x 15
#> polarity id date query user text nouns adjectives
#> <dbl> <int> <dttm> <chr> <chr> <chr> <int> <int>
#> 1 1 217 2009-05-25 17:29:39 mcdo… Mami… mgg … 7 2
#> 2 1 2140 2009-05-20 02:38:17 nike Chet… ew n… 4 2
#> 3 0 224 2009-05-25 17:34:51 chen… QCWo… ife?… 9 3
#> 4 1 569 2009-06-07 21:38:16 kind… rach… @lon… 8 2
#> 5 1 2546 2009-06-08 00:13:48 kind… k8tb… " lo… 7 1
#> 6 1 1019 2009-05-11 05:21:25 lebr… unde… atch… 3 1
#> 7 0 2110 2009-05-18 01:14:35 Malc… blin… @por… 7 3
#> 8 1 256 2009-05-27 23:59:18 goog… maex… " am… 3 1
#> 9 0 413 2009-06-02 03:17:04 time… Jaso… " ha… 11 4
#> 10 1 1003 2009-05-11 03:18:59 kind… Happ… y Ki… 1 0
#> # … with 344 more rows, and 7 more variables: prepositions <int>,
#> # articles <int>, pronouns <int>, verbs <int>, adverbs <int>,
#> # interjections <int>, pred_polarity[,1] <int>
#>
#> $confusion_matrix
#> # A tibble: 4 x 3
#> polarity pred_polarity count
#> <fct> <fct> <int>
#> 1 0 0 122
#> 2 0 1 53
#> 3 1 0 31
#> 4 1 1 148
#>
#> $true_negative
#> [1] 122
#>
#> $true_positive
#> [1] 148
#>
#> $false_positive
#> [1] 53
#>
#> $false_negative
#> [1] 31
#>
#> $precision
#> [1] 0.7363184
#>
#> $recall
#> [1] 0.8268156
#>
#> $f1
#> [1] 0.7789474
#>
#> $accuracy
#> [1] 0.7627119
#>
#> $plot
predict_polarity_keras(model_load_path = system.file("extdata",
"train_no_glove_conv_1d.rds",
package = "deepSentimentR",
mustWork = TRUE))
#> $raw
#> # A tibble: 354 x 14
#> polarity id date query user text nouns adjectives
#> <chr> <int> <dttm> <chr> <chr> <chr> <int> <int>
#> 1 Positive 217 2009-05-25 17:29:39 mcdo… Mami… mgg … 7 2
#> 2 Positive 2140 2009-05-20 02:38:17 nike Chet… ew n… 4 2
#> 3 Negative 224 2009-05-25 17:34:51 chen… QCWo… ife?… 9 3
#> 4 Positive 569 2009-06-07 21:38:16 kind… rach… @lon… 8 2
#> 5 Positive 2546 2009-06-08 00:13:48 kind… k8tb… " lo… 7 1
#> 6 Positive 1019 2009-05-11 05:21:25 lebr… unde… atch… 3 1
#> 7 Negative 2110 2009-05-18 01:14:35 Malc… blin… @por… 7 3
#> 8 Positive 256 2009-05-27 23:59:18 goog… maex… " am… 3 1
#> 9 Negative 413 2009-06-02 03:17:04 time… Jaso… " ha… 11 4
#> 10 Positive 1003 2009-05-11 03:18:59 kind… Happ… y Ki… 1 0
#> # … with 344 more rows, and 6 more variables: prepositions <int>,
#> # articles <int>, pronouns <int>, verbs <int>, adverbs <int>,
#> # interjections <int>
#>
#> $predictions
#> # A tibble: 354 x 15
#> polarity id date query user text nouns adjectives
#> <dbl> <int> <dttm> <chr> <chr> <chr> <int> <int>
#> 1 1 217 2009-05-25 17:29:39 mcdo… Mami… mgg … 7 2
#> 2 1 2140 2009-05-20 02:38:17 nike Chet… ew n… 4 2
#> 3 0 224 2009-05-25 17:34:51 chen… QCWo… ife?… 9 3
#> 4 1 569 2009-06-07 21:38:16 kind… rach… @lon… 8 2
#> 5 1 2546 2009-06-08 00:13:48 kind… k8tb… " lo… 7 1
#> 6 1 1019 2009-05-11 05:21:25 lebr… unde… atch… 3 1
#> 7 0 2110 2009-05-18 01:14:35 Malc… blin… @por… 7 3
#> 8 1 256 2009-05-27 23:59:18 goog… maex… " am… 3 1
#> 9 0 413 2009-06-02 03:17:04 time… Jaso… " ha… 11 4
#> 10 1 1003 2009-05-11 03:18:59 kind… Happ… y Ki… 1 0
#> # … with 344 more rows, and 7 more variables: prepositions <int>,
#> # articles <int>, pronouns <int>, verbs <int>, adverbs <int>,
#> # interjections <int>, pred_polarity[,1] <int>
#>
#> $confusion_matrix
#> # A tibble: 4 x 3
#> polarity pred_polarity count
#> <fct> <fct> <int>
#> 1 0 0 110
#> 2 0 1 65
#> 3 1 0 48
#> 4 1 1 131
#>
#> $true_negative
#> [1] 110
#>
#> $true_positive
#> [1] 131
#>
#> $false_positive
#> [1] 65
#>
#> $false_negative
#> [1] 48
#>
#> $precision
#> [1] 0.6683673
#>
#> $recall
#> [1] 0.7318436
#>
#> $f1
#> [1] 0.6986667
#>
#> $accuracy
#> [1] 0.680791
#>
#> $plot
predict_polarity_keras(model_load_path = system.file("extdata",
"train_glove_conv_1d.rds",
package = "deepSentimentR",
mustWork = TRUE))
#> $raw
#> # A tibble: 354 x 14
#> polarity id date query user text nouns adjectives
#> <chr> <int> <dttm> <chr> <chr> <chr> <int> <int>
#> 1 Positive 217 2009-05-25 17:29:39 mcdo… Mami… mgg … 7 2
#> 2 Positive 2140 2009-05-20 02:38:17 nike Chet… ew n… 4 2
#> 3 Negative 224 2009-05-25 17:34:51 chen… QCWo… ife?… 9 3
#> 4 Positive 569 2009-06-07 21:38:16 kind… rach… @lon… 8 2
#> 5 Positive 2546 2009-06-08 00:13:48 kind… k8tb… " lo… 7 1
#> 6 Positive 1019 2009-05-11 05:21:25 lebr… unde… atch… 3 1
#> 7 Negative 2110 2009-05-18 01:14:35 Malc… blin… @por… 7 3
#> 8 Positive 256 2009-05-27 23:59:18 goog… maex… " am… 3 1
#> 9 Negative 413 2009-06-02 03:17:04 time… Jaso… " ha… 11 4
#> 10 Positive 1003 2009-05-11 03:18:59 kind… Happ… y Ki… 1 0
#> # … with 344 more rows, and 6 more variables: prepositions <int>,
#> # articles <int>, pronouns <int>, verbs <int>, adverbs <int>,
#> # interjections <int>
#>
#> $predictions
#> # A tibble: 354 x 15
#> polarity id date query user text nouns adjectives
#> <dbl> <int> <dttm> <chr> <chr> <chr> <int> <int>
#> 1 1 217 2009-05-25 17:29:39 mcdo… Mami… mgg … 7 2
#> 2 1 2140 2009-05-20 02:38:17 nike Chet… ew n… 4 2
#> 3 0 224 2009-05-25 17:34:51 chen… QCWo… ife?… 9 3
#> 4 1 569 2009-06-07 21:38:16 kind… rach… @lon… 8 2
#> 5 1 2546 2009-06-08 00:13:48 kind… k8tb… " lo… 7 1
#> 6 1 1019 2009-05-11 05:21:25 lebr… unde… atch… 3 1
#> 7 0 2110 2009-05-18 01:14:35 Malc… blin… @por… 7 3
#> 8 1 256 2009-05-27 23:59:18 goog… maex… " am… 3 1
#> 9 0 413 2009-06-02 03:17:04 time… Jaso… " ha… 11 4
#> 10 1 1003 2009-05-11 03:18:59 kind… Happ… y Ki… 1 0
#> # … with 344 more rows, and 7 more variables: prepositions <int>,
#> # articles <int>, pronouns <int>, verbs <int>, adverbs <int>,
#> # interjections <int>, pred_polarity[,1] <int>
#>
#> $confusion_matrix
#> # A tibble: 4 x 3
#> polarity pred_polarity count
#> <fct> <fct> <int>
#> 1 0 0 103
#> 2 0 1 72
#> 3 1 0 42
#> 4 1 1 137
#>
#> $true_negative
#> [1] 103
#>
#> $true_positive
#> [1] 137
#>
#> $false_positive
#> [1] 72
#>
#> $false_negative
#> [1] 42
#>
#> $precision
#> [1] 0.6555024
#>
#> $recall
#> [1] 0.7653631
#>
#> $f1
#> [1] 0.7061856
#>
#> $accuracy
#> [1] 0.6779661
#>
#> $plot