Book Image

Cognitive Computing with IBM Watson

By : Rob High, Tanmay Bakshi
Book Image

Cognitive Computing with IBM Watson

By: Rob High, Tanmay Bakshi

Overview of this book

Cognitive computing is rapidly becoming a part of every aspect of our lives through data science, machine learning (ML), and artificial intelligence (AI). It allows computing systems to learn and keep on improving as the amount of data in the system increases. This book introduces you to a whole new paradigm of computing – a paradigm that is totally different from the conventional computing of the Information Age. You will learn the concepts of ML, deep learning (DL), neural networks, and AI with the help of IBM Watson APIs. This book will help you build your own applications to understand, and solve problems, and analyze them as per your needs. You will explore various domains of cognitive computing, such as NLP, voice processing, computer vision, emotion analytics, and conversational systems. Equipped with the knowledge of machine learning concepts, how computers do their magic, and the applications of these concepts, you’ll be able to research and apply cognitive computing in your projects.
Table of Contents (16 chapters)
Title Page
Copyright and Credits
About Packt

Calling the Personality Insights API

Let's start off with initializing a service instance. Just like the Tone Analyzer, there's no need for the Personality Insights service to have any tooling:

  1. We start by importing the API:
from ibm_watson import PersonalityInsightsV3
  1. Then, you simply feed in text after initializing the service:
personality_insights = PersonalityInsightsV3(version="2017-10-13", iam_apikey="W73kz6O3XR1pkIQVn2RYbrrtIU2o0IvNYuqiMICwSwro")
  1. Next, create a file called personality.txt, a simple text file containing the text from which you wish to infer personality traits. Then, you load the contents of that file into the profile_text variable:
profile_text = open("personality.txt").read()
  1. You call the profile function on the personality_insights instance and call get_result() in order to get the JSON output of the service:
profile = personality_insights.profile(profile_text, "text/plain").get_result()
  1. You can then format the output nicely using the following code:
needs = profile["needs...