Answer to 2.1:
Starting with the initial weight vector ( \mathbf{w}_0 = (0, 0) ) and given a single data point ((\mathbf{x}, y)) with label ( y = +1 ), the perceptron algorithm will misclassify this point in the first iteration because:
[
\mathbf{w}0 \cdot \mathbf{x} = 0 \quad \text{and so} \quad \delta{\mathbf{w}_0}(\mathbf{x}) = -1 \neq y = +1
]
The perceptron updates the weights using:
[
\mathbf{w}_1 = \mathbf{w}_0 + \eta y \mathbf{x} = \mathbf{w}_0 + 1 \cdot (+1) \cdot \mathbf{x} = \mathbf{x}
]
After this update, the new weight vector ( \mathbf{w}_1 = \mathbf{x} ) correctly classifies the data point since:
[
\mathbf{w}1 \cdot \mathbf{x} = \mathbf{x} \cdot \mathbf{x} = | \mathbf{x} |^2 > 0 \quad \text{and so} \quad \delta{\mathbf{w}_1}(\mathbf{x}) = +1 = y
]
Therefore, it takes 1 iteration for the perceptron algorithm to find a decision rule starting from ( \mathbf{w}_0 = (0, 0) ).
Answer to 2.2:
When the initial weight vector ( \mathbf{w}_0 ) is initialized randomly, the number of iterations required for the perceptron to converge depends on the initial classification of the data point:
- If ( \mathbf{w}_0 \cdot \mathbf{x} > 0 ): The perceptron already classifies the data point correctly, and no updates are needed. The algorithm converges in 0 iterations.
- If ( \mathbf{w}_0 \cdot \mathbf{x} \leq 0 ): The perceptron misclassifies the data point, and updates are necessary. The weight vector is updated as:
[
\mathbf{w}_{n} = \mathbf{w}_0 + n \eta y \mathbf{x}
]
At each update, the dot product increases by ( | \mathbf{x} |^2 ):
[
\mathbf{w}_{n} \cdot \mathbf{x} = \mathbf{w}_0 \cdot \mathbf{x} + n | \mathbf{x} |^2
]
We need ( \mathbf{w}_{n} \cdot \mathbf{x} > 0 ) to correctly classify the point, so:
[
\mathbf{w}_0 \cdot \mathbf{x} + n | \mathbf{x} |^2 > 0
]
Solving for ( n ):
[
n > -\frac{\mathbf{w}_0 \cdot \mathbf{x}}{| \mathbf{x} |^2}
]
Therefore, the number of iterations required cannot be determined without knowing ( \mathbf{w}_0 ); it depends on the initial weight vector's alignment with the data point.
Answer to 2.3:
We proceed with the perceptron algorithm using the given data points, initial weight vector ( \mathbf{w}_0 = (0, 0) ), and step size ( \eta = 1 ).
Initialization:
- ( \mathbf{w}_0 = (0, 0) )
Iteration 1:
- Misclassified point: ( \mathbf{x}_1 = (0, 1) ), ( y_1 = +1 )
- Weight update: ( \mathbf{w}_1 = \mathbf{w}_0 + y_1 \mathbf{x}_1 = (0, 1) )
Iteration 2:
- Misclassified point: ( \mathbf{x}_3 = (1, 0.5) ), ( y_3 = -1 )
- Weight update: ( \mathbf{w}_2 = \mathbf{w}_1 + y_3 \mathbf{x}_3 = (0, 1) + (-1)(1, 0.5) = (-1, 0.5) )
Iteration 3:
- Misclassified point: ( \mathbf{x}_2 = (1, 1) ), ( y_2 = +1 )
- Weight update: ( \mathbf{w}_3 = \mathbf{w}_2 + y_2 \mathbf{x}_2 = (-1, 0.5) + (1, 1) = (0, 1.5) )
Iteration 4:
- Misclassified point: ( \mathbf{x}_3 = (1, 0.5) ), ( y_3 = -1 )
- Weight update: ( \mathbf{w}_4 = \mathbf{w}_3 + y_3 \mathbf{x}_3 = (0, 1.5) + (-1)(1, 0.5) = (-1, 1) )
Iteration 5:
- Misclassified point: ( \mathbf{x}_2 = (1, 1) ), ( y_2 = +1 )
- Weight update: ( \mathbf{w}_5 = \mathbf{w}_4 + y_2 \mathbf{x}_2 = (-1, 1) + (1, 1) = (0, 2) )
Iteration 6:
- Misclassified point: ( \mathbf{x}_3 = (1, 0.5) ), ( y_3 = -1 )
- Weight update: ( \mathbf{w}_6 = \mathbf{w}_5 + y_3 \mathbf{x}_3 = (0, 2) + (-1)(1, 0.5) = (-1, 1.5) )
Final Weights:
- ( \mathbf{w}_6 = (-1, 1.5) )
With ( \mathbf{w}_6 ), all data points are correctly classified:
- ( \mathbf{w}_6 \cdot (0, 1) = 1.5 > 0 ) ➔ Correctly classified as ( +1 )
- ( \mathbf{w}_6 \cdot (1, 1) = 0.5 > 0 ) ➔ Correctly classified as ( +1 )
- ( \mathbf{w}_6 \cdot (1, 0.5) = -0.25 < 0 ) ➔ Correctly classified as ( -1 )
Thus, the perceptron algorithm converges after 6 iterations, and the iterative updates are completed as above.