Basic ML Algorithm
Basic ML Algorithm
Algorithms
m= 0.38522
y= 0.38522*x + 65.141
January 22, 2024
Logistic Regression
¡ Logistic regression is a supervised learning
algorithm.
¡ LR analysis studies the association between a
categorical dependent and independent
variables.
¡ The goal of Logistic Regression is to discover
a link between characteristics and the
likelihood of a specific outcome.
P0 (185, 72) P1 (170, 56) P2 (168, 60) P3 (179, 68) P4 (182, 72) P5 (188, 77)
P0 (185, 72)
0 0 0 0 0 0
P1 (170, 56)
21.93 0 0 0 0 0
P2 (168, 60)
20.81 4.47 0 0 0 0
P3 (179, 68)
7.21 15 13.6 0 0 0
P4 (182, 72)
3 20 18.44 5 0 0
P5 (188, 77)
5.83 27.66 26.25 12.73 7.81 0
1/22/24
…
¡ In DBSCAN there are main internal concepts like Core Point,
Noise Point, Border Point, Center Point, ε.
§ ε: It defines the neighborhood around a data point i,e distance between two
points is lower or equal to ε then they are considering as neighbors.
¡ Min.points: Minimum number of neighbors (data points) with ε
radius.
§ Larger the dataset, the large value of Min.points must be chosen.
¡ Core points: A point is said to core point if it has more than
Min.points within ε.
¡ Border point: A point which has fewer than Min.points within ε
but its in the neighborhood of core point.
¡ Noise point: A point which is not a core point or border point.
1/22/24
…
¡ DBSCAN divide the data points in to Core, Noise
and Border points
1. Core points if
▪ {q | dist(p,q) <= ε }>= minPts
2. Border Points if
▪ {q | dist(p,q) <= ε }< minPts
3. Noise Points if
▪ dist(p,q) <= ε and p is core point and q is noise
point
1/22/24
…
X Y
P1 7 4 ¡ Given the minimum point of 4
P2 6 4 and the radius of 1.9, find the
P3 5 6 core, border and noise points
P4 4 2
P5 6 3 !"#$%&'( = (+, − +. ). +(1, − 1. ).
P6 5 2
P7 3 3
P8 4 5
P9 6 5
P10 3 6
P11 4 4
P12 8 2
1/22/24
…
P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12
P1 0 1 2.828 3.606 1.4142 2.82843 4.1231 3.1623 1.4142 4.47214 3 2.2361
P2 1 0 2.236 2.828 1 2.23607 3.1623 2.2361 1 3.60555 2 2.8284
P3 2.8284 2.236 0 4.123 3.1623 4 3.6056 1.4142 1.4142 2 2.2361 5
P4 3.6056 2.828 4.123 0 2.2361 1 1.4142 3 3.6056 4.12311 2 4
P5 1.4142 1 3.162 2.236 0 1.41421 3 2.8284 2 4.24264 2.2361 2.2361
P6 2.8284 2.236 4 1 1.4142 0 2.2361 3.1623 3.1623 4.47214 2.2361 3
P7 4.1231 3.162 3.606 1.414 3 2.23607 0 2.2361 3.6056 3 1.4142 5.099
P8 3.1623 2.236 1.414 3 2.8284 3.16228 2.2361 0 2 1.41421 1 5
P9 1.4142 1 1.414 3.606 2 3.16228 3.6056 2 0 3.16228 2.2361 3.6056
P10 4.4721 3.606 2 4.123 4.2426 4.47214 3 1.4142 3.1623 0 2.2361 6.4031
P11 3 2 2.236 2 2.2361 2.23607 1.4142 1 2.2361 2.23607 0 4.4721
P12 2.2361 2.828 5 4 2.2361 3 5.099 5 3.6056 6.40312 4.4721 0
1/22/24
…
Points Status
P1 P1: P2, P5, P9 Core
P2 P2: P1, P5, P9 Core
P3 P3: P8, P9 Noise Border
P4 P4: P6, P7 Noise
P5 P5: P1, P2, P6 Core
P6 P6: P4, P5 Noise Border
P7 P7: P4, P11 Noise
P8 P8: P3, P10, P11 Core
P9 P9: P1, P2, P3 Core
P10 P10: P8 Noise Border
P11 P11: P7, P8 Noise Border
P12 P12: Noise
1/22/24
…
1/22/24
Divisive Clustering
¡ A type of clustering algorithm that group data object using
in top down manner
§ Initially all the object are in one cluster
§ Then the cluster is subdivided into smaller and smaller pieces until
each object forms a cluster on its own or until it satisfies certain
termination condition as the desired number of clusters is obtained
¡ The algorithm works using minimal spanning tree (MST)
§ Compute a MST for the given adjacency matrix
§ Repeat
§ Create a new cluster by breaking the link corresponding to the new
distance
§ Do until one cluster remain
1/22/24
…
1/22/24
…
Edge Cost Select the minimal cost
A-B 1 from the element listed
C-D 1 without creating an a loop
from the edge.
A-C 2
A-D 2 A
Thus edge A is connected
B-C 2 to B at the cost of 1.
A-E 3 1
D-E 3
B
B-E 3
B-D 4
C-E 5
1/22/24
…
Edge Cost Select the next minimal cost
A-B 1 from the element listed
without creating loop.
C-D 1
A-C 2 Thus edge C is connected to
A-D 2 A C D at the cost of 1.
B-C 2
A-E 3 1 1
D-E 3
B D
B-E 3
B-D 4
C-E 5
1/22/24
…
Edge Cost Select the next minimal cost Edge Cost
A-B 1 from the element listed without A-B 1
loop which is 2. C-D 1
C-D 1
A-C 2 A-D 2
Thus edge A is connected to C
A-D 2 at the cost of 2.
B-C 2
A-E 3
A C
D-E 3
2
B-E 3 1 1
B-D 4
C-E 5 B D
1/22/24
…
Edge Cost In selecting the next minimal
Edge Cost
A-B 1 cost from the element listed 2
A-B 1
but it create a loop in B to C
C-D 1 C-D 1
and A-C, thus you have to
A-C 2 jump. A-D 2
A-D 2 B-C 2 *
B-C 2 A-C 2 *
A-E 3
A C
D-E 3
2
B-E 3 1 1
B-D 4
C-E 5 B D
1/22/24
…
Edge Cost Select the next minimal cost Edge Cost
A-B 1 from the element listed without A-B 1
loop which is 3. C-D 1
C-D 1
Thus edge A is connected to E.
A-C 2 A-D 2
E
A-D 2 B-C 2 *
B-C 2 3 A-C 2 *
A-E 3 A-E 3
A C
D-E 3 2
B-E 3 1 1
B-D 4
C-E 5 B D
1/22/24
…
Edge Cost In selecting the next minimal Edge Cost
A-B 1 cost from the element listed A-B 1
3, 4 and 5 but it create a loop C-D 1
C-D 1
in, thus you have to jump.
A-C 2 A-D 2
E
A-D 2 B-C 2 *
B-C 2 3
A-C 2 *
A-E 3 A-E 3
A C
D-E 3 D-E 3 *
2
B-E 3 1
B-E 3 *
1
B-D 4 B-D 4 *
C-E 5 B D C-E 5 *
1/22/24
…
Edge Cost In selecting the next minimal
Edge Cost
A-B 1 cost from the element listed 3
A-B 1
but it create a loop in B to C
C-D 1 C-D 1
and A-C, thus you have to
A-C 2 jump A-D 2
E
A-D 2 B-C 2 *
B-C 2 3 A-C 2 *
A-E 3
A C
D-E 3
2
B-E 3 1 1
B-D 4
C-E 5 B D
1/22/24
…
1/22/24
KNN
¡ KNN can be used for both classification and regression
predictive problems.
¡ K nearest neighbors is a simple algorithm that stores all
available cases and classifies new cases based on majority
(similarity) vote.
¡ KNN has been used in statistical estimation and pattern
recognition. Three important aspects of KNN:
§ Ease to interpret output
§ Calculation time and
§ Predictive Power
A 7 7 Weak
B 7 4 Weak
C 3 4 Strong
D 4 4 Strong
E 6 7 Weak
F 3 5 Strong
G 1 3 Strong
H 5 4 Weak
I 4 3 ?????
69 176 Normal
64 160 Overweight
65 172 Normal
56 174 Underweight
68 158 Overweight
57 173 Normal
58 169 Normal
68 158 Overweight
55 170 Normal
58 184 Underweight
!(#/") ∗ !(")
! "# =
!(#)
¡ Given
§ P(c|x) is the posterior probability of class (c, target) given predictor (x, attributes).
§ P(c) is the prior probability of class.
§ P(x|c) is the likelihood which is the probability of predictor given class.
§ P(x) is the prior probability of predictor.
¡ ID3
¡ C5 which is modified version of C4.5
¡ CART (Classification and Regression trees)
¡ ID3
¡ C5 which is modified version of C4.5
¡ CART (Classification and Regression trees)
0 @⁄ 0 )
¡ !"#" $%&'(() = $89:;<=& = 1 − ( ?⁄? + ? =0
¡ !"#" $%&'(() = B<"# = 1 − 3⁄ 0 + 0⁄ 0 = 0.48
1 1
Feature Gini
Outlook 0.342
Temperature 0.439
Humidity 0.367
Wind 0.428
Sunny Rainy
Outlook
Day Outlook Temperature Humidity Wind Decision Day Outlook Temperature Humidity Wind Decision
4 Rain Mild High Weak Yes
1 Sunny Hot High Weak No 5 Rain Cool Normal Weak Yes
2 Sunny Hot High Strong No 6 Rain Cool Normal Strong No
8 Sunny Mild High Weak No Overcast 10 Rain Mild Normal Weak Yes
9 Sunny Cool Normal Weak Yes 14 Rain Mild High Strong No
11 Sunny Mild Normal Strong Yes
¡ Gini index 0 in the humidity shows that, after selecting Outlook=Sunny, humidity
follows irrespective of the wind and temperature.
Sunny Rain
Outlook
No Yes
Yes
¡ Gini index 0 in the humidity shows that, after selecting Outlook=Rain, wind
follows irrespective of the temp and humidity.
Sunny Rain
Outlook
Strong
Weak
High
No Yes Yes No
Yes