Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
06.06.2016
Lecture plan
• Nearest neighbor classifier
• Generalized distance-based classifiers
• Non-parametric regression
• Decision trees
• Splitting criteria
• Regression trees
Duck test:
If it looks like a duck, swims like a duck,
and quacks like a duck, then it probably is a
duck.
Duck test: if it looks like a duck, swims like a duck, and quacks
like a duck, then it probably is a duck.
Distance: 𝜌: 𝑋 × 𝑋 → 0; +∞ .
Metric space is a set with a metric 𝜌 𝑥, 𝑦 , defined
on it.
Minkowski distance:
1
𝑝 𝑝
𝑝 𝑥, 𝑦 = 𝑥𝑖 − 𝑦𝑖 ,
𝑖
𝑝 = 2 is the Euclidian distance;
𝑝 = 1 is the Manhattan distance.
Mahalanobis distance:
𝑝 𝑥, 𝑦 = 𝑥−𝑦 ⏉ 𝑆 −1 (𝑥 − 𝑦),
where 𝑆 is covariance matrix for 𝑥 and 𝑦.
Entropic distance measure (in 𝐾 ∗ )
Classifier:
𝑎 𝑢, 𝑇 𝓁 = 𝑦(𝑢,1) .
Voronoi diagram:
Advantages:
• simplicity;
• lucidity;
• interpretability.
Disadvantage:
• sensibility to noise;
• low efficacy;
• no parameters (explicitly);
• necessity to store all the examples.
Choose a distance 𝜌.
Sort objects:
𝜌 𝑢, 𝑥 𝑢,1 ≤ 𝜌 𝑢, 𝑥 𝑢,2 ≤ ⋯ ≤ 𝜌 𝑢, 𝑥 𝑢,𝓁 ,
Algorithm kNN:
𝓁
𝑎 𝑢; 𝑇 𝓁 = argmax𝑦∈𝑌 𝑦 𝑢, 𝑖 = 𝑦 [𝑖 ≤ 𝑘] ,
𝑖=1
𝑘
𝑎 𝑢; 𝑇 𝓁 = argmax𝑦∈𝑌 𝑦 𝑢, 𝑖 = 𝑦 .
𝑖=1
𝑎 𝑢; 𝑇 𝓁 = argmax𝑦∈𝑌 𝑦 𝑢, 𝑖 = 𝑦 𝑤 𝑖, 𝑢 ,
𝑖=1
where 𝑤(𝑖, 𝑢) is a weight function representing
importance of 𝑖th neighbor of 𝑢.
𝑎 𝑢; 𝑇 𝓁 = argmax𝑦∈𝑌 𝐶𝑦 𝑢 .
𝑖=1
𝑤 𝑖, 𝑢 :
• linearly decreasing functions;
• exponentially decreasing functions;
𝑝 𝑥, 𝑦 = 𝜔𝑖 𝑥𝑖 − 𝑦𝑖 𝑝 𝑝.
𝑖
K-D Tree
• py: kd_tree
• weka: KDTree
Ball Tree
• py: ball_tree
• weka: BallTree
Cover Tree
• weka: CoverTree
𝑄 𝜃, 𝑇 𝓁 = 𝑤𝑖 𝑥 𝜃 − 𝑦𝑖 2 → min.
𝜃∈ℝ
𝑖=1
Main idea: let use kernel smoothing:
𝜌 𝑥𝑖 , 𝑥
𝑤𝑖 𝑥 = 𝐾 ,
ℎ
where ℎ is window width.
Advantages:
• easily understandable and interpretable;
• learning is quick;
• can work with different data type.
Disadvantage:
• sensitive to noise;
• easily get overfitted.