Skip to content

Instantly share code, notes, and snippets.

@andrewheiss
Created August 29, 2018 19:36
Show Gist options
  • Save andrewheiss/ab11fb6318f439e2f452c8a1edee7364 to your computer and use it in GitHub Desktop.
Save andrewheiss/ab11fb6318f439e2f452c8a1edee7364 to your computer and use it in GitHub Desktop.
library(tidyverse)
library(kerasformula)
library(textfeatures)
tweets <- read_csv("https://raw.githubusercontent.com/fivethirtyeight/russian-troll-tweets/master/IRAhandle_tweets_1.csv",
n_max = 25000) %>%
mutate(text = content)
features <- textfeatures(tweets, threads = 2)
tweets_features <- bind_cols(tweets, features)
russian_trolls <- kms(account_category ~
following + followers + language + retweet +
n_urls + n_hashtags + n_mentions + n_chars + n_commas +
n_digits + n_exclaims + n_extraspaces + n_lowers + n_lowersp +
n_periods + n_words + n_caps + n_nonasciis + n_puncts +
n_capsp + n_charsperword + sent_afinn + sent_bing +
n_polite + n_first_person + n_first_personp +
n_second_person + n_second_personp + n_third_person +
n_tobe + n_prepositions,
N_layers = 3, data = tweets_features, seed = 123)
russian_trolls$evaluations$acc
#> [1] 0.8706308
plot_confusion(russian_trolls)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment