There’s no way you never heard the word “Python” when reading something about Machine Learning.

For two reasons:

  • First: it’s in the title above.
  • Second: everyone, like, every single soul on the Internet, seems to use Python to code machine learning.
Cringy meme

Cringe

Why is Python so popular in Machine Learning?


Python isn’t famous to be a fast language.

In fact it’s among the slowests, even compared with other interpreted languages, and we know that speeding up the training phase is key: you don’t want to wait forever before being able to use your program.

The question, then, becomes more and more relevant: why is it the god of machine learning, though?

Cool infographic showing why python is used for machine learning

  1. It’s one of the programming languages with the widest set of libraries for every need.

    You don’t want to write everything from scrach if it’s already out there and free to use.

    An important example is Google’s TensorFlow, the machine learning library we’re going to install today.

  2. It’s easy to learn, so it can also be used by scientists and researchers and not only by programmers.

    Furthermore and most importantly, machine learning is so famous that everyone wants to learn it, even if they have zero knowledge of coding.

    That’s not bad in the end, rather it’s a perfect occasion to enter the world of programming.

    In short: Python is a good shortcut for beginners.

  3. Last but not least, Python is trendy.

    Python isn’t popular just for maching learning, it’s popular on its own.

    It introdused people to programming and got some experienced coders complain about its limitations (but we don’t care about this here).

    I bet you can find almost any project you can think of already made in Python, because its community is immense and extremely active.

We’re going to use mainly Python in this series, but also other languages, to compare the results and to learn how to program machine learning from scratch, because sometimes you may need it.

TensorFlow: Google’s Machine Learning library


What is TensorFlow and why have I talked so much about it?

TensorFlow is just the easiest and smartest way to write machine learning programs.

It a library you can use to build Neural Networks.

If you want to build Neural Networks from scratch, then you have make all nodes, their interconnections, relationships, how the network improves, how it’s evaluated and so on.

Too. Much. Pointless. Effort.

Is it limited just to Neural Networks? No, it was just easiest to write an example.

As you know because you read my previous article, Machine Learning is more than just Neural Netwoks: you can read the entire list of things TensorFlow can use for here.

How to install Python


In this and the next section we’re going to install TensorFlow.

There’s an excellent tutorial on the official site, but if you don’t know where to start you can follow this step-by-step guide (for Windows).

First of all you need to go to this site and download a Windows x86-64 executable installer: you can use TensorFlow only with the 64bit version of Python.

Downloading Python

Then go to your Downloads folder and start the file you’ve just downloaded: the installation is guided, so you just have to press Next until it’s finished.

Make sure to check Pip as optional feature.

Pip is a Python’s module that allows to install additional features and libraries, such as TensorFlow.

Check Pip

Now open a command prompt: if you want to be able to execute Python from the default directory follow this tutorial otherwise you must go to the directory in which you installed it, as shown:

Moving to Python's directory

How to install TensorFlow


Done that, installing TensorFlow is pretty easy, just run this three commands:

If python is not recognised as a command, try using python3 or read the last line in the previous section.

  1. Install Numpy:
  2. Install TensorFlow:
  3. Verify that everything is OK:

If you got this result, congratulations, you’ve installed TensorFlow:

Verifying TensorFlow

How to install PyCharm, an IDE for Python


PyCharm is an IDE for Python: in short, it allows to write and run your code in one page, without doing it manually.

PyCharm is not the only one: you can read this post by Kite.com comparison and choose the one you prefer.

Go to https://www.jetbrains.com/pycharm/download/#section=windows and download the community version of PyCharm.

Open it and follow the guided procedure making sure to check these options:

Options to check in PyCharm

Then reboot your computer.

Done that you can open PyCharm and test it creating a new Python file and writing some code.

To run it go to Run->Run… (Alt+Shift+F10) or just press Alt+Shift+F10.

Finally, I’ve also installed Kite, a plugin that suggests you useful code completitions.

Many IDEs give you suggestions on how to complete the line you’re working on, so that you can code faster, but few can give you relevant ones: Kite fixes that.

It’s optional, but it’s a nice feature to have.

Conclusion


This step was necessary before diving into specific machine learning topics, otherwise you could’t run or write any code.

Not much to say here, so ask questions if you feel like and check if the next post is already available (it probably is).

From Zephyro it’s all, Bye!


Leave a Reply

%d bloggers like this: