What level of Python knowledge is needed for Machine Learning?

Python data types

If machine learning has led you to learn Python, rather than vice versa, you may wonder how much pure coding aptitude is required before jumping into ML. This question occurred to me as I was considering the best means to get started in machine learning: can I passively come to understand Python while learning ML, or is it better to first commit the time learning Python and then apply it to machine learning?

In a quest for efficiency, I wasted spent considerable time reaching out to peers, subject-matter experts, and reading through as much material as I could find only to discover there is no consensus; there is no agreed-upon, optimal approach to learn machine learning.

I choose the latter for reasons I’ll expound upon below and in other posts on the site, however, while considering my approach, I determined the material that would be required at a minimum if I was going to learn Python purely as a byproduct of a broader study of machine learning.

So, for those who aim to jump into machine learning immediately — and are presumably familiar with basic programing concepts — this is the basic, ‘pure Python’ material with which I would recommend becoming familiar.

  • Assignment and Data Types
Text:str
Numeric:intfloatcomplex
Sequence:listtuplerange
Mapping:dict
Set:setfrozenset
Boolean:bool
Binary:bytesbytearraymemoryview
  • Flow Control – loops, if/elif/else, and recursion

  • Data Structures – lists and dictionaries in particular, but I would recommend tuples as well. Also, note arrays will be used via a library called NumPy.

  • Functions – similar to other programing languages, a function (or method) is a group of statements associated to perform a specific task. Functions are generally used for efficiency and organization within your code, shaping it into more modular, manageable chunks within the program.

Note: whitespace in Python has meaning and is used somewhat similar to curly brackets in other programing languages

As I noted above, I choose to dig in and learn Python directly first, and then apply it to machine learning. My reasoning was that — even contextualized to data alone — I felt I would like a more complete toolset, which can be leveraged for machine learning. This includes working with APIs, scraping data (if permitted) and constructing robust visualizations.

In addition to the Python competencies specified, there are some core libraries and math (arithmetic, linear algebra) that will be required.

You Might Also Like