0
votes

When using sklearn, I sometimes have issues correctly assigning the output to the right label. When calling different methods on the result of a fit, sklearn only returns numpy arrays with no further labeling. For example, fitting a simple LDA that is trying to classify into two different groups will give me this output.

result = sklearn_lda.fit(X_train, y_train)

print "Prior probabilities are: \n", result.priors_
print "Group means are: \n", result.means_

Output

Prior probabilities are: 
[0.49198397 0.50801603]

Group means are: 
[[ 0.04279022  0.03389409]
 [-0.03954635 -0.03132544]]

How do I know which prior probability is associated with which class label? Same with the group means. For coefficients I know that sklearn outputs them in the same order as they are put in. In this case I am a little confused.

1

1 Answers

1
votes

Use result.classes_ to get the array of classes seen by the model. All other attributes will be in the order of this array.

Most probably this will be alphabetically sorted. So if you have classes A and B, then the order will be:

['A', 'B']

Please see the documentation for available attributes.