The preceding logistic model learns a boundary directly. LDA instead describes where each class's points tend to lie and how they spread, then derives the boundary from those descriptions. Assuming both classes share one covariance is what makes that boundary linear.
Implement lda_fit(X, y) by splitting classes 0 and 1, estimating their means and shared covariance, then deriving the returned score vector and intercept.
X contains feature rows and y contains binary labels 0 and 1.w with one entry per feature and scalar b.n - 2.np.linalg.inv.b; unequal class sizes must affect the boundary.Open one at a time. Each gives away a little more than the last.
Boolean masks y == 0 and y == 1 separate the two populations without a loop.
Compute each class's centered scatter with (Xk - muk).T @ (Xk - muk), then pool before inverting.
No results yet
Run your code to check it against the examples, or submit to run every test.