Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support of category (with lightgbm) #339

Closed
PierreCe opened this issue Jan 14, 2022 · 2 comments
Closed

Support of category (with lightgbm) #339

PierreCe opened this issue Jan 14, 2022 · 2 comments

Comments

@PierreCe
Copy link

PierreCe commented Jan 14, 2022

I have a lightgbm model trained with pandas dataframes some columns of it have the type "category" (and are underlying strings)
All of the steps for loading and compiling this model work well. But when I try to make a prediction, I always get an error:

  • Either, I pass the dataframe, and I get the error: TypeError: Cannot initialize DMatrix from DataFrame
  • Either, I pass the associated ndarray and I get the error: ValueError: Unrecognized NumPy type: object

The code is a copy paste of the quick start example, and the error is on the line :
dmat = treelite_runtime.DMatrix(X.values)

The data is load with :

X = pd.read_csv("french_motors_test.csv")
for column, typ in X.dtypes.iteritems():
    if not is_numeric_dtype(typ):
        X[column] = X[column].astype('category')

Data is coming from open data, so I could share the data and the model (but where?).

@hcho3
Copy link
Collaborator

hcho3 commented Jan 14, 2022

Please convert the matrix to numeric type. Treelite does not support string category type.

@hcho3
Copy link
Collaborator

hcho3 commented Jan 21, 2022

Closing in favor of dmlc/tl2cgen#10.

@hcho3 hcho3 closed this as completed Jan 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants