train_test_split
functiontrain_test_split(*arrays, test_size=None, train_size=None, random_state=None, stratify=None, shuffle=True)Split arrays into reproducible training and test subsets.
ML API atlas / 211 entries / 16 categories
Search the APIs that carry a project from first split to saved pipeline. Filter by workflow stage or library, then read the signature before you reach for autocomplete.
211 APIs
10 APIs
Splitting, validation, and the small helpers every workflow touches.
train_test_split(*arrays, test_size=None, train_size=None, random_state=None, stratify=None, shuffle=True)Split arrays into reproducible training and test subsets.
cross_val_score(estimator, X, y=None, *, groups=None, cv=None, scoring=None, n_jobs=None)Return one score per cross-validation fold for an estimator.
cross_validate(estimator, X, y=None, *, groups=None, scoring=None, cv=None, return_train_score=False, n_jobs=None)Run cross-validation and return fit, score, and timing details.
KFold(n_splits=5, *, shuffle=False, random_state=None)Yield train and test indices for k contiguous folds.
StratifiedKFold(n_splits=5, *, shuffle=False, random_state=None)Keep class proportions in every fold of a classification split.
GroupKFold(n_splits=5)Keep rows from the same group inside a single fold.
ShuffleSplit(n_splits=10, *, test_size=None, train_size=None, random_state=None)Draw repeated random train and test index sets.
learning_curve(estimator, X, y, *, train_sizes=..., cv=None, scoring=None, n_jobs=None)Measure training and validation scores as the training set grows.
validation_curve(estimator, X, y, *, param_name, param_range, cv=None, scoring=None)Sweep one hyperparameter and report training versus validation score.
check_cv(cv=5, y=None, *, classifier=False)Normalize an integer, splitter, or iterable into a CV splitter.
24 APIs
Scaling, encoding, imputing, and turning raw columns into model input.
StandardScaler(*, with_mean=True, with_std=True)Center features and scale them to unit variance.
MinMaxScaler(feature_range=(0, 1), *, copy=True, clip=False)Scale each feature into a fixed range such as zero to one.
RobustScaler(*, with_centering=True, with_scaling=True, quantile_range=(25.0, 75.0))Scale with median and interquartile range so outliers matter less.
MaxAbsScaler(*, copy=True)Scale by the largest absolute value, preserving sparse zeros.
Normalizer(norm='l2', *, copy=True)Scale each row to unit norm for distance-based models.
OneHotEncoder(*, categories='auto', drop=None, sparse_output=True, handle_unknown='error')Turn categorical values into indicator columns.
OrdinalEncoder(*, categories='auto', handle_unknown='error', unknown_value=None)Map categories to integer codes, optionally in a chosen order.
LabelEncoder()Encode target labels as integers from zero to n_classes minus one.
TargetEncoder(categories='auto', target_type='auto', smooth='auto', cv=5, random_state=None)Replace categories with smoothed, cross-fitted target averages.
KBinsDiscretizer(n_bins=5, *, encode='onehot', strategy='quantile', subsample=None)Bucket continuous features into ordered bins.
SimpleImputer(*, missing_values=nan, strategy='mean', fill_value=None, add_indicator=False)Fill missing values with a mean, median, mode, or constant.
KNNImputer(*, missing_values=nan, n_neighbors=5, weights='uniform', metric='nan_euclidean')Fill missing values from the nearest complete rows.
IterativeImputer(*, estimator=None, max_iter=10, random_state=None, add_indicator=False)Model each feature with missing values as a function of the others.
MissingIndicator(*, missing_values=nan, features='missing-only', sparse='auto', error_on_new=True)Add boolean columns that record where values were missing.
PolynomialFeatures(degree=2, *, interaction_only=False, include_bias=True)Create interaction and power terms from numeric columns.
SplineTransformer(n_knots=5, degree=3, *, knots='uniform', extrapolation='constant')Expand each feature into a smooth spline basis.
FunctionTransformer(func=None, inverse_func=None, *, validate=False, accept_sparse=False)Wrap a plain function so it can live inside a pipeline.
Binarizer(*, threshold=0.0, copy=True)Threshold features into zero or one.
MultiLabelBinarizer(*, classes=None, sparse_output=False)Encode lists of labels as a binary indicator matrix.
ColumnTransformer(transformers, *, remainder='drop', sparse_threshold=0.3, verbose_feature_names_out=True)Apply different preprocessing steps to selected column groups.
FeatureUnion(transformer_list, *, n_jobs=None, transformer_weights=None, verbose=False)Concatenate the outputs of several feature transformers.
make_column_transformer(*transformers, remainder='drop', sparse_threshold=0.3, verbose_feature_names_out=True)Build a ColumnTransformer with terser positional syntax.
make_column_selector(pattern=None, *, dtype_include=None, dtype_exclude=None)Select DataFrame columns by name pattern or dtype.
add_dummy_feature(X, value=1.0)Prepend a constant column for an explicit intercept term.
16 APIs
Keep the signal and drop the noise before a model learns from it.
VarianceThreshold(threshold=0.0)Drop features whose variance is below a threshold.
SelectKBest(score_func=f_classif, *, k=10)Keep the k highest-scoring features from a univariate test.
SelectPercentile(score_func=f_classif, *, percentile=10)Keep a percentile of features ranked by a univariate score.
SelectFpr(score_func=f_classif, *, alpha=0.05)Keep features whose false positive rate is below alpha.
SelectFdr(score_func=f_classif, *, alpha=0.05)Control the expected false discovery rate among selected features.
SelectFwe(score_func=f_classif, *, alpha=0.05)Control the family-wise error rate of feature tests.
GenericUnivariateSelect(score_func=f_classif, *, mode='percentile', param=1e-5)Configure a univariate selector by mode and parameter.
RFE(estimator, n_features_to_select=None, *, step=1, importance_getter='auto')Recursively remove the least important features.
RFECV(estimator, *, step=1, min_features_to_select=1, cv=None, scoring=None)Choose the number of features by cross-validated recursive elimination.
SelectFromModel(estimator, *, threshold=None, prefit=False, max_features=None)Keep features whose importance exceeds a threshold.
SequentialFeatureSelector(estimator, *, n_features_to_select='auto', direction='forward', cv=5)Greedily add or remove features while scoring the model.
chi2(X, y)Score nonnegative features with a chi-squared test.
f_classif(X, y)ANOVA F-score for features against class labels.
f_regression(X, y, *, center=True, force_finite=True)Univariate linear F-score between features and a numeric target.
mutual_info_classif(X, y, *, discrete_features='auto', n_neighbors=3)Estimate nonlinear dependency between features and classes.
mutual_info_regression(X, y, *, discrete_features='auto', n_neighbors=3)Estimate nonlinear dependency between features and a target.
29 APIs
Regression and classification where predictions are linear in the inputs.
LinearRegression(*, fit_intercept=True, copy_X=True, n_jobs=None, positive=False)Fit ordinary least squares regression with optional nonnegative coefficients.
Ridge(alpha=1.0, *, fit_intercept=True, solver='auto', positive=False)Least squares regression with an L2 penalty on coefficients.
RidgeCV(alphas=(0.1, 1.0, 10.0), *, cv=None, scoring=None)Choose the Ridge alpha by cross-validation in one fit.
Lasso(alpha=1.0, *, fit_intercept=True, max_iter=1000, positive=False)Linear regression with an L1 penalty that can zero coefficients.
LassoCV(*, eps=1e-3, n_alphas=100, alphas=None, cv=None, random_state=None)Search the Lasso regularization path with cross-validation.
ElasticNet(alpha=1.0, *, l1_ratio=0.5, fit_intercept=True, positive=False)Combine L1 and L2 penalties with a tunable mixing ratio.
ElasticNetCV(*, l1_ratio=0.5, alphas=None, cv=None, random_state=None)Tune ElasticNet alpha and mixing ratio by cross-validation.
Lars(*, fit_intercept=True, n_nonzero_coefs=500, precompute='auto')Follow the least-angle regression path for sparse coefficients.
LassoLars(alpha=1.0, *, fit_intercept=True, precompute='auto')Solve Lasso with the least-angle regression algorithm.
BayesianRidge(*, n_iter=300, alpha_1=1e-6, lambda_1=1e-6)Fit a Bayesian linear model and expose predictive uncertainty.
ARDRegression(*, n_iter=300, alpha_1=1e-6, lambda_1=1e-6)Sparse Bayesian regression with automatic relevance determination.
HuberRegressor(*, epsilon=1.35, alpha=0.0001, max_iter=100)Robust linear regression that limits the influence of outliers.
RANSACRegressor(estimator=None, *, min_samples=None, residual_threshold=None)Fit a model repeatedly on random inlier samples.
TheilSenRegressor(*, fit_intercept=True, max_subpopulation=10000)Median-of-slopes regression with high breakdown against outliers.
SGDRegressor(loss='squared_error', *, penalty='l2', alpha=0.0001, learning_rate='invscaling')Train a linear regressor with stochastic gradient descent.
PoissonRegressor(*, alpha=1.0, fit_intercept=True, max_iter=100)Generalized linear model for nonnegative count targets.
GammaRegressor(*, alpha=1.0, fit_intercept=True, max_iter=100)Generalized linear model for positive continuous targets.
TweedieRegressor(*, power=0, alpha=1.0, link='auto', max_iter=100)Fit a GLM across normal, Poisson, gamma, and Tweedie targets.
QuantileRegressor(*, quantile=0.5, alpha=1.0, solver='highs')Predict a conditional quantile instead of the mean.
LogisticRegression(penalty='l2', *, C=1.0, solver='lbfgs', max_iter=100, class_weight=None)Fit a linear classifier with a logistic loss.
LogisticRegressionCV(*, Cs=10, cv=None, penalty='l2', scoring=None, max_iter=100)Choose the inverse regularization strength by cross-validation.
RidgeClassifier(alpha=1.0, *, fit_intercept=True, class_weight=None)Classify with a ridge regression objective on class labels.
SGDClassifier(loss='hinge', *, penalty='l2', alpha=0.0001, max_iter=1000)Train a linear classifier with stochastic gradient descent.
Perceptron(*, penalty=None, alpha=0.0001, max_iter=1000, eta0=1.0)Fit the classic mistake-driven linear threshold classifier.
PassiveAggressiveClassifier(*, C=1.0, max_iter=1000, average=False)Update linear weights only when a margin mistake occurs.
LinearSVC(penalty='l2', *, C=1.0, loss='squared_hinge', multi_class='ovr')Fast linear support vector classifier for large sparse data.
LinearSVR(*, epsilon=0.0, C=1.0, loss='epsilon_insensitive', max_iter=1000)Linear support vector regression with an epsilon-insensitive loss.
LinearDiscriminantAnalysis(*, solver='svd', shrinkage=None, priors=None)Gaussian classifier that assumes a shared covariance per class.
QuadraticDiscriminantAnalysis(*, priors=None, reg_param=0.0)Gaussian classifier with a separate covariance for each class.
10 APIs
Single decision trees for rules, splits, and feature insight.
DecisionTreeClassifier(*, criterion='gini', max_depth=None, min_samples_leaf=1, random_state=None)Learn a tree of axis-aligned splits for classification.
DecisionTreeRegressor(*, criterion='squared_error', max_depth=None, min_samples_leaf=1, random_state=None)Learn a tree of splits that predicts a numeric target.
ExtraTreeClassifier(*, criterion='gini', max_depth=None, splitter='random')A single extremely randomized tree, mostly used inside ensembles.
ExtraTreeRegressor(*, criterion='squared_error', max_depth=None, splitter='random')A single extremely randomized regression tree.
export_text(decision_tree, *, feature_names=None, max_depth=10, decimals=2)Render a fitted tree as a readable text rule list.
export_graphviz(decision_tree, out_file=None, *, feature_names=None, class_names=None)Export a tree in Graphviz DOT format.
plot_tree(decision_tree, *, max_depth=None, feature_names=None, class_names=None)Draw a fitted tree with Matplotlib.
apply(X, check_input=True)Return the index of the leaf each sample lands in.
decision_path(X, check_input=True)Return the sparse indicator matrix of nodes each sample visits.
cost_complexity_pruning_path(X, y, sample_weight=None)List alphas and impurities for pruning a fitted tree.
17 APIs
Random forests, gradient boosting, and voting across many estimators.
RandomForestClassifier(n_estimators=100, *, max_depth=None, max_features='sqrt', class_weight=None, n_jobs=None)Average many decorrelated decision trees for classification.
RandomForestRegressor(n_estimators=100, *, max_depth=None, max_features=1.0, n_jobs=None)Average many decorrelated decision trees for regression.
ExtraTreesClassifier(n_estimators=100, *, max_depth=None, max_features='sqrt')Random forest variant that randomizes split thresholds too.
ExtraTreesRegressor(n_estimators=100, *, max_depth=None, max_features=1.0)Extremely randomized trees for regression.
GradientBoostingClassifier(*, loss='log_loss', learning_rate=0.1, n_estimators=100, max_depth=3)Fit shallow trees sequentially to reduce the loss.
GradientBoostingRegressor(*, loss='squared_error', learning_rate=0.1, n_estimators=100, max_depth=3)Fit sequential trees to the negative gradient of a regression loss.
HistGradientBoostingClassifier(*, learning_rate=0.1, max_iter=100, max_leaf_nodes=31, early_stopping='auto')Fast histogram-based gradient boosting for larger datasets.
HistGradientBoostingRegressor(*, loss='squared_error', learning_rate=0.1, max_iter=100, early_stopping='auto')Histogram-based gradient boosting for regression.
AdaBoostClassifier(estimator=None, *, n_estimators=50, learning_rate=1.0)Reweight misclassified rows to build a boosted classifier.
AdaBoostRegressor(estimator=None, *, n_estimators=50, learning_rate=1.0, loss='linear')Boost weak regressors by focusing on large residuals.
BaggingClassifier(estimator=None, n_estimators=10, *, max_samples=1.0, max_features=1.0)Train one base estimator per bootstrap sample and vote.
BaggingRegressor(estimator=None, n_estimators=10, *, max_samples=1.0, max_features=1.0)Train one base regressor per bootstrap sample and average.
VotingClassifier(estimators, *, voting='hard', weights=None, n_jobs=None)Combine different classifiers with hard or soft voting.
VotingRegressor(estimators, *, weights=None, n_jobs=None)Average predictions from several heterogeneous regressors.
StackingClassifier(estimators, *, final_estimator=None, cv=None, stack_method='auto')Feed out-of-fold base predictions into a final classifier.
StackingRegressor(estimators, *, final_estimator=None, cv=None)Feed out-of-fold base predictions into a final regressor.
RandomTreesEmbedding(n_estimators=10, *, max_depth=5, sparse_output=True)Encode rows by the leaves they reach in a random forest.
10 APIs
Instance-based learning and margin-based classifiers for small datasets.
KNeighborsClassifier(n_neighbors=5, *, weights='uniform', metric='minkowski', p=2)Classify a row by the votes of its nearest training neighbors.
KNeighborsRegressor(n_neighbors=5, *, weights='uniform', metric='minkowski', p=2)Predict the average target of the nearest training rows.
RadiusNeighborsClassifier(*, radius=1.0, weights='uniform', outlier_label=None)Classify using neighbors inside a fixed radius.
RadiusNeighborsRegressor(*, radius=1.0, weights='uniform', metric='minkowski')Average targets inside a fixed-radius neighborhood.
NearestNeighbors(*, n_neighbors=5, radius=1.0, algorithm='auto', metric='minkowski')Find nearest rows without attaching a prediction target.
kneighbors_graph(X, n_neighbors, *, mode='connectivity', metric='minkowski', include_self=False)Build a sparse graph connecting each row to its neighbors.
SVC(*, C=1.0, kernel='rbf', degree=3, gamma='scale', class_weight=None, probability=False)Support vector classifier with nonlinear kernels and margins.
SVR(*, kernel='rbf', degree=3, gamma='scale', C=1.0, epsilon=0.1)Support vector regression that ignores small residuals.
NuSVC(*, nu=0.5, kernel='rbf', degree=3, gamma='scale')SVC variant parameterized by an upper bound on margin errors.
NuSVR(*, nu=0.5, C=1.0, kernel='rbf', gamma='scale')SVR variant that controls the fraction of support vectors.
5 APIs
Fast probabilistic baselines for text and tabular counts.
GaussianNB(*, priors=None, var_smoothing=1e-9)Naive Bayes for continuous features that look roughly Gaussian.
MultinomialNB(*, alpha=1.0, force_alpha=True, fit_prior=True)Naive Bayes for nonnegative counts such as word frequencies.
BernoulliNB(*, alpha=1.0, binarize=0.0, fit_prior=True)Naive Bayes over boolean or binarized features.
ComplementNB(*, alpha=1.0, norm=False, fit_prior=True)Naive Bayes variant designed for imbalanced text classes.
CategoricalNB(*, alpha=1.0, min_categories=None, fit_prior=True)Naive Bayes for features that are already category codes.
17 APIs
Group unlabeled rows, find density, and score the result.
KMeans(n_clusters=8, *, init='k-means++', n_init='auto', max_iter=300, random_state=None)Partition rows into k clusters by minimizing within-cluster distance.
MiniBatchKMeans(n_clusters=8, *, batch_size=1024, n_init='auto', max_iter=100)Faster approximate k-means using batches of rows.
DBSCAN(eps=0.5, *, min_samples=5, metric='euclidean')Find dense regions and label low-density rows as noise.
OPTICS(*, min_samples=5, max_eps=inf, metric='minkowski', cluster_method='xi')Order points by reachability distance to find variable-density clusters.
HDBSCAN(*, min_cluster_size=5, min_samples=None, cluster_selection_epsilon=0.0)Hierarchical density clustering with automatic cluster counts.
AgglomerativeClustering(n_clusters=2, *, linkage='ward', metric='euclidean')Merge rows bottom-up into a hierarchy of clusters.
Birch(*, threshold=0.5, branching_factor=50, n_clusters=3)Build a compact clustering feature tree for large datasets.
SpectralClustering(n_clusters=8, *, affinity='rbf', assign_labels='kmeans')Cluster with eigenvectors of a similarity graph.
AffinityPropagation(*, damping=0.5, max_iter=200, random_state=None)Choose exemplars by passing messages between rows.
MeanShift(*, bandwidth=None, bin_seeding=False, cluster_all=True)Find modes of a density estimate without a cluster count.
silhouette_score(X, labels, *, metric='euclidean', sample_size=None, random_state=None)Measure how much closer rows are to their own cluster than the next.
silhouette_samples(X, labels, *, metric='euclidean')Return one silhouette value per row.
calinski_harabasz_score(X, labels)Ratio of between-cluster to within-cluster dispersion.
davies_bouldin_score(X, labels)Average similarity between each cluster and its most similar cluster.
adjusted_rand_score(labels_true, labels_pred)Chance-adjusted agreement between two labelings.
normalized_mutual_info_score(labels_true, labels_pred, *, average_method='arithmetic')Shared information between two labelings, normalized to one.
homogeneity_completeness_v_measure(labels_true, labels_pred, *, beta=1.0)Return homogeneity, completeness, and their harmonic mean together.
11 APIs
Compress features, denoise, and inspect structure with matrix methods.
PCA(n_components=None, *, whiten=False, svd_solver='auto', random_state=None)Project features onto the directions of greatest variance.
IncrementalPCA(n_components=None, *, batch_size=None, whiten=False)Fit PCA in batches for data that does not fit in memory.
KernelPCA(n_components=None, *, kernel='linear', gamma=None, eigen_solver='auto')Nonlinear dimensionality reduction with a kernel.
TruncatedSVD(n_components=2, *, algorithm='randomized', n_iter=5, random_state=None)Reduce sparse matrices without centering them.
NMF(n_components=None, *, init='nndsvda', solver='cd', max_iter=200)Factor a nonnegative matrix into nonnegative parts.
LatentDirichletAllocation(n_components=10, *, learning_method='batch', max_iter=10)Model documents as mixtures of latent topics.
FactorAnalysis(n_components=None, *, tol=0.01, max_iter=1000, rotation=None)Explain correlated features with a smaller set of latent factors.
FastICA(n_components=None, *, algorithm='parallel', whiten='unit-variance', random_state=None)Separate independent signals from mixed observations.
DictionaryLearning(n_components=None, *, alpha=1.0, max_iter=1000, random_state=None)Learn a sparse dictionary that reconstructs the rows.
SparsePCA(n_components=None, *, alpha=1.0, max_iter=1000, random_state=None)Find sparse components that are easier to interpret.
randomized_svd(M, n_components, *, n_oversamples=10, n_iter='auto', random_state=None)Compute a fast approximate truncated SVD.
3 APIs
Small multilayer perceptrons and the knobs that keep them stable.
MLPClassifier(hidden_layer_sizes=(100,), *, activation='relu', solver='adam', alpha=0.0001, max_iter=200)Train a feed-forward neural network for classification.
MLPRegressor(hidden_layer_sizes=(100,), *, activation='relu', solver='adam', alpha=0.0001, max_iter=200)Train a feed-forward neural network for regression.
BernoulliRBM(*, n_components=256, learning_rate=0.1, n_iter=10, random_state=None)Learn a restricted Boltzmann machine as a feature transformer.
11 APIs
Search parameters and compare candidates without leaking test data.
GridSearchCV(estimator, param_grid, *, scoring=None, n_jobs=None, cv=None, refit=True)Exhaustively evaluate every parameter combination by cross-validation.
RandomizedSearchCV(estimator, param_distributions, *, n_iter=10, scoring=None, cv=None)Sample a fixed number of parameter combinations.
HalvingGridSearchCV(estimator, param_grid, *, factor=3, resource='n_samples', cv=5)Search a grid while eliminating weak candidates early.
HalvingRandomSearchCV(estimator, param_distributions, *, n_candidates='exhaust', factor=3, cv=5)Sample candidates and eliminate weak ones across rounds.
ParameterGrid(param_grid)Iterate over every dictionary in a parameter grid.
ParameterSampler(param_distributions, n_iter, *, random_state=None)Sample parameter dictionaries from distributions.
PredefinedSplit(test_fold)Use caller-supplied fold assignments.
LeaveOneOut()Hold out one row per fold for very small datasets.
RepeatedKFold(*, n_splits=5, n_repeats=10, random_state=None)Repeat shuffled k-fold splits for a more stable estimate.
RepeatedStratifiedKFold(*, n_splits=5, n_repeats=10, random_state=None)Repeat stratified folds for classification.
GroupShuffleSplit(n_splits=5, *, test_size=None, train_size=None, random_state=None)Randomly split whole groups into train and test.
30 APIs
Score regression, classification, ranking, and clustering honestly.
accuracy_score(y_true, y_pred, *, normalize=True, sample_weight=None)Fraction of labels predicted correctly.
balanced_accuracy_score(y_true, y_pred, *, sample_weight=None, adjusted=False)Average recall across classes, so majority labels do not dominate.
top_k_accuracy_score(y_true, y_score, *, k=2, normalize=True, labels=None)Fraction of rows whose true label is among the k highest scores.
precision_score(y_true, y_pred, *, labels=None, average='binary', zero_division='warn')Of the rows predicted positive, how many really were positive.
recall_score(y_true, y_pred, *, labels=None, average='binary', zero_division='warn')Of the truly positive rows, how many were found.
f1_score(y_true, y_pred, *, labels=None, average='binary', zero_division='warn')Harmonic mean of precision and recall.
fbeta_score(y_true, y_pred, *, beta, average='binary', zero_division='warn')Weight precision and recall differently with a beta value.
precision_recall_fscore_support(y_true, y_pred, *, beta=1.0, labels=None, average=None, zero_division='warn')Return precision, recall, F-score, and support in one pass.
classification_report(y_true, y_pred, *, labels=None, target_names=None, digits=2)Format per-class precision, recall, F1, and support as text.
confusion_matrix(y_true, y_pred, *, labels=None, sample_weight=None, normalize=None)Count true versus predicted labels in a matrix.
multilabel_confusion_matrix(y_true, y_pred, *, sample_weight=None, labels=None)Build one binary confusion matrix per label.
roc_auc_score(y_true, y_score, *, average='macro', multi_class='raise', max_fpr=None)Area under the receiver operating characteristic curve.
roc_curve(y_true, y_score, *, pos_label=None, sample_weight=None, drop_intermediate=True)Compute false positive and true positive rates across thresholds.
auc(x, y)Integrate a curve with the trapezoidal rule.
precision_recall_curve(y_true, probas_pred, *, pos_label=None, sample_weight=None)Track precision and recall as the decision threshold moves.
average_precision_score(y_true, y_score, *, average='macro', pos_label=1)Summarize a precision-recall curve with a weighted mean precision.
log_loss(y_true, y_pred, *, eps='auto', normalize=True, labels=None)Penalize confident wrong probabilities with cross-entropy.
brier_score_loss(y_true, y_proba, *, sample_weight=None, pos_label=None)Mean squared error between predicted probabilities and outcomes.
matthews_corrcoef(y_true, y_pred, *, sample_weight=None)Balanced correlation score for binary and multiclass labels.
cohen_kappa_score(y1, y2, *, labels=None, weights=None, sample_weight=None)Agreement between two labelings after chance correction.
hinge_loss(y_true, pred_decision, *, labels=None, sample_weight=None)Margin loss used by support vector machines.
mean_absolute_error(y_true, y_pred, *, sample_weight=None, multioutput='uniform_average')Average absolute difference between predictions and targets.
mean_squared_error(y_true, y_pred, *, sample_weight=None, multioutput='uniform_average')Average squared difference, sensitive to large errors.
root_mean_squared_error(y_true, y_pred, *, sample_weight=None, multioutput='uniform_average')Square root of mean squared error in the target's units.
mean_absolute_percentage_error(y_true, y_pred, *, sample_weight=None)Average absolute percentage error, undefined near zero targets.
r2_score(y_true, y_pred, *, sample_weight=None, multioutput='uniform_average', force_finite=True)Fraction of target variance explained by the predictions.
explained_variance_score(y_true, y_pred, *, sample_weight=None, multioutput='uniform_average')Variance of the target explained after removing prediction bias.
median_absolute_error(y_true, y_pred, *, multioutput='uniform_average')Median absolute error, robust to a few extreme residuals.
max_error(y_true, y_pred)Largest absolute residual in the dataset.
mean_pinball_loss(y_true, y_pred, *, sample_weight=None, alpha=0.5)Quantile loss for evaluating interval and quantile predictions.
4 APIs
Turn scores into probabilities and choose a decision threshold.
CalibratedClassifierCV(estimator=None, *, method='sigmoid', cv=None, ensemble=True)Wrap a classifier so its scores behave like probabilities.
calibration_curve(y_true, y_prob, *, pos_label=None, n_bins=5, strategy='uniform')Compare predicted confidence with observed positive rate.
FrozenEstimator(estimator, *, fit_parameters=None)Wrap a fitted estimator so meta-estimators reuse it unchanged.
IsotonicRegression(*, y_min=None, y_max=None, increasing=True, out_of_bounds='nan')Fit a monotonic piecewise-linear calibration curve.
5 APIs
Detect unusual rows and validate models without looking into the future.
IsolationForest(*, n_estimators=100, max_samples='auto', contamination='auto', random_state=None)Score outliers by how quickly random splits isolate them.
LocalOutlierFactor(n_neighbors=20, *, contamination='auto', novelty=False)Flag rows whose local density is much lower than their neighbors.
OneClassSVM(*, kernel='rbf', gamma='scale', nu=0.5)Learn a boundary around normal rows for novelty detection.
EllipticEnvelope(*, store_precision=True, assume_centered=False, support_fraction=None)Fit a robust Gaussian ellipse and flag far-away rows.
TimeSeriesSplit(n_splits=5, *, max_train_size=None, test_size=None, gap=0)Validate time-ordered data with strictly future test folds.
9 APIs
Bundle preprocessing with a model and save the fitted result safely.
Pipeline(steps, *, memory=None, verbose=False)Chain preprocessing and a final estimator into one object.
make_pipeline(*steps, memory=None, verbose=False)Build a Pipeline without naming each step.
TransformedTargetRegressor(*, regressor=None, transformer=None, func=None, inverse_func=None)Transform the target for fitting and invert predictions.
make_scorer(score_func, *, response_method=None, greater_is_better=True, **kwargs)Wrap a custom metric as a scoring callable.
get_scorer(scoring)Look up a scoring callable by its registered name.
clone(estimator, *, safe=True)Copy an estimator with identical unfitted parameters.
config_context(**new_config)Temporarily change global scikit-learn display and validation settings.
dump(value, filename, *, compress=0, protocol=None)Persist a fitted pipeline or array to disk.
load(filename, *, mmap_mode=None)Load an object written by joblib.dump.