← 返回 uber 的题目列表ML Coding: Logistic Regression from Scratch
类型:online_judge
Implement core pieces of binary logistic regression from scratch.
Given training data X (shape n x d) and labels y (0/1), implement:
Forward pass: p = sigmoid(Xw + b)
Loss: Binary Cross Entropy (log loss)
Gradient descent updates for w, b
Provide the mathematical definition of Binary Cross Entropy and explain why it is equivalent to minimizing the negative log-likelihood.
Derive the derivative of sigmoid(z).
Bonus
Compute a confusion matrix (TP/FP/TN/FN) from ground-truth labels and predicted labels (or probabilities + threshold).
Example
Input
4 2 200 0.1
0 0 0
0 1 0
1 0 0
1 1 1
Output
(parameters printed; values may vary depending on iterations/lr)