ValueError: continuous is not supported in scikit-learn (tested)

ValueError: continuous is not supported means you passed float values (regression predictions or probabilities) to a classification metric such as confusion_matrix or accuracy_score. Pass class labels from predict(), or use a regression or probability metric instead. Tested on scikit-learn 1.9.1.

1. continuous is not supported

from sklearn.datasets import make_regression
from sklearn.linear_model import LinearRegression
from sklearn.metrics import confusion_matrix

X, y = make_regression(n_samples=100, n_features=3, noise=10, random_state=0)
pred = LinearRegression().fit(X, y).predict(X)
print(confusion_matrix(y, pred))

Output:

Traceback (most recent call last):
  File "/w/b1.py", line 7, in <module>
    print(confusion_matrix(y, pred))
          ~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/usr/local/lib/python3.15/site-packages/sklearn/utils/_param_validation.py", line 218, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.15/site-packages/sklearn/metrics/_classification.py", line 543, in confusion_matrix
    y_type, unique_labels, y_true, y_pred, sample_weight = _check_targets(
                                                           ~~~~~~~~~~~~~~^
        y_true, y_pred, sample_weight
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/local/lib/python3.15/site-packages/sklearn/metrics/_classification.py", line 145, in _check_targets
    raise ValueError("{0} is not supported".format(y_type))
ValueError: continuous is not supported

confusion_matrix, accuracy_score, precision_score, f1_score and classification_report are classification metrics. They first check the type of both label arrays; predictions from a regressor are floats like -7.26, which scikit-learn classifies as continuous, so it raises ValueError: continuous is not supported.

2. The variant: a mix of binary and continuous targets

from sklearn.datasets import load_breast_cancer
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score

X, y = load_breast_cancer(return_X_y=True)
clf = LogisticRegression(max_iter=10000).fit(X, y)
proba = clf.predict_proba(X)[:, 1]
print(accuracy_score(y, proba))

Output:

Traceback (most recent call last):
  File "/w/b2.py", line 8, in <module>
    print(accuracy_score(y, proba))
          ~~~~~~~~~~~~~~^^^^^^^^^^
  File "/usr/local/lib/python3.15/site-packages/sklearn/utils/_param_validation.py", line 218, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.15/site-packages/sklearn/metrics/_classification.py", line 405, in accuracy_score
    y_type, _, y_true, y_pred, sample_weight = _check_targets(
                                               ~~~~~~~~~~~~~~^
        y_true, y_pred, sample_weight
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/local/lib/python3.15/site-packages/sklearn/metrics/_classification.py", line 134, in _check_targets
    raise ValueError(
    ...<3 lines>...
    )
ValueError: Classification metrics can't handle a mix of binary and continuous targets

The same check, with true labels that are fine (0/1) and predictions that are probabilities. predict_proba returns values between 0 and 1, which are continuous, not labels.

3. Fix for classifiers: pass labels, or use a probability metric

from sklearn.datasets import load_breast_cancer
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score, roc_auc_score

X, y = load_breast_cancer(return_X_y=True)
clf = LogisticRegression(max_iter=10000).fit(X, y)
proba = clf.predict_proba(X)[:, 1]
print("accuracy (predict):   ", round(accuracy_score(y, clf.predict(X)), 4))
print("accuracy (proba>=0.5):", round(accuracy_score(y, (proba >= 0.5).astype(int)), 4))
print("roc_auc (proba):      ", round(roc_auc_score(y, proba), 4))

Output:

accuracy (predict):    0.9578
accuracy (proba>=0.5): 0.9578
roc_auc (proba):       0.9947

Use predict(), or threshold the probabilities yourself (same accuracy here: 0.9578). If you want to score the probabilities themselves, use a metric made for scores such as roc_auc_score or log_loss, which accept continuous values.

4. Fix for regression: use regression metrics

from sklearn.datasets import make_regression
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_absolute_error, r2_score

X, y = make_regression(n_samples=100, n_features=3, noise=10, random_state=0)
pred = LinearRegression().fit(X, y).predict(X)
print("MAE:", round(mean_absolute_error(y, pred), 3))
print("R2: ", round(r2_score(y, pred), 4))

Output:

MAE: 7.92
R2:  0.9831

If the target is a number (price, temperature, demand), there is no confusion matrix to compute. Use mean_absolute_error, mean_squared_error or r2_score, or bin the values into classes first (see Unknown label type: continuous).

5. What counts as continuous

import numpy as np
from sklearn.utils.multiclass import type_of_target

for y in ([0, 1, 1, 0], [0.0, 1.0, 1.0], [1.0, 2.0, 3.0], [0.5, 1.0, 0.0],
          [0.1, 0.9], np.array([0, 1], dtype=object), ["cat", "dog"]):
    print(repr(y), "->", type_of_target(y))

Output:

[0, 1, 1, 0] -> binary
[0.0, 1.0, 1.0] -> binary
[1.0, 2.0, 3.0] -> multiclass
[0.5, 1.0, 0.0] -> continuous
[0.1, 0.9] -> continuous
array([0, 1], dtype=object) -> unknown
['cat', 'dog'] -> binary

scikit-learn decides with type_of_target. Floats are fine if they are all whole numbers ([0.0, 1.0] is binary, [1.0, 2.0, 3.0] is multiclass); a single fractional value like 0.5 makes the whole array continuous. An object-dtype array of ints is unknown; convert it with .astype(int). Run type_of_target(y_true) and type_of_target(y_pred) to see which side is the problem.

Related: Unknown label type: continuous ยท suppress scikit-learn warnings.

Frequently asked questions

What does 'continuous is not supported' mean in sklearn?

A classification metric received float values that are not whole numbers (regression output or probabilities). sklearn's type_of_target calls them 'continuous'.

How do I fix 'Classification metrics can't handle a mix of binary and continuous targets'?

Pass labels: clf.predict(X) or (proba >= 0.5).astype(int). To score probabilities, use roc_auc_score or log_loss.

Can I compute accuracy for a regression model?

No. Use mean_absolute_error, mean_squared_error or r2_score, or bin the target into classes and train a classifier.

Written with AI assistance. Measured on 2026-10-23 in Docker: python:3-slim (Python 3.15.1) with scikit-learn 1.9.1. Each block was run verbatim and the output pasted unedited. PlainTables is our extension; Python and scikit-learn are free.