Live data from Hacker News

Ask HN: Why is Python so popular for ML/DS?

news.ycombinator.com

11–20 of 21 posts

Re: Ask HN: Why is Python so popular for ML/DS?

#12
post #6

Python was big in scientific computing before ML went mainstream. In college we were taught using matlab Mathematica and sci-py. So there were a lot of stats and science libraries available in python. Academics typically don’t care about software engineering or typing so python is an easy approachable choice.

Add ipython (now Jupiter) notebooks to this for easy to publish analyses.

Re: Ask HN: Why is Python so popular for ML/DS?

#13
Anecdotally, I have programmed in python, js, java, c#, go, C, C++, ruby, and php all in a professional environment and I'd have to say I prefer python the most. It is a very logically made language with a nice balance of abstraction and expressibility. My general language choosing path is: can I do it in python? If so, use python. Obviously you need to drop down to lower level languages for certain cases, but why work with memory management for application code if you can help it? I guess my point is that if you're going to be learning ML, you should be thrilled that you have the option of using python. That said if other languages float your boat, I've certainly done some ML in c++ with openCV and it was a positive experience. Use whatever you want.

Re: Ask HN: Why is Python so popular for ML/DS?

#15
post #13

Anecdotally, I have programmed in python, js, java, c#, go, C, C++, ruby, and php all in a professional environment and I'd have to say I prefer python the most. It is a very logically made language with a nice balance of abstraction and expressibility. My general language choosing path is: can I do it in python? If so, use python. Obviously you need to drop down to lower level languages for certain cases, but why wo…

Python also gives you the advantage to write faster code in C for smaller more computationally intensive parts of the code and use the C code with python. This allows you to dip into low level languages like you stated but also keep all the main functionality in python.

Re: Ask HN: Why is Python so popular for ML/DS?

#16

To be honest, I don’t understand its popularity. For example, I was trying to understand a batch normalization function defined as def batchnorm_forward(x, gamma, beta, eps): I can’t tell if gamma/beta are scalar or vector?

Wouldn't the default assumption be that you can use either a scalar or vector?

Re: Ask HN: Why is Python so popular for ML/DS?

#17

To be honest, I don’t understand its popularity. For example, I was trying to understand a batch normalization function defined as def batchnorm_forward(x, gamma, beta, eps): I can’t tell if gamma/beta are scalar or vector?

You could try np.isscalar() and np.array().ndim in NumPy.

Re: Ask HN: Why is Python so popular for ML/DS?

#18
The main reasons Python is so popular in science (ML and before) is:

1. It's easier to get started than Java, Go, etc.

2. It's faster to write/prototype. (The IPython REPL and Jupyter notebooks are awesome.)

3. The Python community is also very open source friendly and has significant momentum in third party packages like pandas, numpy, scipy, etc.

Check out some talks from past PyCons and you will see a very strong scientific presence more so than the other languages you mentioned.

Re: Ask HN: Why is Python so popular for ML/DS?

#19

To be honest, I don’t understand its popularity. For example, I was trying to understand a batch normalization function defined as def batchnorm_forward(x, gamma, beta, eps): I can’t tell if gamma/beta are scalar or vector?

We have type annotations in python now which can be used to clarify data types in function signatures.

https://docs.python.org/3/library/typing.html

Re: Ask HN: Why is Python so popular for ML/DS?

#20
post #14

It's just where a lot of the tools are. And why all the tool are in the python camp is probably b/c the academic/scientific community adopted the python ecosystem at a high rate.

And many in scientific industries came from tools like Matlab backed by heavy enterprise support contracts. Python was the first real foray into open source (FOSS) for many of them.

Some adopted R as well but it just didn't take off the same way even though it really was/is a better fit for some use cases.

Post reply on HN