How to Use IBM Watson Personality Insights to Analyze Personality Using Text:
There is a huge literature on how people's personality affects their decisions. Most prior papers use personality test or interviews to infer personality. Problem? Very costly. Here, I'll show you how to use IBM Watson Personality Insights to analyze personality using text. Potentially, you can analyze texts from conference calls, analyst reports, journalists, etc.
What is IBM Watson?
IBM Watson is a technology platform that uses natural language processing and machine learning to reveal insights from large amounts of unstructured data. See video from IBM.
What is Personality Insights?
Personality Insights extracts and analyzes a specturm of personality attributes to help discover actionable insights about people and entities, and in turn guides end users to highly personalized interactions. The service outputs personality characteristics that are divided into three dimensions: the Big 5, Values, and Needs.
Link to a Demo of Personality Insights
Link to How it Works
Link to Detailed Documentation from IBM
How to use it?
You need to call the service by posting the content to be analyzed to the service's API. The service returns output that provides insight into the personality characteristics of the authors of the input text. The service reports a percentile and a sampling error for each characteristics it analyzes. The percentile is based on a corpus of more than a quarter of a million Twitter users. Optionally, it can also report a raw score and a raw sampling error if quested. See here for details.
Detailed Procedures
There are three steps. First, install Python as my code is written in Python. Second, you will need to register an account at IBM Bluemix (a cloud platform for building, running and managing apps). This will give you an IBM Watson Developer Cloud credential to access the services. Third, format the input text.
Step 1: install Python:
a. Install the latest Python 2.* (currently 2.7.13) Note: do not install Python 3.*, Python 3 is not backward compatible with 2.*
b. Install Conda, a package manager and an environment manager application. You only need the simple version (Miniconda). You can download it here.
c. Create a new environment with Conda, activate it and install packages. Run the following commands under command line.
conda create -n personality python
activate personality
conda install pandas
conda install requests
Note: You can use any name for the environment, I use personality. Pandas and requests are two Python modules the code needs.
Step 2: Register an account at IBM Bluemix
You can follow the video here or steps here or following the following steps:
a. Go to https://console.ng.bluemix.net/ and sign up for an account.
b. After you login using your account, click the icon on the upper right corner (account and support), and change the Region (I use US South).
c. On the left panel, Create a Space (you can choose any name, for example, personality).
d. Choose Services & APIs, then Personality Insights. Click CREATE on the right panel.
e. Click Service Credentials on the left panel to view your username and password.
f. Modify the python code, replace the username and password with your own credential.
Step 3: For your input text
a. Save the code (personality_insights.py, you will need to change the extension of the downloaded file from .txt to .py) file under a folder (I'll use D:\personality as an example)
b. Create a new folder under D:\personality, for example "sentence".
c. Structure your input files as tab delimiter text files.
I use the following SAS code to create such files:
PROC EXPORT DATA = output
OUTFILE = "D:\personality\sentence\sample.txt"
DBMS = TAB REPLACE;
RUN;
d. All input files (you can have multiple ones) should be in same directory, in this case D:\personality\sentence\
e. Navigate to the directory with the python code under command line.
f. Run the Python code.
python personality_insights.py sentence
Note: Before you run the code, make sure the conda environment is activated. If it's not, activate it by running this:
activate personality
g. The Python program will create a directory named "output" to store the output files. Each input file will have its own output file with the same name.
There is a huge literature on how people's personality affects their decisions. Most prior papers use personality test or interviews to infer personality. Problem? Very costly. Here, I'll show you how to use IBM Watson Personality Insights to analyze personality using text. Potentially, you can analyze texts from conference calls, analyst reports, journalists, etc.
What is IBM Watson?
IBM Watson is a technology platform that uses natural language processing and machine learning to reveal insights from large amounts of unstructured data. See video from IBM.
What is Personality Insights?
Personality Insights extracts and analyzes a specturm of personality attributes to help discover actionable insights about people and entities, and in turn guides end users to highly personalized interactions. The service outputs personality characteristics that are divided into three dimensions: the Big 5, Values, and Needs.
Link to a Demo of Personality Insights
Link to How it Works
Link to Detailed Documentation from IBM
How to use it?
You need to call the service by posting the content to be analyzed to the service's API. The service returns output that provides insight into the personality characteristics of the authors of the input text. The service reports a percentile and a sampling error for each characteristics it analyzes. The percentile is based on a corpus of more than a quarter of a million Twitter users. Optionally, it can also report a raw score and a raw sampling error if quested. See here for details.
Detailed Procedures
There are three steps. First, install Python as my code is written in Python. Second, you will need to register an account at IBM Bluemix (a cloud platform for building, running and managing apps). This will give you an IBM Watson Developer Cloud credential to access the services. Third, format the input text.
Step 1: install Python:
a. Install the latest Python 2.* (currently 2.7.13) Note: do not install Python 3.*, Python 3 is not backward compatible with 2.*
b. Install Conda, a package manager and an environment manager application. You only need the simple version (Miniconda). You can download it here.
c. Create a new environment with Conda, activate it and install packages. Run the following commands under command line.
conda create -n personality python
activate personality
conda install pandas
conda install requests
Note: You can use any name for the environment, I use personality. Pandas and requests are two Python modules the code needs.
Step 2: Register an account at IBM Bluemix
You can follow the video here or steps here or following the following steps:
a. Go to https://console.ng.bluemix.net/ and sign up for an account.
b. After you login using your account, click the icon on the upper right corner (account and support), and change the Region (I use US South).
c. On the left panel, Create a Space (you can choose any name, for example, personality).
d. Choose Services & APIs, then Personality Insights. Click CREATE on the right panel.
e. Click Service Credentials on the left panel to view your username and password.
f. Modify the python code, replace the username and password with your own credential.
Step 3: For your input text
a. Save the code (personality_insights.py, you will need to change the extension of the downloaded file from .txt to .py) file under a folder (I'll use D:\personality as an example)
b. Create a new folder under D:\personality, for example "sentence".
c. Structure your input files as tab delimiter text files.
I use the following SAS code to create such files:
PROC EXPORT DATA = output
OUTFILE = "D:\personality\sentence\sample.txt"
DBMS = TAB REPLACE;
RUN;
d. All input files (you can have multiple ones) should be in same directory, in this case D:\personality\sentence\
e. Navigate to the directory with the python code under command line.
f. Run the Python code.
python personality_insights.py sentence
Note: Before you run the code, make sure the conda environment is activated. If it's not, activate it by running this:
activate personality
g. The Python program will create a directory named "output" to store the output files. Each input file will have its own output file with the same name.