0
$\begingroup$

Is it possible to get the label names from an sklearn SGDClassifier model that is loaded from a pickle file?

model = pickle.load(open("saved_model.pkl", 'rb'))
y_pred = model.predict(x)

Because all the labels may not be present in the input vector, x, how can I know what the possible labels are?

$\endgroup$

1 Answer 1

0
$\begingroup$

model.classes_ will show the labels in the model. This is a public attribute of SGDClassifier object.

Reference

$\endgroup$
1
  • $\begingroup$ Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center. $\endgroup$
    – Community Bot
    Nov 27, 2022 at 2:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.