Machine Learning Algorithms: Amit Kumar Singh.b
Machine Learning Algorithms: Amit Kumar Singh.b
Algorithms
• Magnitude A
• If a is [4,5] then magnitude is 4**2+5**2=5
• Dot product of vector if a=[2,3] and b=[4,5]
• A.B=(2 4)+(3 5)=23
If there are 2 dimensions we can rely on to linear algebra. If the
dimensions are 63 63 then vector space can be used.
SVM hyper plane ( decision boundary)
• Vector w is any point perpendicular to decision boundary and vector
u a unknown data point
• If u.w+b>=0 then +
• If u.w+b<=0 then –
• Where b is bias
• U is the data set
• We need to find both w and b
• X (-ve class data).W+B=-1
• X (+ve class data).W+B=1
•Yi(class) it will be -1 and 1 for the respective classes
SVM hyper plane ( decision boundary)(part 2)
• Yi ( X i (-ve class data).W+B)=(-1 Yi) class -1
• Yi ( X i (+ve class data).W+B)=(1 Yi) class 1
• Then both equation would become
• Yi ( X i (both class data).W+B)=1
• Yi ( X i (both class data).W+B)-1=0
• Svm optimization
• We mainly focus on maximizing the width between both the hyper
plane
• Width=(x+-x-)-w/ w
• Maximize the width(b) .minimize the w .
• X =y (x.w+b)==1+b similarly X =y (x.w+b)==1-b
+ i - i
SVM optimization(first method upto 1993)
• So we introduce lagrangian
𝑛
equation
• L(w,b)=(1/2* W **2)- α[Yi ( X i (both class data).W+B)-1]
𝑖=0
SVM Optimization (using CONVEX method)
W Magnitude of w
start with
`
maximum
Global minimum
SVM Conclusion
• We need to find the w(minimum) and b(maximum) so that it satisfies
the equation Yi(Xi.W+B)>=1
• Then use y=sign(x.w+b) for prediction
• For the hyper plane (-w[i]*x-b+Yi)/w[i+1]) if its 2d data then I will be 0
and Yi can be -1 for –ve boundary ,+1 for +ve boundary ,0 for decision
boundary
• For hyper plane consider the min ,max featureset value
• Initally the w should be [maxfeaterue ,maxfeature],and atleast 3 step
sizes like 10,1,0.1 percent of data
• Need to check w in all possible transformation [1,1],[1,-1],[-1,-1],
[-1,1]
KMeans (clustering) unsupervised learning
• Flat clustering(will buy or not)
• Hierarchal clustering(will , likely , not buyer)
• We need to choose centroids Kmeans comes by default with 8 cluster
• Centroids are formed by taking the distance from each points either
by Euclidean or norm methodology
• Each centroids are recognized by having iterations until no change in
centroids
• Here the classifier has fit,cluster_center_(centroids),labels_(voting
features)
Logistic Regression