HRAnalytics

Chapter 16 Personality insights

The IBM Watson Personality Insights service uses linguistic analysis to extract cognitive and social characteristics from input text such as email, text messages, tweets, forum posts, and more. By deriving cognitive and social preferences, the service helps users to understand, connect to, and communicate with other people on a more personalized level.

We can use communications from a person to analyse their personality.

We first need to be able to talk to Personality Insights. We get most of this information off the IBM site once we’ve made an account.

key = "aOWMNztQ_VVlz9fINhc3v67rtnJqcN6JuubQorAvhq"
url = "https://gateway.watsonplatform.net/personality-insights/api/v3/profile?version=2017-10-13"
uname="a4a4ea65-e8e7-492c-a95e-128f10fc5f"
pword="LuFm4BELs"

We can then talk to the API using the httr package. We can send a body of text to be analysed. The guidance for the API says you should send it more than 600 words to get a robust results.

library(httr)
library(janeaustenr)
cr=POST(url,
    authenticate(uname, pword),
    content_type("text/plain;charset=utf-8"),
    accept_json(),
    body=paste(janeaustenr::emma, collapse = " ")
)
status_code(cr)

We can then visualise the results using the ibmsunburst package.

library(ibmsunburst)
ibmsunburst(content(cr), version = "v3")