Predicting Personality Traits from Content Using IBM Watson
Would you like to know what your customers want before they do?
Of course. Every business wants to be able to anticipate the needs of their customers.
And that starts by understanding customers in a deep and meaningful way.
Unfortunately, that is getting harder and harder in our digital world…
- Consumers are increasingly less trusting and loyal
- Consumers have more power — thanks to social media, online shopping comparisons, and a ever-growing list of choices
- With all the noise out there, it has become increasingly difficult to get an accurate view of your customers
- Consumer mindsets are shifting from product ownership to experience due to economic uncertainty and information overload
All of this certainly highlights the need to create a more compelling customer experience to stay relevant.
”Customer experience is the new competitive battlefield.”
But to stay close to this new digital consumer, you really need to get a view into their mind.
Fortunately, artificial intelligence is stepping up to the challenge. Giving you the ability to turn all those digital transformations into digital advantage.
We can use an A.I. platform to instantly analyze and predict the values, needs and behaviors of your customers. A platform which can provide a wide range of uses — from precision marketing to product recommendations to ultra-personalized emails.
So let’s build one!
This application (originally developed by IBM’s Watson Developer Cloud) uses a content analysis service to analyze social media content and provide you with insights about the personality traits of the content’s author.
Want to see some source code? Here’s our fork of the application on GitHub.
- Step 1: Requirements
- Step 2: Create the Application Container
- Step 3: Create the Personality Insights Instance
- Step 4: Create the Twitter App
- Step 5: Fire it Up!
Let’s get to it…
The end result
By following the steps in this guide, you’ll create an application similar to the following.
Here’s a live preview.
The application currently supports two content sources:
- Custom content — Copy/paste any type of text content
- Twitter stream — Classification of tweets in a particular account
It even gives you a nice visual with the results…
And of course, this is just the beginning — the application can be extended in any number of different ways. The only limit is your imagination.
How it works.
The application analyzes content and intelligently analyzes the core topics and tone of the content, then predicts personality traits of the author based on that analysis.
And it uses one cloud-based service from IBM Watson:
- Personality Insights — Classifies the content and makes a prediction for the corresponding personality traits
Step 1: Requirements
Before we create the Watson service, let’s get the system requirements covered.
Download the source repository.
To start, go ahead and download the source files.
Note: You’ll need a git client installed on your computer for this step.
Simply move to the directory you want to use for this demo and run the following commands in a terminal:
# Download source repository
git clone https://github.com/10xNation/ibm-watson-personality-insights.git
At this point, you can keep the terminal window open and set it aside for now…we’ll need it in a later step.
Name the application.
Right away, let’s nail down a name for your new app:
# Application name
- name: xxxxxxxxxxxxxxx
xxxxxxxxxxxxxxx in the
manifest.yml file with a globally unique name for your instance of the application.
The name you choose will be used to create the application’s URL — eg. http://personality-insights-587854.mybluemix.net/.
Create a Bluemix account.
Go to the Bluemix Dashboard page (Bluemix is IBM’s cloud platform).
If you don’t already have one, create a Bluemix account by clicking on the “Sign up” button and completing the registration process.
A few of the steps in this guide require a command line session, so you’ll need to install the Cloud-foundry CLI tool.
Open a terminal session with Bluemix.
Once the Cloud-foundry CLI tool is installed, you’ll be able to log into Bluemix through the terminal:
Note: Feel free to use the same terminal window as above.
# Log into Bluemix
cf api https://api.ng.bluemix.net
cf login -u YOUR_BLUEMIX_ID -p YOUR_BLUEMIX_PASSOWRD
YOUR_BLUEMIX_PASSOWRD with the respective username and password you created above.
Step 2: Create the Application Container
Go to the Bluemix Dashboard page.
Once you’re signed in and see your Dashboard, click on the “Create app” button.
In this demo, we’ll be using a Node application, so click on “SDK for Node.js.”
Then fill out the information required, using the application name you chose in step #1 — and hit the “Create” button.
Set the application memory.
Let’s give your application a little more memory to work with.
Click on your new application.
Then click on the “plus” sign for “MB MEMORY PER INSTANCE” — set it to 512 — then hit “Save.”
That’s it for the application container, so let’s move onto the service instance.
Step 3: Create the Personality Insights Instance
To set up the Personality Insights service, go back to your Bluemix Dashboard page.
Then click on your application.
And that should take you to the Overview section of your application dashboard. Since this is a brand new application, you should see a “Create new” button in the Connections widget — click that button.
You should now see a long list of services. Click “Watson” in the Categories filter and then click on “Personality Insights” to create a new instance of that service.
Go ahead and choose a Service Name that makes sense for you — eg.
Personality Insights-Demo. For this demo, the “Lite” Pricing Plan will do just fine. And by default, you should see your application’s name listed in the “Connected to” field.
Click the “Create” button when ready. And If needed, update the Service Name you chose in the
# Service name
- Personality Insights-Demo
Personality Insights-Demo with your chosen Service Name.
Feel free to “Restage” your application when prompted.
Enter service credentials.
After your Personality Insights instance is created, click on the respective “View Credentials” button.
And that will pop up a modal with your details.
Copy/paste your Personality Insights service username and password into the
# Service credentials
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx with your username and
xxxxxxxxxxxx with your password.
Your Personality Insights service is now ready, so let’s move onto Twitter.
Step 4: Create the Twitter App
Go to the Twitter Apps home page.
Log in with the Twitter user account you plan to use with your new app.
After logging in you should see a “Create New App” button…click it.
Enter a globally unique name for your Twitter application, a brief description, and the URL to your website.
Click on the “Keys and Access Tokens” tab.
Copy/paste your credentials into the
# Twitter credentials
xxxxxxxxxxxxxxxxxxxxxxxxx with your consumer key and
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx with your consumer secret.
Step 5: Fire it Up!
That’s it for the hard stuff. So let’s put this app to work.
Launch the application.
To bring the application to life, simply run the following command — making sure the terminal is in the repository directory and logged into Bluemix:
This command will upload the files, configure your new application and start it.
Note: You can use the
cf push command to update the same application after it’s originally published.
Take a look.
After the server has started, you’ll be able to open the application in your browser at the respective URL.
The application should look something like this…
Play around with it and get a feel for the functionality.
If you’re having any problems with the application, be sure to check out the logs…
Just click on the “Logs” link within your application dashboard.
Take it to the Next Level
But this is just a start. The real power comes when you apply this type of analysis across all your customers’ content and brand interactions — giving you an insightful view into their thinking and habits.
How will you build on this web service? Run it separately — or better yet — integrate it with your existing marketing and hiring tools (CRM, social media automation, etc.).
And currently, you can make 1,000 API calls per month for free — so go ahead and just start playing with it!
You can dig deeper into the entire suite of Watson APIs in the IBM Watson Developer Community.
- Building Voice-Enabled Products With Amazon Alexa
- Cognitive Customer Engagement Using IBM Watson
- Harnessing Visual Data Using Google Cloud
- Building a Recommendation Engine Using Microsoft Azure
- Predicting Marketing Campaign Response Using Amazon Machine Learning
- Unleashing A.I.-Powered Conversation With IBM Watson
- Get into the Mind of Your Customer Using Google’s Sentiment Analysis Tools
- Discover Your Customers’ Deepest Feelings Using Microsoft Facial Recognition
- Give Your Products the Power of Speech Using Amazon Polly
- Computers Are Opening Their Eyes — and They’re Already Better at Seeing Than We Are
- How to Predict When You’re Going to Lose a Subscriber
- The Future of Business is a Digital Spokesperson — Let’s Build a Preview Using Microsoft’s Bot Framework
And be on the lookout for future issues, they come out every other Monday.