How to Learn Python for Machine Learning

Python has become a de facto language for machine learning. It's not a difficult language to learn, but if you're not particularly familiar with the language, there are some tips that may help you learn it faster or better.

In this post, you will learn what is the right way to learn a programming language and how to get help. After reading this post you will know

What should be the right mindset to learn Python for use in Machine Learning

What are good resources for learning Python

How to find answers to Python related questions

let's get started.

How to learn Python?

There are many ways to learn a language, for natural languages ​​like English or for programming languages ​​like Python. Children learn language by listening and imitating. Gradually, when they learned patterns and some vocabulary, they could form their own sentences. Conversely, when college students learn Latin, they probably start with the rules of grammar. Singular and plural, indicative and subjunctive, nominative and accusative. Then we can make a Latin sentence.

Similarly, learning Python or any programming language, you can either read and try to understand other people's code, and then make changes from it. Or you can learn the rules of the language and build a program from scratch. The latter will be beneficial if your end goal is to work on the language, such as writing a Python interpreter. But usually, the former approach is faster to get some results.

I suggest learning from the examples first. But to strengthen your foundation in understanding the language by reviewing the rules of the language from time to time. Let's look at an example from Wikipedia:

This Python code is implementing a secondary method to find the root for a function. If you're new to Python, here's what you should do, take a look at the example, and see how much you can understand. If you have prior knowledge of other programming languages, you will probably guess that def defines a function. But if you don't, you might feel confused and it is best for you to start with a beginner's book on programming, so that you can learn about the concept of functions, variables, loops, etc.

The next thing you might think of that you can do is to modify the functions. For example, what if we are not using the secant method to find the root but rather Newton's method? You can guess how to modify the equation on line 4 to do this. What about the bifurcation method? In order for us to decide which way we should go, you need to add a statement of if f(x2)>0 . If we look at the f_example function, we see the symbol **. It is an exponentiation operator which means there to the power 2. But should we or should we? You'll have to go back and check the language manual to see the operator preference hierarchy.

So, even a small example like this, you can learn a lot of language features. By learning from more examples, you can guess the syntax, get used to idiomatic ways of coding, and do some work even if you can't explain it in detail.

Machine learning

What to avoid

If you have decided to learn Python, learning from a book is a must. Just about any beginner book on Python from your local library should work. But when you read, keep the bigger picture of your learning goal in mind. Get some exercise while you read, try out the code from the book, and create your own. Skipping a few pages is not a bad idea. Reading a book cover to cover may not be the most efficient way to learn. You should prevent yourself from delving too deeply into a single topic, as this will make you lose track of the larger goal of using Python to do useful things. Topics such as multithreading, network sockets, object-oriented programming can be considered as advanced topics for the latter.

Python is a language that is distinguished from its interpreter or compiler. Therefore, a different interpreter may behave slightly differently. Python.org's standard interpreter is CPython, also known as the reference implementation. A common option is PyPy. Whatever you use, you should learn with Python 3 instead of Python 2 because the latter is an obsolete dialect. But keep in mind that Python has gained its momentum with Python 2 and you can still see a lot of Python 2 programs.

Summary

In this post, you learned how one should study Python and the resources that can help you get started. A goal-oriented approach to studying can help you get results quickly, but as always, you need to spend a significant amount of time in it before you can become proficient.



Post a Comment

0 Comments