Learn to use an Artificial Intelligence Model in 30 Minutes or Less (Part 1)

Source: Artificial Intelligence on Medium

Learn to use an Artificial Intelligence Model in 30 Minutes or Less (Part 1)

Artificial Intelligence, or AI, has become one of the biggest buzzwords of the 21st century. Whether ‘AI’ makes you think of kombucha-sipping, flannel-adorned startups, or an Arnold Schwarzenneger-shaped robot kicking down your door, you’re probably curious about what Artificial Intelligence models are, how they’re used, and what they’re used for.

What is AI?

In a nutshell, the field of Artificial Intelligence refers to the study of any computer system, software, or device that aims to mimic or display the qualities of human-like intelligence. David Poole, Alan Mackworth, and Randy Goebel put forward one of the earliest, and in my opinion best, definitions in 1998:

[Artificial Intelligence] is the study of the design of intelligent agents. An agent is something that acts in an environment — it does something. Agents include worms, dogs, thermostats, airplanes, humans, organizations, and society. An intelligent agent is a system that acts intelligently: What it does is appropriate for its circumstances and its goal, it is flexible to changing environments and changing goals, it learns from experience, and it makes appropriate choices given perceptual limitations and finite computation.

There are numerous principles and approaches examined in the field of AI, but the most common, which is what we’ll be using later, is the concept of machine learning.

Ordinarily, when a developer creates a program, they give the computer explicit instructions on how to carry out each step of the process, in order to achieve a desired result. For simpler programs, this can be incredibly easy, but there are a variety of applications in which this process becomes incredibly tedious or in-feasibly complex.

Machine learning takes a different approach. When creating a machine learning program, a developer creates a set of ‘rules’ for the computer to operate under. Then, the developer feeds the computer a large set of problems for it to solve, along with the solution to each respective problem. This set of problems and solutions is called the ‘training dataset.’ The computer then makes associations to create methods which would allow it to reach each solution for each problem, all while operating within the previously defined rules. A large and focused training dataset will result in a more capable end program, while a small or unfocused dataset might lead to an incapable or overgeneralized program.

Deep learning is an extension of the concept of machine learning. In deep learning, there are multiple ‘levels’ of training datasets used. The first training dataset will offer an underlying set of problems, with partial or simplistic solutions. The second training dataset will use those solutions as problems, and will offer a ‘deeper’ layer of more complete or complex solutions. Successive layers can get even more complete or complex, adding more ‘depth’ to the model until it has reached an acceptable degree of accuracy.

In order to explore the applications of machine learning, specifically deep learning, we’ll be working with IBM’s Watson AI platform.

Watson is arguably the most well known real-world AI, gaining its fame through its staggering Jeopardy! performance in 2011. Today marks the ninth anniversary of this achievement, and in the years since, Watson has expanded into a massive, easily accessible platform for professionals and researchers to incorporate artificial intelligence into their work.

We’ll be using the Watson Natural Language Understanding product from IBM.

Watson Natural Language Understanding showcases the AI concept of natural language processing (NLP). NLP refers to the interactions between computers and ‘natural language,’ or language as humans speak it (as opposed to how we’re ‘supposed’ to speak it under the rules of grammar and usage).

IBM has utilized data sets containing millions of sentences and phrases along with their associated concepts, sentiments, and more in order to generate a robust program. IBM has made this program 100% free, and easily accessible for the general public!

Let’s Get Started


We’ll start with heading to https://cloud.ibm.com/login. Over on the left side, you’ll see a button labeled ‘Create an IBM Cloud account.’ Go ahead and select it, then follow the steps to create a free account for the IBM Cloud. You’ll have to verify your account with the email you used to sign up.


Once you have your account, head back to https://cloud.ibm.com/login, and login. You’ll have to accept IBM’s terms and conditions before you’re allowed to enter. Now you’ll see your dashboard for IBM Cloud. Here, IBM allows users to access a number of services and resources for a variety of applications.


In the top left of your dashboard, you should see a panel titled ‘Resource Summary.’ Within this panel, there should be a small button labeled ‘Create +.’ Press it to create a storage resource.

A storage resource is a portion of IBM’s servers dedicated to hosting your services.


After pressing the ‘Create +’ button, you’ll be taken to IBM’s catalog. On the left side, under the list of categories, you’ll see an entry called ‘Storage.’ Select that, then select the ‘Object Storage’ service.


The ‘Lite’ pricing plan should be selected for you, it’s 100% free, so go ahead and press the ‘Create’ button.


On the Cloud Object Storage page, you’ll be given the option to create a ‘bucket.’ A bucket is what holds your data within the server. Press the ‘Create Bucket’ button.


IBM offers users the option to really personalize their data storage, but we won’t need anything advanced. Select the ‘Standard’ option under ‘Predefined Buckets.’


We won’t have to change anything from IBM’s default selections, upload any files, or set up a Test Bucket, so go ahead and hit ‘Next’ until you’re finished with creating the bucket.

There’s a small chance you’ll get an error message here when naming your bucket. Sometimes, IBM doesn’t automatically assign a unique name, so if you get this error just add a few random characters to the end of the bucket until you can move on to the next step. The name of the bucket isn’t all that important for our purposes.


Once you’ve finished, select the ‘IBM Cloud’ text in the top left corner to return to the dashboard.


Now we’re going to set up our AI service. Select the ‘Create Resource’ button.


This time, on the left side under categories, select the ‘AI’ category. Then, scroll down the services options until you see ‘Natural Language Understanding,’ and select it.


Once again the ‘Lite’ plan should be selected for you, so hit ‘Create’ on the right side panel.


Congratulations! You now have your Artificial Intelligence resource set up. IBM has done the hard work of training a computer to recognize and process human language, we’ll be learning how to use this existing model.


Select ‘Manage’ on the left side panel.


Here you’ll see the credentials for your Natural Language Understanding service. This is essentially how IBM knows to identify your specific instance if their product. The URL shown is essentially the address of where your Natural Language Understanding resource is located, and the API Key is effectively a ‘password’ that tells IBM’s servers to allow you to access the resource.


Make sure to save this information somewhere! We’ll need it soon!


Now, we’re going to be leaving our web browser and heading to our file manager. That’ll be File Explorer on a Windows machine, or Finder on a Mac. In your Documents folder, create a new folder to hold the files for using your AI model.

As you can see, I’ve named my folder ‘LearningAI,’ but feel free to choose something different.


Now, we’re going to make a couple scripts to utilize the AI model we’ve provisioned from IBM. Even if you don’t have much background in working with computers, I’ll try to make it as easy as possible to follow along.


The first script we’re going to make is going to analyze the language in an article we find online. Head over to https://medium.com, or any other news source you enjoy, and select an article that interests you. For reference, here is the article I used. It may be easier to follow along exactly, but feel free to choose a different article if you’d like.


That’s it for part 1! The following steps will be different if you’re on Windows or macOS, so click the link to head to part 2 where we’ll start using the AI model.

Part 2: Windows

Part 2: macOS