compare_classifiers.confusion_matrices

Functions

confusion_matrices(estimators, X_train, X_test, ...)

Display confusion matrices for multiple estimators on a dataset.

Module Contents

compare_classifiers.confusion_matrices.confusion_matrices(estimators, X_train, X_test, y_train, y_test)[source]

Display confusion matrices for multiple estimators on a dataset.

Parameters:

estimatorslist of tuples

A list of (name, estimator) tuples, each containing a string: name/label of estimator, and a model: the estimator, which implements the scikit-learn API (fit, predict, etc.).

X_trainPandas data frame or Numpy array

Data frame containing training data along with n features or ndarray with no feature names.

X_testPandas data frame or Numpy array

Data frame containing test data along with n features or ndarray with no feature names.

y_trainPandas series or Numpy array

Target class labels for data in X_train.

y_testPandas series or Numpy array

Target class labels for data in X_test.

Returns:

: axes : numpy.ndarray or list of matplotlib.axes.Axes

A 2D array (or list) of axes objects where the confusion matrices are plotted. Each element represents an individual subplot (axis) within the grid.

Example:

>>> estimators = [
...     ('rf', RandomForestClassifier(n_estimators=10, random_state=42)),
...     ('svm', make_pipeline(StandardScaler(), LinearSVC(random_state=42)))
... ]
>>> confusion_matrices(estimators, X_train, X_test, y_train, y_test)