[CreativeProgramming]Lecture14_Machine Learning
[CreativeProgramming]Lecture14_Machine Learning
Spring 2025
CUL1122 Lecture #14
Statistical Problems:
❖Machine Learning
▪ Traditional Programming vs. Machine Learning: A Comparison
▪ The Basic Paradigm of Machine Learning
❖Understanding Distance Measures
❖Feature Representation and Engineering
❖Exercise: Classifying Reptiles
3
Machine Learning
5
Traditional Programming vs. Machine Learning
6
Basic Paradigm of Machine Learning
7
Basic Paradigm of Machine Learning
8
Basic Paradigm
9
Supervised Learning
10
How Should We Classify the Data?
11
Defining Distance Measures
Definition: Let O1 and O2 be two objects from the universe of possible objects.
The distance (dissimilarity) between O1 and O2 is a real number denoted by D(O1, O2)
gene1
gene2
0.23 3 342.7
12
Defining Distance Measures
13
Attribute-Based Labeling through Distance Measure
14
Feature Representation
15
An Example Process of Feature Representation
20
Measuring Distance between Animals
Rattlesnake = [1,1,1,1,0]
Boa constrictor = [0,1,0,1,0]
Dart frog = [1,0,1,0,4]
21
Euclidean Distance between Animals
22
Add an Alligator
23
Add an Alligator
❖The alligator is closer to the dart frog than to the snakes. Why?
▪ The alligator differs from the dart frog in three features, whereas it differs from
the boa constrictor in only two features.
▪ However, the scale for the “legs” feature ranges from 0 to 4, while the scales
for the other features range from 0 to 1.
▪ As a result, the “legs” dimension is disproportionately large.
Rattlesnake Boa constrictor Dart frog Alligator
Rattlesnake - 1.414 4.243 4.123
Boa constrictor 1.414 - 4.472 4.123
Dart frog 4.243 4.472 - 1.732
Alligator 4.243 4.123 1.732 -
24
Using Binary Features
25
Exercise: Classifying Reptiles
Exercise #1: Reptile Classification
27
Exercise #1: 1) Define the Animal Class
❖Define the Animal class, which should include a feature vector and a
method for measuring the distance between features.
class Animal(object):
def __init__(self, name, features):
# Assume name a string; features a list of numbers
self.name = name
self.features = numpy.array(features)
28
Exercise #1: 2) Calculate Similarity between Animals
30
Exercise #1: 4) Improve Features
31
수고하셨습니다!
32