user13898619
user13898619

Reputation:

DecisionTreeClassifier model.fit(X, y) command is returning an error

I am coding a model to predict travel times based of a distance. I am getting

ValueError: Unknown label type: 'continuous' error when I run this code:

import pandas as pd

from sklearn.tree import DecisionTreeClassifier
times = pd.read_csv('SC.csv')
X = times.drop(columns=['Time'])
y = times.drop(columns=['distance'])

model = DecisionTreeClassifier()
model.fit(X, y)

Upvotes: 0

Views: 480

Answers (1)

Nicolas Gervais
Nicolas Gervais

Reputation: 36704

This is because your targets are float values, not integers. You might be trying to classify continuous targets.

Maybe try DecisionTreeRegressor(), or convert your targets to integers if your labels mistakenly got converted to float. Or double check you're using the right columns.

Upvotes: 1

Related Questions