Perceptron training epoch
Your task
Perform one epoch of perceptron training. Given weights (a list of d floats), bias (a float), X (a list of samples, each a list of d floats), y (labels, each +1 or -1), and learning_rate, process the samples in order. For each sample, compute activation = dot(weights, x) + bias; the prediction is +1 if activation >= 0 else -1. On a misclassification (prediction != label), update weights[j] += learning_rate * label * x[j] for all j and bias += learning_rate * label. Return [updated_weights, updated_bias], with every number rounded to 6 decimals. There is at least one sample and d >= 1.
Examples
perceptron_epoch(weights: list[float], bias: float, X: list[list[float]], y: list[int], learning_rate: float) -> listExample 1
Input
perceptron_epoch([0, 0], 0, [[1, 1]], [1], 1)Output
[[0, 0], 0]