Teoh Teik Toe Python For Artificial Intelligence 2022
Teoh Teik Toe Python For Artificial Intelligence 2022
Abstract Python is a very popular programming language with many great features
for developing Artificial Intelligence. Many Artificial Intelligence developers all
around the world use Python. This chapter will provide an introduction to the Python
Programming Language before covering its history and common uses and explain
why it is so popular among Artificial Intelligence developers.
Learning outcomes:
• Introduce the Python programming language.
“Python has gotten sufficiently weapons grade that we don’t descend into R
anymore. Sorry, R people. I used to be one of you but we no longer descend into
R.” – Chris Wiggins
Python is a general-purpose programming language conceived in 1989 by Dutch
programmer Guido van Rossum.
Python is free and open source, with development coordinated through the
Python Software Foundation.
Python has experienced rapid adoption in the last decade and is now one of the
most commonly used programming languages.
© The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd. 2022 3
T. T. Teoh, Z. Rong, Artificial Intelligence with Python,
Machine Learning: Foundations, Methodologies, and Applications,
https://doi.org/10.1007/978-981-16-8615-3_1
4 1 Python for Artificial Intelligence
The following chart, produced using Stack Overflow Trends, shows one measure of
the relative popularity of Python.
The figure indicates not only that Python is widely used but also that adoption of
Python has accelerated significantly since 2012.
This is driven at least in part by uptake in the scientific domain, particularly in
rapidly growing fields like data science.
For example, the popularity of pandas, a library for data analysis with Python,
has exploded, as seen here.
(The corresponding time path for MATLAB is shown for comparison.)
1.1 Common Uses 5
Note that pandas takes off in 2012, which is the same year that we see Python’s
popularity begins to spike in the first figure.
Overall, it is clear that
• Python is one of the most popular programming languages worldwide.
• Python is a major tool for scientific computing, accounting for a rapidly rising
share of scientific work around the globe.
1.1.2 Features
One nice feature of Python is its elegant syntax—we will see many examples later
on.
6 1 Python for Artificial Intelligence
Elegant code might sound superfluous, but in fact it is highly beneficial because
it makes the syntax easy to read and easy to remember.
Remembering how to read from files, sort dictionaries, and other such routine
tasks means that you do not need to break your flow in order to hunt down correct
syntax.
Closely related to elegant syntax is an elegant design.
Features like iterators, generators, decorators, and list comprehensions make
Python highly expressive, allowing you to get more done with less code.
Namespaces improve productivity by cutting down on bugs and syntax errors.
Python is very popular for Artificial Intelligence developers for a few reasons:
1. It is easy to use:
• Python is easy to use and has a fast learning curve. New data scientists can easily
learn Python with its simple to utilize syntax and better comprehensibility.
• Python additionally gives a lot of data mining tools that help in better handling
of the data, for example, Rapid Miner, Weka, Orange, and so on.
• Python is significant for data scientists since it has many useful and easy to use
libraries like Pandas, NumPy, SciPy, TensorFlow, and many more concepts that
a skilled Python programmer must be well acquainted with.
2. Python is flexible:
• Python not only lets you create software but also enables you to deal with the
analysis, computing of numeric and logical data, and web development.
1.3 Why Python for Artificial Intelligence 7