Skip to content

Programming in Python for Machine Learning - learning Python with an additional focus on Machine Learning (ML)

Notifications You must be signed in to change notification settings

widmi/programming-in-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Programming in Python for Machine Learning

Hi there! This is an interactive tutorial on how to program in Python with an additional focus on Machine Learning (ML). I use it to teach Python for ML, i.a. at the Artificial Intelligence study at the Kepler University Linz.

This course is suitable for complete beginners as well as veteran programmers.

Why Python?

Python is one of the most commonly used Programming languages in machine learning and AI. It is a powerful and versatile programming language that allows for fast prototyping in simple scripts up to complex software development. These materials shall provide an introduction to programming and Python with a focus on Machine Learning.

What awaits you here?

  • A full tutorial on how to program in Python from the beginning (bits/bytes) to programming neural networks in PyTorch.
  • Interactive materials for self-study.
  • Small tasks for you to check your knowledge.
  • Lots of examples and useful code snippets.

Which areas are covered?

  1. Basics and setup
    • Basics on hardware, software, programming, and datatypes
    • Python setup and installation
    • PyCharm editor and debugger
  2. Programming-in-Python-I: General Python programming
    • Python basics
    • Advanced Python
    • Important Python modules
    • PyTorch preview
  3. Programming-in-Python-II: Python and Machine Learning
    • Building ML projects in Python using PyTorch
    • Data collection, analysis, preprocessing
    • Neural network implementation, training, and evaluation
    • More details on Python classes
    • ML standards, hints, and good-practice

Requirements

  • No prior knowledge in programming is required. If you're already familiar with similar languages or Python, just skim over the first units.
  • Laptop, PC, or access to a server is required. No high-end machines are required. GPU is optional (but faster and more fun).
  • 64bit Python 3.6 or higher. (For installation instructions see slides.)
  • Recommended operating system: Ubuntu 18.04 or higher. (optional)
  • Recommended editor and debugger: PyCharm. (optional)

Usage

  • Complete materials GS1 to GS3 in folder basics_setup/ if you are new to programming or need to set up your Python programming environment.
  • Complete each unit in folder Programming-in-Python-I/ and Programming-in-Python-II/. For each Unit xx (if existing):
    1. Go through the slides file xx_slides.py (=theoretical part and background).
    2. Step through the code filexx_code.py in the debugger (=practical part and main content). Observe the changes of the variables in the variable explorer of PyCharm. Feel free to play around with the code.
    3. Try to solve the tasks in xx_tasks.py.
    4. Check the example solutions for the tasks in xx_solutions.py.
  • Assignment sheets, datasets collected by students, and access to ML challenge server are only available to enrolled students. (But you can use other image data for the ML project or skip the project part.)

Contents

Basics and setup

In folder basics_setup/

Programming in Python I

In folder Programming-in-Python-I/

  • 00_comments_variables
    • Syntax, comments, and docstrings in Python, common Python variables, variable operations, and datatype conversions.
  • 01_tuples_lists_indices_dictionaries_slices
    • Tuples, lists, how to index them, how to create dictionaries, and how to use slices to retrieve multiple elements.
  • 02_conditions_loops
    • If, elif, and else conditions, for loops, while loops, and list comprehensions.
  • 03_functions_print_input_modules
    • Functions, passing arguments to and returning values from functions, printing to and reading from the console, and how to import python modules.
  • 04_exceptions
    • How to raise and catch exceptions. (Error-handling in Python.)
  • 05_files_glob
    • How to open, close, and read from files.
    • Finding files in directories using the glob module.
  • 06_os_sys_subprocess
    • How to use the os/sys modules to access OS operations and to get the arguments passed to our Python script using argparse.
    • How to start external programs in the background using the subprocessing module and how to call functions or external programs in a parallel fashion using the multiprocessing module.
    • Python as powerful alternative to shell-/bash-scripts to call and communicate with other programs.
  • 07_regex
    • How to use the re module to search for more complex patterns in strings via regular expressions ("regex").
  • 08_numpy_pickle
    • How to perform fast (vector/matrix) calculations with NumPy.
    • How to save Python objects to files, e.g. via the pickle module, and how to save large data in hdf5 files via h5py.
  • 09_matplotlib
    • How to create plots in Python using matplotlib.
  • 10_classes
    • Introduction to classes in Python.
  • 11_decorators_numba
    • How to speed up your Python code by using the numba package. We will also briefly learn about decorators in Python.
  • 12_tensorflow_pytorch
    • How to create computational graphs, speed up your Python code, utilize the GPU, and get ready for the basics of ML code with the PyTorch and TensorFlow modules.

Programming in Python II

In folder Programming-in-Python-II/


Best wishes and have fun!

-- Michael Widrich (widi)

About

Programming in Python for Machine Learning - learning Python with an additional focus on Machine Learning (ML)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages