As any Pythonista could tell you, this fun, Monty Python-inspired programming language has been around for a little over 30 years but it's only enjoyed visibility and popularity in the last decade or so. Don't you wonder why?

Guido van Rossum, Python's creator and Benevolent Dictator for Life asserts that his language was born out of the frustration of overly complicated programming languages that existed in 1989; specifically ABC, which was supposed to be simpler than Pascal and BASIC.

Keep in mind that, at that time, computers were far from the mainstream - public access to the World Wide Web was still four years into the future, and artificial intelligence remained in the realm of science fiction.

Today, thanks to astounding progress on various technology fronts, self-driving cars are in the testing phase and sentient robots are a serious possibility. For them to become reality, these machines have to learn from their experiences and become conditioned to make decisions based on those experiences.

That, in a nutshell, is the definition of machine learning. Python is arguably the best language for it.

You might say that, after that decades-long wait, Python has finally found its purpose - which explains this language's sudden popularity. Or you might not. Let Superprof help you clear up that indecision.

The best Python tutors available
Matthew
5
5 (23 reviews)
Matthew
£27
/h
Gift icon
1st lesson free!
Dr. Kritaphat
4.9
4.9 (26 reviews)
Dr. Kritaphat
£49
/h
Gift icon
1st lesson free!
Igor
5
5 (15 reviews)
Igor
£50
/h
Gift icon
1st lesson free!
Siddharth
5
5 (13 reviews)
Siddharth
£40
/h
Gift icon
1st lesson free!
Orestes
5
5 (5 reviews)
Orestes
£40
/h
Gift icon
1st lesson free!
Domantas
5
5 (14 reviews)
Domantas
£22
/h
Gift icon
1st lesson free!
Andrea
5
5 (17 reviews)
Andrea
£50
/h
Gift icon
1st lesson free!
Wei bin
5
5 (13 reviews)
Wei bin
£30
/h
Gift icon
1st lesson free!
Matthew
5
5 (23 reviews)
Matthew
£27
/h
Gift icon
1st lesson free!
Dr. Kritaphat
4.9
4.9 (26 reviews)
Dr. Kritaphat
£49
/h
Gift icon
1st lesson free!
Igor
5
5 (15 reviews)
Igor
£50
/h
Gift icon
1st lesson free!
Siddharth
5
5 (13 reviews)
Siddharth
£40
/h
Gift icon
1st lesson free!
Orestes
5
5 (5 reviews)
Orestes
£40
/h
Gift icon
1st lesson free!
Domantas
5
5 (14 reviews)
Domantas
£22
/h
Gift icon
1st lesson free!
Andrea
5
5 (17 reviews)
Andrea
£50
/h
Gift icon
1st lesson free!
Wei bin
5
5 (13 reviews)
Wei bin
£30
/h
Gift icon
1st lesson free!
Let's go

What Is Learning?

Take a look back over your learning experiences. No one will blame you if school is the first thought that popped into your head and it will serve our thesis well. How did you learn in school?

Somebody, usually a teacher, delivered information that you processed and stored. So far, so good; that sounds exactly like programming a computer. The only difference is that you weren't served individual nuggets of knowledge in a vacuum; everything you learned sort of hung together and, more often than not, it was up to you to make those connections.

Babies learn by trial and error
Most of what we learned as babies was through experimentation and play. Photo credit: quinn.anya on Visualhunt.com

Now, go back a bit further, to your learning before formal education. How did you learn?

Humans (and other animals) absorb information from a variety of inputs and make decisions based on their experiences. Falling down and hitting your head causes pain; let's do our best to not hit our heads. Hitting and biting other children causes angry reactions and maybe provokes punishment; we soon learned to not bite or hit other kids.

We don't only learn through negative experiences. Witness a parent's delight when a child takes their first steps, feeds themselves for the first time or learns how to control their bodily functions.

Approval and positive reinforcement are as good a teaching tool as their negative counterparts. Better tools, most would argue. So the child will repeat the well-rewarded behaviour to repeat the experience of receiving positive feedback.

The amazing thing about toddlers making such executive decisions is that they have little experience or information to base those decisions on and, even more astoundingly, they were never taught how to decide anything.

Machines are nothing like that.

For one, they only have one source of input: their programmer(s). For two, they have to be taught how to make decisions; if you're in any way familiar with computer languages, think only of all the 'if/else', 'with', 'def' and 'try' statements that permeate any code.

Finally, they have no incentive to learn or perform. Machines cannot be rewarded for doing well - at least, not as humans define a reward (more on that in a bit). Nor can they be punished for doing poorly.

They will process the data they're given with the instructions they're programmed with. Unlike sentient beings whose leaps of intuition spur learning far better than feeding them information can, machines can only function as they've been programmed to.

So, despite Python being inspired by one of the greatest comedy troupes of all time, Python-programmed robotics can never learn to appreciate the absurdity of Monty Python.

Still, there's plenty of value in programming machines to learn; let's find out how they do it.

Find good python courses London here on Superprof.

How Machines Learn

Machine learning begins by programming to make decisions based on desired outcomes, expected outcomes or the expectation that the machine will scan its inputs to find structure on its own; applications mostly used in statistics, to estimate the density of continuous random variables.

Those three types of learning are called supervised learning, reinforcement learning and unsupervised learning, respectively.

The type of machine learning you are likely most familiar with, whether you know it or not, is reinforcement learning. It involves a machine interacting with a dynamic environment, in which the machine must perform a series of actions.

Let's look at self-parking cars versus self-driving cars. Both involve a dynamic environment in which the machine must make decisions and perform actions. For self-parking cars, the environment they operate in is fairly limited: the vehicle's speed is lower, the space it moves in is smaller and the potential risks are easier to analyse.

Contrast that with the massive amount of data self-driving cars must process. Everything from pedestrians and other moving vehicles to the lanes they move in and traffic lights, it's easy to see how self-driving cars could discard data as not relevant to their decision-making processes.

Find good python classes here on Superprof.

Self-driving cars receive data from multiple sensors
Self-driving cars are loaded with sensors that constantly feed it information. Photo credit: harry_nl on Visualhunt.com

It's great to have the technology to build even a prototype self-driving car but the level of learning those vehicles have to do virtually guarantees that we'll be driving ourselves for the foreseeable future. Or do we only need to step our reinforcement learning game?

As we pointed out in the previous segment, punishment and reward can reinforce behaviours... do you see where we're going with this?

With reinforcement learning, machines can expect a reward for performing any positively-interpreted action. The whole context of rewards is too extensive to cover here; let's just say that these rewards are cumulative, meaning that the more desired responses are delivered, the greater the machine's reward will be upon the task's completion.

That makes reinforcement learning the ideal teaching tool for self-driving cars as well as computer games such as AlphaGo and Deep Blue, IBM's chess-playing computer.

Find good python tutorial here on Superprof.

Python and Machine Learning

Earlier, we mentioned that Python's time had come, a statement made true by its extensive library of software packages that include functionality in a host of different sectors, including:

  • graphical user interfaces (GUIs)
  • computer networking
  • multimedia
  • data analytics
  • database management
  • scientific computing
  • web scraping

And, of course, machine learning - and this is just a short list of Python uses. In March of 2021, the Python Package Index (PyPI) listed more than 290,000 software packages to address a variety of functional needs.

Doesn't that make you wonder how Python and data science can work together?

To understand how that's possible, you have to know that Python is modular. It contains hundreds of thousands of already-scripted modules designed to work as extensions of its minimal core language and in tandem with more complex programming languages.

Python's libraries - TensorFlow, Scikit-learn and Pytorch among them give programmers a choice of tools to develop their artificial intelligence and machine learning projects.

And you ought to see what Python can do with web development!

Meet and work with other Pythonistas at Pycon
You can meet and interact with other Pythonistas at Python conventions or PyCons. Photo credit: 4nitsirk on VisualHunt

Why Python is Best for Machine Learning

There are plenty of programming languages out there; what makes Python so uniquely adaptable to machine learning?

It's simple and easy to use.

Whereas many languages are laden with syntax, Python is clean and functional. For instance, if you wanted to write a program that would perform a series of tasks or deliver a certain outcome in a different programming language, you would have to type out the entire code or borrow from a code library and adapt it to fit your needs.

Not so with Python. We mentioned earlier its extensive library of modules; each written for a specific task or series of tasks. You only need to search the library to plug in what you want.

Some programming languages are suitable for a single paradigm - action, logic, data flow or event-driven.

Python supports many paradigms; it can be used in applications requiring logic and operate just as well driving an application programming interface (API). Furthermore, Python is object-oriented; the various 'objects' - data fields, variables and even code interact with each other and may even modify the basic program.

If a machine is learning, wouldn't it be best for it to operate flexibly rather than follow a rigid, pre-determined set of instructions?

For all its adaptability, Python is simple. That's good not just for novice programmers who haven't yet memorized W3C's entire lexicon, it's also great for new developers. The concise syntax and easy readability mean you don't have to tutor any new collaborators on your project and, thanks to its modular structure, you simply plug in what you want your machine to do and it's off, doing it!

Finally, there's the Python community.

We're not just talking about all the Pythonistas out there - programmers enthused by Python, even though they're one of the best reasons to embrace this language. Besides them, there's so much support to be had.

Python is open-source;. there are (virtual) reams of documentation out there, from individuals who tried and failed on a project to high-quality how-tos and analyses, with programmers and software engineers adding to the library all the time.

Between that extensive PyPI catalogue and the Pythonistas who can help you understand how to make the most of it, it's a wonder you're not thinking about where you can use Python... or are you?

>

The platform that connects tutors and students

First Lesson Free

Enjoyed this article? Leave a rating.

5.00 (1 rating(s))
Loading...

Sophia

A vagabond traveler whose first love is the written word, I advocate for continuous learning, cycling, and the joy only a beloved pet can bring. There is plenty else I am passionate about, but those three should do it, for now.