01_lecture1
01_lecture1
Lecture 1: Introduction
2
Machine Learning, Pourkamali
Course prerequisites
• We need some level of calculus and linear algebra
• Vector, matrix, inner product, matrix-matrix multiplication
• Derivatives of polynomials and exponential functions
• Chain rule for nding the derivative of a composite function
3
fi
Machine Learning, Pourkamali
Anaconda
• https://www.anaconda.com/
4
Machine Learning, Pourkamali
Google Colab
• Google Colaboratory, or “Colab” for short, allows you to write and execute
Python in your browser
5
fi
fi
Machine Learning, Pourkamali
6
Machine Learning, Pourkamali
Course structure
• Part 1: Fundamentals of Machine Learning (Scikit-Learn)
• Review of Python’s main scienti c libraries: NumPy, pandas, and Matplotlib
• Steps in a typical machine learning project
• Learning by tting a model to data and optimizing a cost function
• Challenges of using machine learning systems
• Part 2: Neural Networks and Deep Learning (TensorFlow 2.0, Keras, and PyTorch)
• What neural nets are and what they are good for
• Building and training feedforward neural nets (basics and implementation)
• Convolutional nets for deep computer vision and recurrent neural nets (mainly
fundamental concepts)
7
fi
fi
Machine Learning, Pourkamali
• Alan Turing gave quite possibly the earliest public lecture on this topic in 1947:
“What we want is a machine that can learn from experience”
8
Machine Learning, Pourkamali
9
fi
Machine Learning, Pourkamali
10
fi
fi
Machine Learning, Pourkamali
Beyond prediction
• Machine learning can help human learn and discover patterns from large
amounts of data that are not immediately apparent
11
Machine Learning, Pourkamali
12
fl
Machine Learning, Pourkamali
13
fi
fi
Machine Learning, Pourkamali
• For example, based on the shopping history, detect groups of similar visitors
14
fi
Machine Learning, Pourkamali
• Find the best strategy known as policy to get the most reward
15
Machine Learning, Pourkamali
Another categorization
1. Batch learning or of ine learning: the system must be trained using all the
available data
• Drawbacks:
16
fl
Machine Learning, Pourkamali
Another categorization
1. Instance-based learning: the system uses a similarity measure to compare new
cases to the learned examples
6. Model-based learning: build a model of the learned examples and then use that
model to make predictions
17
Machine Learning, Pourkamali
Model-based learning
• Does money make people happier?
• Examples
18
Machine Learning, Pourkamali
19
Machine Learning, Pourkamali
Summary of steps
20
Machine Learning, Pourkamali
21
fi
Machine Learning, Pourkamali
22
fi
Machine Learning, Pourkamali
23
fi
Machine Learning, Pourkamali
24
fi
Machine Learning, Pourkamali
• Split the available data into two sets: training set and testing set
• The error on the test set is called the generalization error or out-of-sample
error
• If training error is low and generalization error is high, then over tting occurs
• How to choose suitable models and their hyperparameters?
25
fi
Basics of Python
https://github.com/farhad-pourkamali/machine-learning
Review of linear algebra and NumPy
https://github.com/farhad-pourkamali/machine-learning
Part 1: https://youtu.be/xSO0qOyvevc
Part 2: https://youtu.be/SeBRHg9ZrSs
Machine Learning, Pourkamali
Introduction
• NumPy offers mathematical functions, random number generators, linear algebra
routines, and more
a1
a11 … a1m
a2
a= ∈ ℝn A= ⋮ ⋮ ∈ ℝn×m
⋮ an1 anm
an
28
Machine Learning, Pourkamali
Creating arrays
29
Machine Learning, Pourkamali
Creating arrays
30
Machine Learning, Pourkamali
31
Machine Learning, Pourkamali
Array data
• NumPy’s ndarrays are ef cient because their elements must have the same type
• Data types: https://numpy.org/doc/stable/user/basics.types.html
32
fi
Machine Learning, Pourkamali
Array data
• NumPy’s ndarrays are ef cient because their elements must have the same type
33
fi
Machine Learning, Pourkamali
Reshaping an array
34
Machine Learning, Pourkamali
Reshaping an array
• The reshape function returns a new array object pointing at the same data.
35
Machine Learning, Pourkamali
Conditional operators
36