Assignment 1 - Binary Classifier and Polynomial Vector Space
1. Binary Classifier
a) Expressing y as an inner product
The decision rule for the binary classifier is based on the sign of x<em>1a</em>1+x<em>2a</em>2−b. We can express this as an inner product y=xTw, where:
x=[x<em>1 x</em>2 1] is the feature vector.
w=[a<em>1 a</em>2 −b] is the weight vector.
Thus, y=x<em>1a</em>1+x<em>2a</em>2−b=xTw.
b) Decision Boundary as a Straight Line
The decision boundary is defined by x<em>1a</em>1+x<em>2a</em>2=b. To show this is a straight line in the x<em>1-x</em>2 plane, we can rearrange the equation to solve for x2:
x<em>2=−a<em>2a</em>1x</em>1+a2b
This is in the form of a straight line y=mx+c, where:
c) Feature Matrix X
Given the four data samples, the feature matrix X is constructed as follows:
X=[0amp;0.4amp;1 0.2amp;0.1amp;1 0.5amp;0.6amp;1 0.9amp;0.8amp;1]
Each row represents a data sample, with columns corresponding to x<em>1, x</em>2, and a 1 for the bias term.
d) Sketching the Decision Boundary and Classifying Data
Given a<em>1=1, a</em>2=2, and b=1, the decision boundary equation is:
x<em>1+2x</em>2=1
Or, solving for x2:
x<em>2=−21x</em>1+21
This is a straight line with a slope of -1/2 and a y-intercept of 1/2. To classify the data points:
(0, 0.4): 0 + 2(0.4) = 0.8 < 1, Class -1
(0.2, 0.1): 0.2 + 2(0.1) = 0.4 < 1, Class -1
(0.5, 0.6): 0.5 + 2(0.6) = 1.7 > 1, Class 1
(0.9, 0.8): 0.9 + 2(0.8) = 2.5 > 1, Class 1
The points (0, 0.4) and (0.2, 0.1) are classified as -1, and (0.5, 0.6) and (0.9, 0.8) are classified as 1.
e) Linear Classifier Script
The linear classifier script classifies 5000 data points with two features. The decision boundary observed is a straight line, which separates the two classes.
f) Changing Classifier Weights
Changing the classifier weights to w=[1.6 2 −1.6] alters the slope and position of the decision boundary. This leads to a different linear separation of the data points, resulting in a different classification for some points.
2. Polynomial Vector Space
a) P as a Vector Space
To show that P is a vector space, we need to verify the vector space axioms:
Closure under addition: If p,q<br>∈P, then p+q is also a polynomial of degree <br>≤n, so p+q<br>∈P.
Closure under scalar multiplication: If p<br>∈P and c<br>∈R, then cp is also a polynomial of degree <br>≤n, so cp<br>∈P.
Commutativity of addition: For all p,q<br>∈P, p+q=q+p.
Associativity of addition: For all p,q,r<br>∈P, (p+q)+r=p+(q+r).
Existence of additive identity: The zero polynomial 0 is in P (can be viewed as a polynomial of degree -∞), and for all p<br>∈P, p+0=p.
Existence of additive inverse: For every p<br>∈P, there exists −p<br>∈P such that p+(−p)=0.
Distributivity of scalar multiplication with respect to vector addition: For all a<br>∈R and p,q<br>∈P, a(p+q)=ap+aq.
Distributivity of scalar multiplication with respect to scalar addition: For all a,b<br>∈R and p<br>∈P, (a+b)p=ap+bp.
Associativity of scalar multiplication: For all a,b<br>∈R and p<br>∈P, a(bp)=(ab)p.
Existence of multiplicative identity: For all p<br>∈P, 1p=p.
b) Inner Product Definition
To show that pTq=∫−11p(x)q(x)dx is an inner product, we need to verify the following properties:
Symmetry: pTq=qTp since ∫<em>−11p(x)q(x)dx=∫</em>−11q(x)p(x)dx.
Linearity: (ap+bq)Tr=a(pTr)+b(qTr) for any scalars a, b. This holds because integration is linear.
Positive-definiteness: pTp<br>≥0 and pTp=0 if and only if p=0. Since p(x)2<br>≥0 for all x, ∫<em>−11p(x)2dx≥0. If ∫</em>−11p(x)2dx=0, then p(x)=0 for all x<br>∈[−1,1], so p is the zero polynomial.
c) Orthogonal Polynomials
To check for orthogonality, we need to compute the inner product of each pair of polynomials:
p<em>1Tp</em>2=∫<em>−11x(1−x)dx=∫</em>−11(x−x2)dx=[2x2−3x3]−11=(21−31)−(21+31)=−32. Not orthogonal.
p<em>1Tp</em>3=∫<em>−11x(3x2−1)dx=∫</em>−11(3x3−x)dx=[43x4−2x2]−11=(43−21)−(43−21)=0. Orthogonal.
p<em>2Tp</em>3=∫<em>−11(1−x)(3x2−1)dx=∫</em>−11(3x2−1−3x3+x)dx=[x3−x−43x4+2x2]−11=(1−1−43+21)−(−1+1−43+21)=0. Orthogonal.
Thus, p<em>1(x) and p</em>3(x) are orthogonal, and p<em>2(x) and p</em>3(x) are orthogonal.