Python For Machine Learning: DIT822-Software Engineering For AI Systems Razan Ghzouli Razan - Ghzouli@chalmers - Se
Python For Machine Learning: DIT822-Software Engineering For AI Systems Razan Ghzouli Razan - Ghzouli@chalmers - Se
Python For Machine Learning: DIT822-Software Engineering For AI Systems Razan Ghzouli Razan - Ghzouli@chalmers - Se
Learning
DIT822-Software Engineering for AI Systems
Razan Ghzouli
[email protected]
What is Python?
Open source
high-level general- Used in:
purpose programming -data analysis
language -machine learning
-web development
-game programming
Initiative and flexible -desktop GUI
Interpreted language
2
Examples of Companies Using Python
3
Your own experience:
programming knowledge
4
5
Your own experience:
Python
6
7
Hello World in Python
Go to notebook “input and output” section to learn:
• Print an output
• Get an input from user
• Read/write a file
8
Hello World in Python: quiz
• Write in a text file "Now the file has more content!“
https://parsons.problemsolving.io/puzzle/6d8157fb00824966be5c9c
469b898c3a
9
Arithmetic Operations in Python
+ sum
- minus
* multiplication
** to the power
/ division (the result is float even if the numbers are integers)
// integer division (the result is integer even if the divided numbers are
float -rounded to the nearest integer )
% remainder
<, >, <=, >=, ==, != Comparison operators
10
Mutable and immutable
Yes No
11
Data Structures: some examples
12
Types and Data Structure
Go to notebook “types and data structure” section to learn:
• Built-in functions for variables
• Examples of dictionaries, arrays and sets
13
Types and Data Structure: quiz
• find if Chalmers has vowels
https://parsons.problemsolving.io/puzzle/263be7013df442058b8579
1420fbfac5
14
Menti check
15
Control Flow
Go to notebook “control flow” section to learn:
• Loops with examples
• Conditional statements with examples
• Transfer statements with link example
16
Control Flow: quiz
• for 3 rounds divide by 5 and notify the user if the result is negative,
lower than five, or bigger than one:
https://parsons.problemsolving.io/puzzle/2d311404c4e74a459cd0e1e
36373fe8a
• Match the type of entered coordination:
https://parsons.problemsolving.io/puzzle/cf77a1268a8540ca8592eccd
e58d6bba
17
Menti check
18
Break
19
Modules and debugging errors
Go to notebook “modules and Exception Handling” section to learn:
• Importing modules and downloading them
• Handling errors/exceptions
20
Functions and classes
Go to notebook “Functions and classes” section to learn:
• Functions syntax
• Local and global scoping in functions
• Multi argument passing in functions
• Classes syntax and their constructors
Class
Instances of the Class
Data
attributes Obj_1
Obj_2
Methods
Obj_3
21
Functions and classes: quiz
• a function that prints a list of names. The user has the flexibility to
pass as many names as needed
https://parsons.problemsolving.io/puzzle/9ea90673135e4b37a6db901
17be2c9e9
22
Menti check
23
NumPy and Pandas
Go to notebook “Numpy and pandas” section to learn:
• Syntax of numpy array
• Copying in numpy
• Basic functions for vectors using numpy arrays
• Syntax for pandas’ arrays
• Selecting items by label/index
• Reading a csv using pandas
24
NumPy and Pandas: menti quiz
25
NumPy and Pandas: menti quiz
correct answer in red
26
NumPy and Pandas: menti quiz
27
NumPy and Pandas: menti quiz
correct answer in red
28
NumPy and Pandas: menti quiz
29
NumPy and Pandas: menti quiz
correct answer in red
30
NumPy and Pandas: menti quiz
31
NumPy and Pandas: menti quiz
correct answer in red
32
NumPy and Pandas: menti quiz
33
NumPy and Pandas: menti quiz
correct answer in red
34
Visualization
Go to notebook “Visualization” section to learn:
• Plotting using Matplotlib
35
Machine learning libraries
• For machine learning algorithms scikit-learn http://scikit-learn.org
• Keras, PyTorch, TensorFlow, Caffe for neural networks
• Useful mathematical library SciPy. You might find it useful when
handling sparse data
https://www.w3schools.com/python/scipy/scipy_sparse_data.php
36
Summary
• Check this cheat sheet from Coursera, which summarized the basics of Python
https://cf-courses-data.s3.us.cloud-object-
storage.appdomain.cloud/IBMDeveloperSkillsNetwork-PY0101EN-
SkillsNetwork/handouts/Python%20Cheat%20Sheet%20-
%20The%20Basics%20Coursera.pdf
• Practice at home and check-out the links in the notebook
• For those who know Java, and they want to compare it with Python to relate to
your previous knowledge, I recommend this blog https://realpython.com/oop-in-
python-vs-java/
37
Resources and extra materials
• https://pythontutor.com/python-debugger.html#mode=edit to visualize execution
• https://faculty.washington.edu/rjl/uwhpsc-coursera/index.html#python useful course from
the university of Washington
• https://docs.python.org/3/reference/index.html Python documentation
• https://realpython.com/ useful blog full of resources
• https://jakevdp.github.io/PythonDataScienceHandbook/ Python Data Science Handbook
38