Python✓ Mathematical
◆ The PatternThe Swiss army knife — classification_report, cross_val_score, learning_curve, and the metrics module
scikit-learn includes everything covered in this toolkit under one roof. The metrics module has every scorer, model_selection has every CV strategy, and inspection has permutation importance and partial dependence.
// The scikit-learn evaluation workflow
# Complete sklearn evaluation workflow from sklearn.model_selection import ( cross_val_score, learning_curve, GridSearchCV ) from sklearn.metrics import ( classification_report, confusion_matrix, roc_auc_score, mean_squared_error ) from sklearn.inspection import permutation_importance # 1. Cross-validated scores scores = cross_val_score(model, X, y, cv=5, scoring='f1') # 2. Full classification report model.fit(X_train, y_train) print(classification_report(y_test, model.predict(X_test))) # 3. Learning curves sizes, train_s, val_s = learning_curve(model, X, y, cv=5) # 4. Feature importance pi = permutation_importance(model, X_test, y_test, n_repeats=30) # 5. Hyperparameter tuning grid = GridSearchCV(model, param_grid, cv=5, scoring='f1') grid.fit(X_train, y_train)
| Module | Key functions | This toolkit topic |
|---|---|---|
| sklearn.metrics | classification_report, roc_auc_score, r2_score | Confusion Matrix, Regression |
| sklearn.model_selection | cross_val_score, TimeSeriesSplit, learning_curve | CV, Learning Curves |
| sklearn.inspection | permutation_importance, PartialDependenceDisplay | Permutation, PDP/ICE |
| sklearn.feature_selection | mutual_info_classif, SelectKBest | Information Gain |
Tip: Always use
Pipeline to chain preprocessing + model. This prevents data leakage in CV and makes deployment trivial.