plot_confusion_matrix() got an unexpected keyword argument 'title'

Viewed 23

The code below throws the error plot_confusion_matrix() got an unexpected keyword argument 'title':

from sklearn.feature_extraction.text import CountVectorizer
from sklearn.feature_extraction.text import TfidfTransformer
from sklearn.naive_bayes import MultinomialNB
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import plot_confusion_matrix
from sklearn.pipeline import Pipeline

text_clf = Pipeline([('vect', CountVectorizer()), ('tfidf', TfidfTransformer()),('clf', RandomForestClassifier(class_weight='balanced', n_estimators=100))])

text_clf.fit(tokenizer.sequences_to_texts_generator(train_text_vec), y_train.argmax(axis=1)) 
predictions = text_clf.predict(tokenizer.sequences_to_texts_generator(test_text_vec))  

print('Baseline Accuracy Using Naive Bayes: ', (predictions == y_test.argmax(axis = 1)).mean()) 

print('F1 Score:', f1_score(y_test.argmax(axis = 1), predictions, average='weighted')) 

conf = plot_confusion_matrix(y_test.argmax(axis = 1), predictions, labels=encoder.classes_, title='Confusion matrix, without normalization')
1 Answers
Related