compare_classifiers.ensemble_compare_f1

Functions

ensemble_compare_f1(estimators, X_train, y_train)

Show cross validation results, including fit time and f1 scores by stacking and voting the estimators.

Module Contents

compare_classifiers.ensemble_compare_f1.ensemble_compare_f1(estimators, X_train, y_train)[source]

Show cross validation results, including fit time and f1 scores by stacking and voting the estimators.

Parameters:
  • estimators (list of tuples) – A list of (name, estimator) tuples, consisting of individual estimators to be processed through the voting or stacking classifying ensemble. Each tuple contains a string: name/label of estimator, and a model: the estimator, which implements the scikit-learn API (fit, predict, etc.).

  • X_train (Pandas data frame) – Data frame containing training data along with n features or ndarray with no feature names.

  • y_train (Pandas series or Numpy array) – Target class labels for data in X_train.

Returns:

A data frame showing cross validation results on training data, with 3 columns: fit_time, test_score, train_score and 2 rows: voting, stacking.

Return type:

Pandas data frame

Examples

>>> estimators = [
...     ('rf', RandomForestClassifier(n_estimators=10, random_state=42)),
...     ('svm', make_pipeline(StandardScaler(), LinearSVC(random_state=42)))
... ]
>>> ensemble_compare_f1(estimators, X, y)