Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Why Python is the preferred language for artificial Intelligence

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)05/31 Report--

Why Python is the preferred language for artificial intelligence, for this problem, this article details the corresponding analysis and answers, hoping to help more small partners who want to solve this problem find a simpler and easier way.

In the history of human development, no technology and its applications have developed as rapidly as computer networks. The impact on people's work, life, consumption and communication is so great, and with the arrival of the information-based network society, the traditional mode of production, lifestyle and survival of human beings have undergone earth-shaking changes. The computer can not run without programs, writing programs will need to use computer language. Today we talk about Python, a common computer language.

The Internet says Python was invented by a rogue: "yes" and "no."

"Yes" because Python was founded by Guido van Rossum, who was bored in Amsterdam on Christmas Day 1989 and decided to develop a new scripting interpretation language. Python was chosen as the name of the program because he was a fan of the boa constrictor flying circus. He has a wide range of hobbies and seems to have nothing to do.

"No" is because: before Python development, he was also the designer of ABC language, ABC did not succeed in the end, Guido believes that because ABC is not open source, so Python pays special attention to open source and combination with other languages.

Python is an interpreted scripting language, not a high-level language like c++/java, which needs to be compiled into bytecode before it can run. It can be interpreted while running. Its design also maintains a clear and uniform style, which makes Python an easy-to-read, easy-to-maintain, and widely used language that is popular with a large number of users.

And with the rise of artificial intelligence, Python's popularity has gradually increased in recent years, and many AI practitioners will choose Python first. Let's look at two sets of data:

According to the 2017 Machine Learning and Data Science Survey published by data platform Kaggle, Python is the language most used by data scientists and AI practitioners in terms of tool language use (see figure below).

Python was also ranked No. 1 in the IEEE Spectrum's 2017 list of most popular programming languages (see figure below).

Why Python is the preferred programming language for AI technology?

Reason 1: Python is a spoken language

The so-called "speaking human language" refers to this language:

Developers do not need to focus on the bottom layer

Simple and intuitive syntax

consistent expression

Let's look at a few code examples:

C Hello World code:

int main()

{

printf("Hello, World! ");

return 0;

}

Java Hello World code:

public class HelloWorld {

public static void main(String[] args){

System.out.println("Hello World! ");

}

}

Python Hello World code:

print("Hello World! ")

Just a Hello World program, you can see the difference, right?

Compilation VS interpretation

Of course, just a Hello World, C and Java code is not more than a few lines.

But don't forget, C and Java code to run, must first go through the compilation link.

For the C language, what kind of compiler to use on different operating systems is also a problem that needs to be considered. Once the code is copied to the new machine, the running environment is different from before, and it needs to be recompiled, and whether there is a compiler on that machine is still a problem. After installing the compiler, it may be different from the original compiler before, and the source code needs to be modified to meet the needs of the compilation environment...

What did I do wrong? I'm just trying to run a program someone else wrote.

Python does not need to be compiled and runs directly. And can not write files, a statement can be run directly as a command line, really too convenient.

language syntax

Java syntax is more verbose than Python.

As you can see from the above example, to create a list, Java also needs to declare and insert nodes one by one, while Python can complete all operations from list creation to node insertion and assignment in one line of code.

Java makes you write a few lines awkwardly, Python does it in one sentence.

As a result, Python is easy to write and easy to read. Readability is much higher than Java.

expression style

A decade or more ago, Python was often compared to Perl. After all, C was a system-level language, Java was an object-oriented language, and Python & Perl were the twin stars of scripting.

Python and Perl have one big difference at the design level:

Python strives to ensure that different people use the same form of expression when writing code for the same function;

Perl, on the other hand, deliberately seeks to express itself in a variety of ways, allowing the same person to write the same function in different places in different forms.

Philosophically speaking, Perl's quest is more liberal and more conducive to the release of human diversity. However, Perl writes programs--that's a mess!

If you don't want to be a code poet or a language guru, but just want to get things done in as simple and direct a way as possible, the preferred language is Python.

Reason 2: Strong AI support library

matrix operation

NumPy, created by data scientist Travis Oliphant, supports dimensional arrays and matrix operations. Combined with Python's built-in math and random libraries, it can be called an AI data artifact! With them, you can rest assured that the bold play matrix!

As we all know, whether it is Machine Learning or Deep Learning, models, algorithms, and network structures can be used ready-made, but the data is responsible for I/O and passed to the algorithm.

And all kinds of algorithms actually deal with matrices and vectors.

Using NumPy, matrix transpositions, inversions, sums, cross multiplications, dot multiplications…can be easily done with one line of code, rows and columns can be easily extracted, and matrix decomposition is just a matter of a few lines of code.

Moreover, NumPy does a lot of parallelization of matrix operations at the implementation level, improving program efficiency through mathematical ingenuity rather than letting users write multithreaded programs themselves.

With Python, a programming language with simple syntax and uniform style, no need to pay attention to the underlying implementation, even matrix elements can be written like formulas on paper, and the results can be automatically calculated after writing formulas, developers can focus on models and algorithms.

ML model

For most classical models implemented in Python, dozens or hundreds of lines of code are sufficient.

Of course, for ordinary users, you can also ignore the algorithm and just call the Scikit-Learn interface.

For example, training and using a logistic Regression model requires only the following lines of code:

# import the LogisticRegression

from sklearn.linear_model import LogisticRegression

# Use default parameters

classifier = LogisticRegression()

# train model

classifier.fit(train_set, target)

# do test

y_hat = classifier.predict(test_set)

# print out test results

print y_hat

Support chart

Python also has a number of icon support libraries. To generate various graphical tables on the dashboard is a very simple matter.

For example, using Plotly graphics library, the following colorful graphics, just use it:

Reason 3: Scale effects

The language is simple to learn and the support library is rich and powerful. These two pillars have established Python's status in the Jianghu from the early days.

According to the statistics of major programming language trends based on the number of Stack Overflow questions read in high-income countries, Python has surpassed Java and Javascript in recent years to become the fastest growing programming language in developed countries (see figure below).

As can be seen from the figure, after 2012, the number of views on Python-related issues has increased rapidly. From the perspective of time, this trend coincides with the development of artificial intelligence in recent years.

Summary:

The popularization of technology is like snowballing. The early accumulation is relatively slow. Once the critical point is passed, it is a big explosion. China has entered an era of rapid development of artificial intelligence, and the current popular Python is considered the preferred programming language for artificial intelligence technology at this stage.

The answer to why Python is the preferred language for artificial intelligence is shared here. I hope the above content can help you to some extent. If you still have a lot of doubts, you can pay attention to the industry information channel to learn more about it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report