1
$\begingroup$

Learning to do Linear Discriminant Analysis with sklearn, and a bit confused about the scalings_ attribute of the fitted model. The LDA classifier can be written as

$$\delta_k(x)=x^{T}\Sigma^{-1} \mu_k + C_k,$$

with $C_k$ a constant not dependent on $x$. The documentation says the scalings are the linear combinations of the predictors, so I assumed this was the $\Sigma^{-1} \mu_k$ term.

But, after fitting a LDA classifier lda.fit(X_train,Y_train) and comparing

np.lingalg.inv(lda.covariance_) @ lda.means_

lda.scalings_,

they are different, and I can see that I was wrong as the two results aren't the same. In fact, the first result is a $2 \times 2$ matrix, and the second result is $1 \times 2$ row vector. So, not sure where my misunderstands lie. Thank you for reading.

$\endgroup$
1
  • $\begingroup$ Please do LDA of iris data and match your results with described in an answer here stats.stackexchange.com/q/82497/3277. It will help understand what "scalings" are called in other software. This a good point to start from. $\endgroup$
    – ttnphns
    Commented Dec 5, 2023 at 14:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.