{"id":13858053,"url":"https://github.com/mkearney/tweetbotornot","last_synced_at":"2025-10-25T21:49:03.508Z","repository":{"id":124080011,"uuid":"121677541","full_name":"mkearney/tweetbotornot","owner":"mkearney","description":"🤖 R package for detecting Twitter bots via machine learning ","archived":false,"fork":false,"pushed_at":"2021-10-20T15:20:25.000Z","size":29042,"stargazers_count":389,"open_issues_count":25,"forks_count":135,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-03-30T04:09:42.148Z","etag":null,"topics":["machine-learning","mkearney-r-package","r","r-package","rstats","rtweet","twitter","twitter-api","twitter-bots"],"latest_commit_sha":null,"homepage":"https://tweetbotornot.mikewk.com","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mkearney.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-02-15T20:13:24.000Z","updated_at":"2025-03-26T10:38:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"d9794cc2-fc15-4a93-999d-a41c02d1c467","html_url":"https://github.com/mkearney/tweetbotornot","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkearney%2Ftweetbotornot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkearney%2Ftweetbotornot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkearney%2Ftweetbotornot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkearney%2Ftweetbotornot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mkearney","download_url":"https://codeload.github.com/mkearney/tweetbotornot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247436490,"owners_count":20938573,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["machine-learning","mkearney-r-package","r","r-package","rstats","rtweet","twitter","twitter-api","twitter-bots"],"created_at":"2024-08-05T03:01:55.225Z","updated_at":"2025-10-25T21:48:58.462Z","avatar_url":"https://github.com/mkearney.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n```{r setup, include=FALSE}\nknitr::opts_chunk$set(echo = TRUE, collapse = TRUE, comment = \"#\u003e\", eval = FALSE)\n```\n\n# tweetbotornot \u003cimg width=\"160px\" src=\"man/figures/logo.png\" align=\"right\" /\u003e \n\n[![lifecycle](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)\n[![Travis build status](https://travis-ci.org/mkearney/tweetbotornot.svg?branch=master)](https://travis-ci.org/mkearney/tweetbotornot)\n[![Coverage status](https://codecov.io/gh/mkearney/tweetbotornot/branch/master/graph/badge.svg)](https://codecov.io/github/mkearney/tweetbotornot?branch=master)\n\nAn R package for classifying Twitter accounts as `bot or not`.\n\n## Features\n\nUses machine learning to classify Twitter accounts as bots or not bots. The **default model** is 93.53% accurate when classifying bots and 95.32% accurate when classifying non-bots. The **fast model** is 91.78% accurate when classifying bots and 92.61% accurate when classifying non-bots. \n\nOverall, the **default model** is correct 93.8% of the time.\n\nOverall, the **fast model** is correct 91.9% of the time.\n\n## Install\n\nInstall from CRAN:\n\n``` r\n## install from CRAN\ninstall.packages(\"tweetbotornot\")\n```\n\n\nInstall the development version from Github:\n\n``` r\n## install remotes if not already\nif (!requireNamespace(\"remotes\", quietly = TRUE)) {\n  install.packages(\"remotes\")\n}\n\n## install tweetbotornot from github\ndevtools::install_github(\"mkearney/tweetbotornot\")\n```\n\n## API authorization\n\nUsers must be authorized in order to interact with Twitter's API. To setup your \nmachine to make authorized requests, you'll either need to be signed into Twitter and working in an interactive session of R–the browser will open asking you to authorize the rtweet client (rstats2twitter)–or you'll need to create an app (and have a developer account) and your own API token. The latter has the benefit of (a) having sufficient permissions for write-acess and DM (direct messages) read-access levels and (b) more stability if Twitter decides to shut down [@kearneymw](https://twitter.com/kearneymw)'s access to Twitter (I try to be very responsible these days, but Twitter isn't always friendly to academic use cases). To create an app and your own Twitter token, [see these instructions provided in the rtweet package](http://rtweet.info/articles/auth.html).\n\n## Usage\n\nThere's one function `tweetbotornot()` (technically there's also `botornot()`, but it does the same exact thing). \nGive it a vector of screen names or user IDs and let it go to work.\n\n```{r}\n## load package\nlibrary(tweetbotornot)\n\n## select users\nusers \u003c- c(\"realdonaldtrump\", \"netflix_bot\",\n  \"kearneymw\", \"dataandme\", \"hadleywickham\",\n  \"ma_salmon\", \"juliasilge\", \"tidyversetweets\", \n  \"American__Voter\", \"mothgenerator\", \"hrbrmstr\")\n\n## get botornot estimates\ndata \u003c- tweetbotornot(users)\n\n## arrange by prob ests\ndata[order(data$prob_bot), ]\n#\u003e # A tibble: 11 x 3\n#\u003e    screen_name     user_id            prob_bot\n#\u003e    \u003cchr\u003e           \u003cchr\u003e                 \u003cdbl\u003e\n#\u003e  1 hadleywickham   69133574            0.00754\n#\u003e  2 realDonaldTrump 25073877            0.00995\n#\u003e  3 kearneymw       2973406683          0.0607 \n#\u003e  4 ma_salmon       2865404679          0.150  \n#\u003e  5 juliasilge      13074042            0.162  \n#\u003e  6 dataandme       3230388598          0.227  \n#\u003e  7 hrbrmstr        5685812             0.320  \n#\u003e  8 netflix_bot     1203840834          0.978  \n#\u003e  9 tidyversetweets 935569091678691328  0.997  \n#\u003e 10 mothgenerator   3277928935          0.998  \n#\u003e 11 American__Voter 829792389925597184  1.000  \n```\n\n### Integration with rtweet\n\nThe `botornot()` function also accepts data returned by [rtweet](http://rtweet.info) functions.\n\n```{r}\n## get most recent 100 tweets from each user\ntmls \u003c- get_timelines(users, n = 100)\n\n## pass the returned data to botornot()\ndata \u003c- botornot(tmls)\n\n## arrange by prob ests\ndata[order(data$prob_bot), ]\n#\u003e # A tibble: 11 x 3\n#\u003e    screen_name     user_id            prob_bot\n#\u003e    \u003cchr\u003e           \u003cchr\u003e                 \u003cdbl\u003e\n#\u003e  1 hadleywickham   69133574            0.00754\n#\u003e  2 realDonaldTrump 25073877            0.00995\n#\u003e  3 kearneymw       2973406683          0.0607 \n#\u003e  4 ma_salmon       2865404679          0.150  \n#\u003e  5 juliasilge      13074042            0.162  \n#\u003e  6 dataandme       3230388598          0.227  \n#\u003e  7 hrbrmstr        5685812             0.320  \n#\u003e  8 netflix_bot     1203840834          0.978  \n#\u003e  9 tidyversetweets 935569091678691328  0.997  \n#\u003e 10 mothgenerator   3277928935          0.998  \n#\u003e 11 American__Voter 829792389925597184  1.000  \n```\n\n### `fast = TRUE`\n\nThe default [gradient boosted] model uses both users-level (bio, location, number of followers and friends, etc.) **and** tweets-level (number of hashtags, mentions, capital letters, etc. in a user's most recent 100 tweets) data to estimate the probability that users are bots. For larger data sets, this method can be quite slow. Due to Twitter's REST API rate limits, users are limited to only 180 estimates per every 15 minutes. \n\nTo maximize the number of estimates per 15 minutes (at the cost of being less accurate), use the `fast = TRUE` argument. This method uses **only** users-level data, which increases the maximum number of estimates per 15 minutes to *90,000*! Due to losses in accuracy, this method should be used with caution!\n\n```{r}\n## get botornot estimates\ndata \u003c- botornot(users, fast = TRUE)\n\n## arrange by prob ests\ndata[order(data$prob_bot), ]\n#\u003e # A tibble: 11 x 3\n#\u003e    screen_name     user_id            prob_bot\n#\u003e    \u003cchr\u003e           \u003cchr\u003e                 \u003cdbl\u003e\n#\u003e  1 hadleywickham   69133574            0.00185\n#\u003e  2 kearneymw       2973406683          0.0415 \n#\u003e  3 ma_salmon       2865404679          0.0661 \n#\u003e  4 dataandme       3230388598          0.0965 \n#\u003e  5 juliasilge      13074042            0.112  \n#\u003e  6 hrbrmstr        5685812             0.121  \n#\u003e  7 realDonaldTrump 25073877            0.368  \n#\u003e  8 netflix_bot     1203840834          0.978  \n#\u003e  9 tidyversetweets 935569091678691328  0.998  \n#\u003e 10 mothgenerator   3277928935          0.999  \n#\u003e 11 American__Voter 829792389925597184  0.999  \n```\n\n\n\n## NOTE\n\nIn order to avoid confusion, the package was renamed from \"botrnot\" to \"tweetbotornot\" in June 2018. This package should not be confused with the [botornot application](http://botornot.co/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkearney%2Ftweetbotornot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmkearney%2Ftweetbotornot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkearney%2Ftweetbotornot/lists"}