Artificial Intelligence With Python 简明教程

AI with Python – 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

借助深度神经网络,人工智能可以实现巨大的准确性。人工智能有助于医学领域诊断疾病,如通过患者的 MRI 诊断癌症。

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 −

Sr.No

Intelligence & Description

Example

1

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

Narrators, Orators

2

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

Musicians, Singers, Composers

3

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

4

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

5

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

6

Intra-personal intelligence The ability to distinguish among one’s own feelings, intentions, and motivations.

Gautam Buddhha

7

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 −

  1. Reasoning

  2. Learning

  3. Problem Solving

  4. Perception

  5. Linguistic Intelligence

intelligenc

让我们简单了解一下所有组成部分:

Let us go through all the components briefly −

Reasoning

这套流程使我们能够为判断、决策和预测提供依据。主要有两类:

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.

  1. 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.

  2. 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 known or unknown hurdles.

解决问题还包括 decision making ,这是从多个备选方案中选择最合适的备选方案以达到期望目标的过程。

Problem solving also includes decision making, which is the process of selecting the best suitable alternative out of multiple alternatives to reach the desired goal.

Perception

这是获取、解释、选择和组织感官信息的过程。

It is the process of acquiring, interpreting, selecting, and organizing sensory information.

感知假设 sensing 。在人类中,感知借助于感觉器官。在人工智能领域,感知机制以一种有意义的方式将传感器获取的数据放在一起。

Perception presumes sensing. In humans, perception is aided by sensory organs. In the domain of AI, perception mechanism puts the data acquired by the sensors together in a meaningful manner.

Linguistic Intelligence

这是使用、理解、说和写语言和文字的能力。它在人际交流中很重要。

It is one’s ability to use, comprehend, speak, and write the verbal and written language. It is important in interpersonal communication.

What’s Involved in AI

人工智能是一个广泛的研究领域。该研究领域有助于找到解决现实世界问题的方案。

Artificial intelligence is a vast area of study. This field of study helps in finding solutions to real world problems.

现在让我们来看看人工智能中的不同研究领域 −

Let us now see the different fields of study within AI −

Machine Learning

它是人工智能中最流行的领域之一。该领域的基本概念是让机器从数据中学习,就像人类能够从自己的经验中学习一样。它包含学习模型,根据这些模型可以在未知数据上做出预测。

It is one of the most popular fields of AI. The basic concept of this filed is to make the machine learning from data as the human beings can learn from his/her experience. It contains learning models on the basis of which the predictions can be made on unknown data.

Logic

这是另一个重要的研究领域,其中使用数学逻辑来执行计算机程序。它包含执行模式匹配、语义分析等的规则和事实。

It is another important field of study in which mathematical logic is used to execute the computer programs. It contains rules and facts to perform pattern matching, semantic analysis, etc.

Searching

该研究领域主要用于国际象棋、井字棋等游戏。在搜索整个搜索空间后,搜索算法给出最优解。

This field of study is basically used in games like chess, tic-tac-toe. Search algorithms give the optimal solution after searching the whole search space.

Artificial neural networks

这是一个高效计算系统的网络,其核心主题借鉴了生物神经网络的类比。人工神经网络可用于机器人技术、语音识别、语音处理等。

This is a network of efficient computing systems the central theme of which is borrowed from the analogy of biological neural networks. ANN can be used in robotics, speech recognition, speech processing, etc.

Genetic Algorithm

遗传算法有助于借助多个程序解决问题。结果将基于选择最合适的结果。

Genetic algorithms help in solving problems with the assistance of more than one program. The result would be based on selecting the fittest.

Knowledge Representation

借助该研究领域,我们能够以机器可以理解的方式表示事实。知识表示得越有效,系统就会越智能。

It is the field of study with the help of which we can represent the facts in a way the machine that is understandable to the machine. The more efficiently knowledge is represented; the more system would be intelligent.

Application of AI

在本节中,我们将看到人工智能支持的不同领域 −

In this section, we will see the different fields supported by AI −

Gaming

人工智能在国际象棋、扑克、井字棋等战略游戏中起着至关重要的作用,机器可以基于启发式知识想到大量的可能位置。

AI plays crucial role in strategic games such as chess, poker, tic-tac-toe, etc., where machine can think of large number of possible positions based on heuristic knowledge.

Natural Language Processing

人是可以与理解人类口语的计算机进行交互的。

It is possible to interact with the computer that understands natural language spoken by humans.

Expert Systems

某些应用程序集成了机器、软件和特殊信息,以提供推理和建议。它们向用户提供解释和建议。

There are some applications which integrate machine, software, and special information to impart reasoning and advising. They provide explanation and advice to the users.

Vision Systems

这些系统理解、解释和领悟电脑上的视觉输入。例如:

These systems understand, interpret, and comprehend visual input on the computer. For example,

  1. A spying aeroplane takes photographs, which are used to figure out spatial information or map of the areas.

  2. Doctors use clinical expert system to diagnose the patient.

  3. Police use computer software that can recognize the face of criminal with the stored portrait made by forensic artist.

Speech Recognition

一些智能系统能够在与人交谈时以句子及其意义的方式听到并理解语言。它可以处理不同的口音、俚语、背景噪音、因感冒导致的人类声音的变化等。

Some intelligent systems are capable of hearing and comprehending the language in terms of sentences and their meanings while a human talks to it. It can handle different accents, slang words, noise in the background, change in human’s noise due to cold, etc.

Handwriting Recognition

手写识别软件可以读取纸上用笔书写的文本,或屏幕上用触控笔书写的文本。它可以识别字母形状并将其转换成可编辑的文本。

The handwriting recognition software reads the text written on paper by a pen or on screen by a stylus. It can recognize the shapes of the letters and convert it into editable text.

Intelligent Robots

机器人能够执行人类给定的任务。它们有传感器来检测来自真实世界中的物理数据,例如光、热、温度、运动、声音、颠簸和压力。它们有高效的处理器、多个传感器和巨大的存储器,可以表现出智能。此外,它们能够从错误中学习,并且可以适应新的环境。

Robots are able to perform the tasks given by a human. They have sensors to detect physical data from the real world such as light, heat, temperature, movement, sound, bump, and pressure. They have efficient processors, multiple sensors and huge memory, to exhibit intelligence. In addition, they are capable of learning from their mistakes and they can adapt to the new environment.

Cognitive Modeling: Simulating Human Thinking Procedure

认知建模基本上是计算机科学中涉及研究和模拟人类思考过程的研究领域。人工智能的主要任务是让机器像人类一样思考。人类思考过程最重要的特点是解决问题。这就是为什么或多或少认知建模试图理解人类如何解决问题。在此之后,该模型可用于各种 AI 应用程序,例如机器学习、机器人、自然语言处理等。以下为人脑不同思维层次的图表 −

Cognitive modeling is basically the field of study within computer science that deals with the study and simulating the thinking process of human beings. The main task of AI is to make machine think like human. The most important feature of human thinking process is problem solving. That is why more or less cognitive modeling tries to understand how humans can solve the problems. After that this model can be used for various AI applications such as machine learning, robotics, natural language processing, etc. Following is the diagram of different thinking levels of human brain −

cognitive modeling

Agent & Environment

在本部分中,我们将重点关注代理和环境,以及它们如何帮助实现人工智能。

In this section, we will focus on the agent and environment and how these help in Artificial Intelligence.

Agent

代理是可以通过传感器感知其环境并通过效应器对环境采取行动的任何事物。

An agent is anything that can perceive its environment through sensors and acts upon that environment through effectors.

  1. A human agent has sensory organs such as eyes, ears, nose, tongue and skin parallel to the sensors, and other organs such as hands, legs, mouth, for effectors.

  2. A robotic agent replaces cameras and infrared range finders for the sensors, and various motors and actuators for effectors.

  3. A software agent has encoded bit strings as its programs and actions.

Environment

有些程序完全在 artificial environment 中运行,仅限于键盘输入、数据库、计算机文件系统和屏幕上的字符输出。

Some programs operate in an entirely artificial environment confined to keyboard input, database, computer file systems and character output on a screen.

相比之下,一些软件代理(软件机器人或软机器人)存在于丰富、无限的软机器人域中。模拟器具有 very detailed, complex environment 。软件代理需要从一系列动作中实时做出选择。软机器人旨在扫描客户的在线偏好,向客户展示有趣的产品,既适用于 real 环境,又适用于 artificial 环境。

In contrast, some software agents (software robots or softbots) exist in rich, unlimited softbots domains. The simulator has a very detailed, complex environment. The software agent needs to choose from a long array of actions in real time. A softbot is designed to scan the online preferences of the customer and shows interesting items to the customer works in the real as well as an artificial environment.