Reputation: 37
In training data: the datatype of x is "int64" and y is "categorical" I can't able to fit training data-set in this algorithm..
i am getting an error in the line "model.fit(x_train,y_train)"
the error is "object of type 'CategoricalDtype' has no len()"
x=df.drop("income",axis=1)
y=df["income"]
from sklearn.model_selection import train_test_split
x_train,x_test,y_train,y_test=train_test_split(x,y,train_size=0.3,random_state=100)
from sklearn.tree import DecisionTreeClassifier
model=DecisionTreeClassifier(max_depth=4)
model.fit(x_train,y_train)
Upvotes: 1
Views: 1122