Search code examples
python-3.xscikit-learnclassification

Get label names from sklearn model


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?


Solution

  • model.classes_ will show the labels in the model.