Giter Club home page Giter Club logo

weekpracticeaml's Introduction

Introduction to Python

Welcome to the Applied Machine Learning course. During this course, we will use Python programming language to perform matrix computations, image manipulation and retrieval tasks. As some people have not worked with Python before, we start the course with an introduction to the language.

Python is a very popular high-level programming language with an emphasis on code readability and writing with a minimal amount of lines. The Python programming language contains many features that make it easy to learn. Most notably:

  • It has a dynamic type system (so you don't have to explicitly give the type to a variable, like int or float or string. Python will figure it out by itself).
  • It has automatic memory management (so you don't have to worry that much about freeing the memory or about pointers).
  • There is a rich set of libraries ready to import that will make your life easier (from simple math libraries to a whole 2D game engine).

We start with an introduction to Python and a few very useful libraries for this course. Please take care to fully understand what is happening in this introduction and feel very free to mess around with the language to understand how it works. We expect that the people unfamiliar with Python will quickly come to like the language.

Installation

NOTE: These explanations are mainly focused on Windows (and OS X) users. Linux users will find it much easier to setup Python as Linux distributions usually come with preinstalled Python and its components. Search online for explanations, there is a lot to find about Linux usage! Although installing Anaconda on Linux distributions also has its advantages.

We recommend you to use Python 3.6 or newer. The easiest way to install Python interpreter, as well as the required packages, is to use Anaconda - scientific Python distributions. It comes with virtual environment manager, popular libraries and utils. Just download the proper version of Anaconda and follow the instructions. Linux/macOS users also have to add anaconda/bin to PATH variable.

echo 'export PATH="~/anaconda3/bin:$PATH"' >> ~/.bashrc 
source .bashrc

There are other ways of installing Python, creating the environment and managing the packages. The above-stated method is not the best one, however, it will allow us to help you with possible troubles during the course.

How to run

There are several ways how to create and run python programs. One way is to create a .py file and run it from the command line: python <name of a file>. It is also possible to open a Python interpreter by simply typing python in the command line. In the interpreter, you can type individual commands, which is very useful when you want to test short code lines.

For the rest of this course, however, you will be using the Jupyter Notebook. It combines the Python interpreter, Markdown and visualization tools (and even more). It can be run just by typing jupyter notebook in a terminal/cmd. The Jupyter Notebook is a bit similar to the Python interpreter, but with a number of advantages. Namely, it also serves as a browser-based notebook (so we can explain the assignments and you can write down your notes) and you can easily print and plot results.

If you want to open Jupyter Notebook in a specific folder, first change directories in your command line by typing cd /path/to/directory. If this directory is not on your default drive (Windows users), first type driveletter: ENTER.

Q&A

Q: Are there alternative methods of launching Jupyter Notebook?

A: The latest versions of Anaconda provide users with the GUI launchers. Just double-click the icon to launch the application.

Q: I have Anaconda with the previous version of Python and I would like to switch to the newer one. How to do it?

A: You can create a new virtual environment with the version of Python you like. And then add this kernel to Jupyter Notebook.

conda create -n py37 python=3.7
source activate py37
python -m ipykernel install --name py37
source deactivate

Q: I created a new virtual environment. How can I install all the required packages?

A: You can install them with conda and/or pip. We will use numpy, scipy, matplotlib and scikit-learn for the assignments. We will use requests as well.

source activate py36 (or just `activate py37` for win)
conda install -c anaconda numpy
conda install -c anaconda scipy 
conda install scikit-learn
conda install -c conda-forge matplotlib
y
conda install -c anaconda requests
y
source deactivate (or just `deactivate` for win)

Q: How can I get the materials from GitHub?

A: There are several ways of downloading the files from GitHub:

  • The first one and the simplest one is just to visit the repository and download .zip archive.
  • You can download the official GitHub desktop client. Then visit the GitHub repository and click Open in Desktop on the website and the rest will be done automatically by the client.
  • You can clone the repository to your computer by typing the following command in a terminal/cmd: git clone https://github.com/davzha/UVA_AML19_dev. But first, install git. You may also find this tutorial very useful

weekpracticeaml's People

Contributors

pebeirao avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.