AI In Your Windows Phone Apps pt 3 – Psycho-Analyzing People You Hate On Twitter

Let’s Review Shall We

In parts 1 and 2 we went over the process of signing up for a free IBM Bluemix account, creating an app, and adding the Watson Question and Answer service to the app. We then built a Windows Phone 8.1 XAML app that consumes the Watson REST service and provides you with answers to your healthcare and travel-related questions. If you haven’t read them yet, or just want a little refresher, you can read Part 1 and Part 2 now and/or check out the full source.  We’ll wait…

Everyone’s a Shrink… Or Needs a Shrink

Today, we are going to explore the Watson User Modeling service. As you might deduce from the name, this service allows you to analyze personality traits for somebody based on digital communications. More specifically, from the documentation found here:

The service uses linguistic analytics to extract cognitive and social characteristics, including Big Five personality, values, and needs, from text. These insights help businesses to understand their clients’ preferences and improve customer satisfaction by anticipating customer needs and recommending the next best actions. This allows businesses to improve client acquisition, retention, and engagement, and to strengthen relations with their clients.

The documentation talks a lot about how you can use this data to gain insights into your customers, understand your customers, market to your customers, blah, blah, blah. I don’t know about you, but I don’t really have any customers, so I’m going to use this service to create profiles of random people on Twitter.

Signup for your IBM Bluemix account

Service Me Watson

Instead of completely repeating parts 1 and 2, I am just going to tell you that you need to repeat the same steps we took there to add the User Modeling service to our Bluemix app and make a note of our service credentials. Then we are going to use Fiddler again to create a post request to the /systemu/service/api/v2/profile service. The only difference here will be the content of the request. The profile service expects something like the following:

CaptureIt is also important to note that the service will not analyze your request unless the content contains at least 100 (and preferably 2000) words. Once we have a JSON response, we are going to let Web Essentials and the “Paste JSON as Classes” functionality do the hard work of creating a response model class for us.

Signup for your IBM Bluemix account

Analyze This

So let’s take a closer look at the kind of data the user modeling service will give us. The User Modeling service extracts three types of personal characteristics from the text that is passed to it:

  1. Big 5 Personality: This is the most used personality model, describing how a person generally interacts with the world through the following traits:
    • Openness-to-Experience: Associated with curiosity, intellect, and an appreciation for art and adventure.
    • Conscientiousness: Associated with organization and industriousness.
    • Extraversion: Associated with positive and outgoing attitudes toward other people.
    • Agreeableness: Associated with compassion and cooperation toward other people.
    • Neuroticism: Associated with a sensitivity to negative emotions.
  2. Basic Human Values: This model describes factors that influence a person’s decision-making. Currently the model includes five dimensions based on Schwartz’s work in psychology:
    • Self-Transcendence: Motivated by helping others.
    • Self-Enhancement: Motivated by increasing social status.
    • Hedonism: Motivated by pleasurable experiences.
    • Openness-to-Change: Motivated by experiencing new things in the world.
    • Conservation: Motivated by tradition and conformity.
  3. Fundamental Human Needs: This model is based on Maslow’s hierarchy of needs. It tries to describe which aspects of a product will appeal most to a person.
    • Ideal: The person likes high-end, finely crafted products.
    • Self-Expression: The person likes products that help them establish closer relationships with family and friends.
    • Closeness: The person likes products that help them establish closer relationships with family and friends.
    • Excitement: The person likes products that provide exciting, adventurous experience.
    • Practicality: The person likes products that simply get the job done.

Signup for your IBM Bluemix account

Your Honor, I Object

The last thing we are going to do in this post is take a closer look at the JSON data that is returned from the service, how the Web Essentials add-in converts that into a C# class, and how we go about deserializing the JSON into our model using

Below is the formatted JSON with all nested properties collapsed:


We can see here the “tree” property – which contains the actual personality models – id, source, word_count_message, and word_count properties.

If we look at our model class we can see the same properties in the generated “RootObject” class:


Expanding the tree property in our JSON, we see we now have id, root, and children properties.


In our generated model, we see a corresponding Tree, Child and Child1 class:


The children property of our Tree class represents each of the three models we discussed above:


Each model then has its own children, again representing the sub-traits mentioned above:


Quite honestly, this is all quite confusing, and you might be thinking that we are not just going to be able to get away with calling JsonConvert.DeserializeObject<UserModelingResponse.RootObject>() to convert this JSON into our model class. That’s what I thought anyway, but I was wrong. JsonConvert.DeserializeObject works just fine here and that cuts about 3 paragraphs and 2 pictures from the length of this post.

In the next post we will update our Windows Phone app to allow for searching for a Twitter username and analyzing their recent posts using the User Modeling service.

Signup for your IBM Bluemix account



About Andrew Long

Web developer, Windows Phone developer:, IBM Bluemix Evangelist:
This entry was posted in Windows Phone, Windows Universal, WP8 and tagged , , , , , , . Bookmark the permalink.

1 Response to AI In Your Windows Phone Apps pt 3 – Psycho-Analyzing People You Hate On Twitter

  1. Jan Bergmans says:

    Reblogged this on A Dialogue Of One and commented:
    Part 3

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s