Documente Academic
Documente Profesional
Documente Cultură
Varun Chandola
Computer Science and Engineering
Computational and Data-Enabled Science and Engineering
University at Buffalo, State University of New York
Varun Chandola
Machine Learning
1 / 38
Tutorial Overview
Varun Chandola
Machine Learning
2 / 38
Setup
Python and iPython Notebooks
scikit-learn - ML library in Python
Follow Along
Slides: https://github.com/ubdsgroup/
cdsedaystutorial/blob/master/talk.pdf
Notebook: http://nbviewer.jupyter.org/github/
ubdsgroup/cdsedaystutorial/blob/master/
MachineLearningBasics.ipynb
Git Repo:
https://github.com/ubdsgroup/cdsedaystutorial.git
Varun Chandola
Machine Learning
3 / 38
Recognition
2
Reason.
Mathematical Logic. Bayesian Inference.
Learn.
Improve with Experience
Varun Chandola
Machine Learning
4 / 38
Recognition
2
Reason.
Mathematical Logic. Bayesian Inference.
Learn.
Improve with Experience
Varun Chandola
Machine Learning
Machine Learning
4 / 38
Varun Chandola
Machine Learning
5 / 38
Varun Chandola
Machine Learning
6 / 38
Why is ML so popular?
Varun Chandola
Machine Learning
7 / 38
Machine Learning
8 / 38
Varun Chandola
Machine Learning
9 / 38
Classification or Regression
Varun Chandola
Machine Learning
10 / 38
Varun Chandola
Machine Learning
11 / 38
Non-parametric
No (finite) set of parameters
U D
Machine Learning
12 / 38
Varun Chandola
Machine Learning
13 / 38
Possible approaches
Varun Chandola
Machine Learning
14 / 38
b = arg min
J ()
= arg min
N
X
(yi yi )2
i =1
Varun Chandola
Machine Learning
15 / 38
Varun Chandola
Machine Learning
16 / 38
b = arg min J () + R ()
Varun Chandola
Machine Learning
17 / 38
Varun Chandola
Machine Learning
18 / 38
y N (w> x, 2 )
y Bernoulli (sigmoid (w> x))
where sigmoid (a) = 1+exp1 (a)
One can use polynomial expansion to model non-linear
dependencies (the model is still linear in the weights)
How to control the complexity?
Varun Chandola
Machine Learning
19 / 38
Examples of Regularization
Ridge Regression
LASSO
Machine Learning
20 / 38
Varun Chandola
Machine Learning
21 / 38
>
y = sign(w> x + b)
<
Decision Rule
w> x + b > 0 y = +1
Varun Chandola
b k
kw
w> x + b < 0 y = 1
Machine Learning
22 / 38
y = sign(w> x + b)
SVM Learning
Input: Training data
{(x1 , y1 ), . . . , (xN , yN )}
Objective: Learn w and b
that maximizes the margin
Varun Chandola
Machine Learning
23 / 38
still restrictive
The kernel trick
Allows for (implicit) mapping of data into a new high dimensional
space through kernel functions
>
k (x1 , x2 ) 1 2
Varun Chandola
Machine Learning
24 / 38
Decision Trees
Varun Chandola
Machine Learning
25 / 38
Strengths
Both regression and
classification
Weaknesses
No optimality guarantee
(learning problem is
NP-complete)
Varun Chandola
Machine Learning
26 / 38
Varun Chandola
Machine Learning
27 / 38
What is Clustering?
Varun Chandola
Machine Learning
28 / 38
x2
x1
Varun Chandola
Machine Learning
29 / 38
x2
x2
x1
Varun Chandola
x1
Machine Learning
29 / 38
K-Means Clustering
Objective: Group a set of N points ( <D ) into K clusters.
Varun Chandola
Machine Learning
30 / 38
K-Means Clustering
Objective: Group a set of N points ( <D ) into K clusters.
1
Varun Chandola
Machine Learning
30 / 38
K-Means Clustering
Objective: Group a set of N points ( <D ) into K clusters.
1
Varun Chandola
Machine Learning
30 / 38
K-Means Clustering
Objective: Group a set of N points ( <D ) into K clusters.
1
Varun Chandola
Machine Learning
30 / 38
K-Means Clustering
Objective: Group a set of N points ( <D ) into K clusters.
1
Repeat 2
Varun Chandola
Machine Learning
30 / 38
Variants of K-Means
Finding distance
Euclidean distance is popular
Finding cluster centers
Mean for K-Means
Median for k-medoids
Varun Chandola
Machine Learning
31 / 38
Choosing Parameters
1
Similarity/distance metric
Can use non-linear transformations
K-Means with Euclidean distance produces circular clusters
How to set k?
Trial and error
How to evaluate clustering?
K-Means objective function
J (c, R) =
N X
K
X
Rnk kxn ck k2
n =1 k =1
Rnk =
Varun Chandola
1
0
If xn cluster k
Otherwise
Machine Learning
32 / 38
Initialization Issues
Varun Chandola
Machine Learning
33 / 38
Weaknesses
Circular clusters (not with kernelized versions)
Choosing K is always an issue
Not guaranteed to be optimal
Works well if natural clusters are round and of equal densities
Hard Clustering
Varun Chandola
Machine Learning
34 / 38
Hard clustering
Assign every data point to exactly one cluster
Probabilistic Clustering
Each data point can belong to multiple clusters with varying
probabilities
In general
P (xi Cj ) > 0 j = 1 . . . K
For hard clustering probability will be 1 for one cluster and 0 for
all others
Varun Chandola
Machine Learning
35 / 38
Varun Chandola
Machine Learning
36 / 38
Varun Chandola
Machine Learning
36 / 38
Varun Chandola
Machine Learning
36 / 38
Varun Chandola
Machine Learning
37 / 38
Other Resources
visual-intro-to-machine-learning-part-1/)
Varun Chandola
Machine Learning
38 / 38