AI with Python

AI with Python


Artificial intelligence  (AI) with Python  Tutorial

Artificial intelligence (AI) is the intelligence demonstrated by machines, in contrast to the intelligence displayed by humans.

This tutorial covers the basic concepts of various fields of artificial intelligence like Artificial Neural Networks, Natural Language Processing, Machine Learning, Deep Learning, Genetic algorithms etc., and its implementation in Python.

This tutorial will be useful for graduates, post graduates, and research students who either have an interest in this subject or have this subject as a part of their curriculum. The reader can be a beginner or an advanced learner.

We assume that the reader has basic knowledge about Artificial Intelligence and Python programming. He/she should be aware about basic terminologies used in AI along with some useful python packages like nltk, OpenCV, pandas, OpenAI Gym, etc.


Su T.P.

Copyright © 2020 by Su TP.  All Right Reserved.

Table of Contents

Table of Contents

Chapter 1_ Primer Concept

Chapter 2_ Getting Started

Chapter 3_ Machine Learning

Chapter 4_ Data Preparation

Chapter 5_ Supervised Learning: Classification

Chapter 6_ Supervised Learning: Regression

Chapter 7_ Logic Programming

Chapter 8_ Unsupervised Learning: Clustering

Chapter 9_ Natural Language Processing

Chapter 10_ NLTK Package

Chapter 11_ Analyzing Time Series Data

Chapter 12_ Speech Recognition

Chapter 13_ Heuristic Search

Chapter 14_ Gaming

Chapter 15_ Neural Networks

Chapter 16_ Reinforcement Learning

Chapter 17_ Genetic Algorithms

Chapter 18_ Computer Vision

Chapter 19_ Deep Learning

Chapter 1_ Primer Concept

Chapter 1_ Primer Concept


Since the invention of computers or machines, their capability to perform various tasks has experienced an exponential growth. Humans have developed the power of computer systems in terms of their diverse working domains, their increasing speed, and reducing size with respect to time.

A branch of Computer Science named Artificial Intelligence pursues creating the computers or machines as intelligent as human beings.

Basic Concept of Artificial Intelligence (AI)

According to the father of Artificial Intelligence, John McCarthy, it is “The science and engineering of making intelligent machines, especially intelligent computer programs”.

Artificial Intelligence is a way of making a computer, a computer-controlled robot, or a software think intelligently, in the similar manner the intelligent humans think. AI is accomplished by studying how human brain thinks and how humans learn, decide, and work while trying to solve a problem, and then using the outcomes of this study as a basis of developing intelligent software and systems.

While exploiting the power of the computer systems, the curiosity of human, lead him to wonder, “Can a machine think and behave like humans do?”

Thus, the development of AI started with the intention of creating similar intelligence in machines that we find and regard high in humans.

The Necessity of Learning AI

As we know that AI pursues creating the machines as intelligent as human beings. There are numerous reasons for us to study AI. The reasons are as follows −

AI can learn through data

In our daily life, we deal with huge amount of data and human brain cannot keep track of so much data. That is why we need to automate the things. For doing automation, we need to study AI because it can learn from data and can do the repetitive tasks with accuracy and without tiredness.

AI can teach itself

It is very necessary that a system should teach itself because the data itself keeps changing and the knowledge which is derived from such data must be updated constantly. We can use AI to fulfill this purpose because an AI enabled system can teach itself.

AI can respond in real time

Artificial intelligence with the help of neural networks can analyze the data more deeply. Due to this capability, AI can think and respond to the situations which are based on the conditions in real time.

AI achieves accuracy

With the help of deep neural networks, AI can achieve tremendous accuracy. AI helps in the field of medicine to diagnose diseases such as cancer from the MRIs of patients.

AI can organize data to get most out of it

The data is an intellectual property for the systems which are using self-learning algorithms. We need AI to index and organize the data in a way that it always gives the best results.

Understanding Intelligence

With AI, smart systems can be built. We need to understand the concept of intelligence so that our brain can construct another intelligence system like itself.

What is Intelligence?

The ability of a system to calculate, reason, perceive relationships and analogies, learn from experience, store and retrieve information from memory, solve problems, comprehend complex ideas, use natural language fluently, classify, generalize, and adapt new situations.

Types of Intelligence

As described by Howard Gardner, an American developmental psychologist, Intelligence comes in multifold −


Intelligence & Description



Linguistic intelligence

The ability to speak, recognize, and use mechanisms of phonology (speech sounds), syntax (grammar), and semantics (meaning).

Narrators, Orators


Musical intelligence

The ability to create, communicate with, and understand meanings made of sound, understanding of pitch, rhythm.

Musicians, Singers, Composers


Logical-mathematical intelligence

The ability to use and understand relationships in the absence of action or objects. It is also the ability to understand complex and abstract ideas.

Mathematicians, Scientists


Spatial intelligence

The ability to perceive visual or spatial information, change it, and re-create visual images without reference to the objects, construct 3D images, and to move and rotate them.

Map readers, Astronauts, Physicists


Bodily-Kinesthetic intelligence

The ability to use complete or part of the body to solve problems or fashion products, control over fine and coarse motor skills, and manipulate the objects.

Players, Dancers


Intra-personal intelligence

The ability to distinguish among one’s own feelings, intentions, and motivations.

Gautam Buddhha


Interpersonal intelligence

The ability to recognize and make distinctions among other people’s feelings, beliefs, and intentions.

Mass Communicators, Interviewers

You can say a machine or a system is artificially intelligent when it is equipped with at least one or all intelligences in it.

What is Intelligence Composed Of?

The intelligence is intangible. It is composed of −

  • Reasoning
  • Learning
  • Problem Solving
  • Perception
  • Linguistic Intelligence

Let us go through all the components briefly −


It is the set of processes that enable us to provide basis for judgement, making decisions, and prediction. There are broadly two types −

Inductive Reasoning

Deductive Reasoning

It conducts specific observations to makes broad general statements.

It starts with a general statement and examines the possibilities to reach a specific, logical conclusion.

Even if all of the premises are true in a statement, inductive reasoning allows for the conclusion to be false.

If something is true of a class of things in general, it is also true for all members of that class.

Example − "Nita is a teacher. Nita is studious. Therefore, All teachers are studious."

Example − "All women of age above 60 years are grandmothers. Shalini is 65 years. Therefore, Shalini is a grandmother."

Learning − l

The ability of learning is possessed by humans, particular species of animals, and AI-enabled systems. Learning is categorized as follows −

Auditory Learning

It is learning by listening and hearing. For example, students listening to recorded audio lectures.

Episodic Learning

To learn by remembering sequences of events that one has witnessed or experienced. This is linear and orderly.

Motor Learning

It is learning by precise movement of muscles. For example, picking objects, writing, etc.

Observational Learning

To learn by watching and imitating others. For example, child tries to learn by mimicking her parent.

Perceptual Learning

It is learning to recognize stimuli that one has seen before. For example, identifying and classifying objects and situations.

Relational Learning

It involves learning to differentiate among various stimuli on the basis of relational properties, rather than absolute properties. For Example, Adding ‘little less’ salt at the time of cooking potatoes that came up salty last time, when cooked with adding say a tablespoon of salt.

  • Spatial Learning − It is learning through visual stimuli such as images, colors, maps, etc. For example, A person can create roadmap in mind before actually following the road.
  • Stimulus-Response Learning − It is learning to perform a particular behavior when a certain stimulus is present. For example, a dog raises its ear on hearing doorbell.

Problem Solving

It is the process in which one perceives and tries to arrive at a desired solution from a present situation by taking some path, which is blocked by


Publisher: BookRix GmbH & Co. KG

Publication Date: 03-26-2020
ISBN: 978-3-7487-3355-3

All Rights Reserved

Next Page
Page 1 /