Deep Learning for Physical Scientists. Edward O. Pyzer-Knapp
Чтение книги онлайн.

Читать онлайн книгу Deep Learning for Physical Scientists - Edward O. Pyzer-Knapp страница 7

Название: Deep Learning for Physical Scientists

Автор: Edward O. Pyzer-Knapp

Издательство: John Wiley & Sons Limited

Жанр: Химия

Серия:

isbn: 9781119408352

isbn:

СКАЧАТЬ rel="nofollow" href="https://www.ioccc.org/">https://www.ioccc.org/ and wonder at the ingenuity. So by choosing to use Python in this book even if you are not a regular Python user you should be able to have a good understanding of what is going on.

      One other reason for using Python is the strong community, which has resulted in a huge amount of online support for those getting into the language. If you have a problem when writing some code for this book, online resources such as stackoverflow.com are full of people answering questions for people who have had the exact same problem. This community has resulted in the surfacing of common complaints, and the community collectively building solutions to make libraries for solving these problems and to deliver new functionality. The libraries publically available for Python are something quite special, and are one of the major reasons it has become a major player in the data science and machine learning communities.

      Recently, Python has seen a strong emergence in the data science community, challenging more traditional players such as R and Matlab. Aside from the very intuitive coding style, transferability, and other features described above, there are a number of reasons for this. First amongst these is its strong set of packages aimed at making mathematical analysis easy. In the mid‐1990s the Python community strongly supported the development of a package known as numeric whose purpose was to take the strengths of Matlab's mathematical analysis packages and bring them over to the Python ecosystem. Numeric evolved into numpy, which is one of the most heavily used Python packages today. The same approach was taken to build matplotlib – which as the name suggests was built to take the Matlab plotting library over to python. These were bundled with other libraries aimed at scientific applications (such as optimisation) and turned into scipy – Python's premier scientific‐orientated package.

      It is in the area of machine learning in which Python has really separated itself from the rest of the pack. Taking a leaf out of R's book, the scikit‐learn module was built to mimic the functionality of the R module caret. Scikit‐learn offers a plethora of algorithms and data manipulation features which make some of the routine tasks of data science very simple and intuitive. Scikit‐learn is a fantastic example of how powerful the pythonic method for creating libraries can be.

      2.3.1 Why Use Anaconda?

      When you first pick up this book, it may be tempting to run off and download Python to start playing with some examples (your machine may even have Python pre‐installed on it). However, this is unlikely to be a good move in the long term. Many core Python libraries are highly interdependent, and can require a good deal of setting up – which can be a skill in itself. Also, the process will differ for different operating systems (Windows installations can be particularly tricky for the uninitiated) and you can easily find yourself spending a good deal of time just installing packages, which is not why you picked up this book in the first place, is it?

      Anaconda Python offers an alternative to this. It is a mechanism for one‐click (or type) installation of Python packages, including all dependencies. For those of you who do not like the command line at all, it even has a graphical user interface (GUI) for controlling the installation and updates of packages. For the time being, I will not go down that route, but instead will assume that you have a basic understanding of the command line interface.

      2.3.2 Downloading and Installing Anaconda Python

      Detailed installation instructions are available on the anaconda website (https://conda.io/docs/user‐guide/install/index.html). For the rest of this chapter, I will assume that you are using MacOS – if you are not, do not worry; other operating systems are covered on the website as well.

      The first step is to download the installer from the Anaconda website (https://www.anaconda.com/download/#macos).

      Conda vs. Mini‐conda

      When you go to the website, you will see that there are two options for Anaconda; Conda; and Mini‐conda. Mini‐conda is a bare‐bones installation of Python, which does not have any packages attached. This can be useful if you are looking to have a very lean installation (for example, you are building a Docker image, or your computer does not have much space for programmes), but for now we will assume that this is not a problem, and use the full Anaconda installation, which has many packages preinstalled.

      You can select the Python2 or Python3 version. If you are running a lot of older code, you might want to use the Python2 version, as Python2 and Python3 codes do not always play well together. If you are working from a clean slate, however, I recommend that you use the Python3 installation as this “future proofs” you somewhat against libraries which make the switch, and no longer support Python2 (the inverse is much rarer, now).

      So long as you have chosen Anaconda version (not Mini‐coda), you can just double click the pkg file, and the installation will commence. Once installation is finished (unless you have specific reasons, accept any defaults during installation) you should be able to run.

      $ > conda list

      If the installation is successful, a list of installed packages will be printed to screen.

      From here, installing packages is easy. First, search your package on Anaconda's cloud (https://anaconda.org/), and you will be able to choose your package. For example, scikit‐learn's page is at https://anaconda.org/anaconda/scikit‐learn. On each page, the command for installing is given. For scikit‐learn, it looks like this:

      $> conda install –c anaconda scikit-learn

СКАЧАТЬ