Giter Club home page Giter Club logo

Comments (2)

JarneVerhaeghe avatar JarneVerhaeghe commented on May 17, 2024

Thank you for the issue. I have taken a look at your code and tested it and it appears this error is because of the argument requirements for LightGBM. According to the documentation of LightGBM for the categorical_feature documentation argument, the model only accepts categorical features if they use a int format when using Pandas.

Using the following snippet to convert all string categories to ints for preprocessing will solve your issue!

cats = ['Cabin', 'Embarked', 'Gender', 'Name', 'Parch', 'Pclass', 'SibSp', 'Ticket']
for col in cats:
    X[col] = X[col].factorize()[0]

The PowerShap API is used correctly in your snippet!

from powershap.

deepandas11 avatar deepandas11 commented on May 17, 2024

@JarneVerhaeghe thanks for looking into this. However, I may have an alternate explanation for the documentation on lightgbm. If the columns in the dataframe are of CategoricalDtype() and are nominal, one could use the name representation of the cat_features. e.g., simply running the following line verifies that:

lgb_cl = LGBMClassifier(random_state=42, n_estimators=10, cat_features=cats)
lgb_cl.fit(X, y)

from powershap.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.