Content vs. Character

How to read Trump’s Tweets with a computer.

Jonathan Hendler
9 min readNov 3, 2016

Donald Trump is a human being. Doesn’t matter if you feel he is a villain or a hero, because he is neither. There are hundreds of millions of scared, angry people who would act like him if they had power.

Most people can bear adversity. But if you wish to know what a man really is, give him power. This is the supreme test.

What is troubling is a world that willed him into the spotlight. Trump reached millions of vulnerable people. Understanding and fixing the real vulnerabilities is the grand problem of the twenty-first century.

Simpler to understand is the language leaders use and to learn why it works so well. From there, perhaps we can help everyone find truth.

Language is flexible but ancient technology. We communicate abstractions, which leave room for ambiguity. Perhaps we simply do not know what language represents. We fill in the gaps with our imagination. If we believe our imagination too much, we may be loyal to the messenger without examining the truth.

With a platform, language can be exploited at scale.

Loyalty can be earned through language. An abstraction for trust, we defer to loyalty when trust is too hard calculate. We lie to ourselves the most.

Can we separate the language we believe in from the people we believe in?

With humility, perhaps using software to understand politics is lazy, armchair activism. Yet, software is already the foundation of modern participatory democracy.

This summer I did a small project for an Italian company converting the audio of political speeches to text and visualizing the words. Then, I thought about Trump. Why are people entertained by and attracted to Trump‘s language?

Looking at Trump’s language was an obvious project for many software developers. My favorite example is the Twitter bot DeepDrumpf. The results of DeepDrumpf were interesting because the tweets seemed compelling, and perhaps honest.

Entertaining, but this doesn’t explain why Trump sounds like Trump. Understanding Trump Tweets required a contrast. By closely examining language of Obama and Trump on Twitter, I wanted to understand better:

What did Trump followers like about Trump tweets? And, was it different from what Obama followers liked about Obama tweets?

From Twitter I gathered 16,578 Trump tweets and 11,364 for Obama. The tweets span from February 2012 to June 2016.

Here is Obama’s most popular tweet during that time.

Here is Trump’s most popular Tweet during that time.

Counting things

The most basic ability of computers can bring surprises. For example, Trump’s Twitter account had a larger vocabulary than Obama. With unique words (lemmatized), Trump had 25,659 (1.3 average per tweet) and Obama had 8,988 (0.79 average per tweet). In verbs Trump led 2 to 1, adjectives 2.5 to 1, and nouns 3.2 to 1.

A large vocabulary is useful for entertainment and marketing. Also, it can be part of creating a confidence trick of story telling like defeating straw men, misdirection and repetition. In a recent study referenced on the BBC, repetition “makes a fact seem more true, regardless of whether it is or not”.

Trump claimed Obama was not born in the United States about 29 times (searching “birther” or “birth certificate”) .

Obama mentioned it 5 times.

Positioned as an outsider, Trump creates fear and doubt. Doubt is possible because we can not easily know what happens in Washington DC, the Trump Tower, or in a plane crash.

When asked about his claims, he may deny and refuses to apologize. Denial is a form of repetition which works far better from a trusted source because it’s a lot of work to triangulate the truth.

Trump mentioned Putin 50 times or so. Use is meaning.

How many women will need to say Trump groped them before supporters believe the women? Do they trust Trump, the New York Times, or the women?

Aggression towards women is correlated to Trump support. To detect gender tone, I used on a random sample of tweets on Textio.com.

Obama (Left), Trump (Right)

Maybe not a surprising result, except that this differs from what Textio found with longer speeches — which is that Trump was feminine sounding. Perhaps expressing a range of emotions and gender tones builds trust.

The Good Tweet

A basic sentiment analysis tool (trained against movie reviews) found Obama to be 81% positive and Trump to be 70% positive. Sounding positive isn’t the same thing as being getting a large response.

Then I defined a good tweet. A good tweet has the number of favorites or retweets larger than the mean. I gathered stats for 28122 of 30979 total**. Trump had 25% success rate and Obama had a 32% success rate. (**This data certainly has some bot activity, and many tweets are not written by Trump or Obama, but not the extreme use of Trump bots during the 2016 election.)

Did followers like positive sounding tweets? Trumps followers were more interested in negative statements. About 21% of the positive and 24% of the negative were considered good, and Obama’s followers celebrated 33% of the positive and 30% of the negative

What do popular and unpopular tweets look like? These word clouds make words larger the more often they are used.

Good Adjectives (Obama (L), Trump (R))
Bad Adjectives, (Obama (L), Trump (R))

It appears Obama’s tweets were not popular when he mentioned “new” things. Trump was not popular when he claimed something was true, or beautiful, or happy. But there are a number of words found in both good and bad tweets. Sometimes Trump had a hit using Great, sometimes he missed.

Here are uniquely good or bad words (adjectives, verbs, and nouns).

Bad Tweets (Obama (L), Trump (R))
Good Tweets (Obama (L), Trump (R))

Prediction

Avoiding a discussion about free will vs. determinism, not all the world is knowable, so not all of it is predictable. But, most people believe they are not as predictable as they are. Our daily online behavior in words, photos, “likes” and purchases combined with basic facts about human needs, means what can be predicted will be predicted. Stores can be stocked optimally, advertisers can grab your attention, and politicians know what to say to build trust.

To demonstrate a simple example, can the relatively small amount of data used here predict if a tweet will be popular?

Predicting Obama’s successful tweets was 75% accurate (combined precision and recall), and Trump was 86% accurate. (Earlier “Trump had 25% success rate and Obama had a 32% success rate.”) Obama is both harder to predict and has a higher batting average. The accuracy is significant because it’s better than guessing for the more common. In other words, guess that all Trumps tweets would not be popular, and you’d be right 75% of the time. Only using nouns, the accuracy didn’t change. When using only adjectives, the accuracy drops to 68% for Trump, 64% for Obama — a bigger drop for Trump predictability (18% vs. 11%).

Using only parts of speech like verbs, nouns. For example, this tweet…

This vote is a victory for diplomacy … and for the safety and security of the world. — President Obama on the #IranDeal vote

ends up looking like this…

DT NN VBZ DT NN IN NN : CC IN DT NN CC NN IN DT NN . NNP NNP IN DT NN NNP NN

This represents the most basic speech pattern and removed the bias of the larger vocabulary.

The predictability of Obama’s tweets dropped to 60%. For Trumps Tweets, the predictability dropped to 69%. Better results could be obtained by always guessing that a tweet is not popular. However, with Trump, the model for speech patterns was more accurate than the model for Trump’s adjective use.

If we scanned the entire internet and everything ever said, we could increase the machine learning model’s accuracy to the point where software could inspire a politician’s followers more than the politician — only if the audience didn’t know a computer was feeding us.

The digital politician would have no way to enact their speech. If they are optimized for positive reactions among certain demographics, they will say whatever is required to grow and sustain enthusiastic followers. In other words, optimizing for popularity doesn’t have to have any correlation to truth or indicate what will happen.

Perhaps the more predictably popular the speech, the less honest and creative. Predictability could be an indication of a less accurate representation of reality. It is incredibly difficult to be accurate, scientific, truthful, and popular.

In Conclusion

Loyalty is the currency of business and politics. If the emotions at the root of our loyalty are fear, distrust, or anger, the 2016 election says more about us than our leaders.

Supporters aren’t victims. We’re all susceptible to believing in people because of language. We eventually adopt the truth, but we can be predictably swindled.

No matter who we support, we are all distracted and injured by the creation of fear, confusion, and distrust. The spectacle of personality and language is a distraction from understanding our neighbors and respecting them. Understanding and respect is key to changing their minds.

Software may protect us from online harassment, trolls, and lies better in the future. Until then, even if our voice feels too small, we can choose how we listen and what we hear — and therefore, what we learn.

NOTES

Maine

I grew up in rural Maine. Sometimes involuntarily, we learned to care about our neighbors because of isolation and our shared desire to survive challenging weather and economics.

Maine’s small population creates a microcosm and bellwether of US national politics. In the recent past, they elected Governor Paul LePage. LePage is both a Trump supporter, and an impulsive practitioner of Trump’s language.

Opinion — You know this man

Data

Data used here will be available Github in the form of the raw text of tweets, and an SQLite database of tweets and meta data of likes and retweets.

Word clouds were made with a Python library. For NLP I used spaCy (word vectors, POS tagging) and TextBlob (a wrapper for NLTK sentiment analysis). For machine learning I used SciKit Learn and the deep learning lib Keras, and and other tools like Word2Vec.

Once data is prepared, it takes little code to run a prediction.

import numpy as np
from sklearn.ensemble import AdaBoostClassifier
from sklearn.metrics import classification_report
from timeit import default_timer as timer
def runtest(data):
X = []
y = []
for i, line in enumerate(data):
X.append(line[0])
c = 1.0 if (line[1] == True) else 0.0
y.append(c)
clf = AdaBoostClassifier(n_estimators=500)
text_clf = Pipeline([('vect', CountVectorizer()), ('tfidf', TfidfTransformer()), ('clf', clf),])
skX, skX_test, sk_y, sky_test = train_test_split(X, y, test_size=0.2, random_state=42)
start = timer()
_ = text_clf.fit(array(skX), array(sk_y))
predicted = text_clf.predict(skX_test)
print classification_report(sky_test, predicted)
score = np.mean(predicted == sky_test)
end = timer()
duration = end - start
print "score", score, "duration", duration
return score

The most accurate model was SVM with TF-IDF on preprocessed text.

For part of speech only, the highest results were obtained using ADABoost.

If you are curious about NLP, you could start with Alan Turing, Claude Shannon’s 1950 paper on entropy and redundancy in english , Noam Chomsky, philosophy, or look to leading research institutions and companies for state of the art.

--

--