Code RoomPerceptron training epoch
MediumPrep Room Coding #235

Perceptron training epoch

CodingML systemsMid–Senior~25 min

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.

Implement
perceptron_epoch(weights: list[float], bias: float, X: list[list[float]], y: list[int], learning_rate: float) → list
Examples
in[[0,0],0,[[1,1]],[1],1]out[[0,0],0]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 25 min
InputExpectedGot
[[0,0],0,[[1,1]],[1],1][[0,0],0]not run yetsample