Code Monkey home page Code Monkey logo

Comments (4)

NikEyX avatar NikEyX commented on May 11, 2024

I should note that in python I can use model.classes_ to get the class values. I guess my question boils down to how can I do this in your library (which seems awesome btw)?

from leaves.

dmitryikh avatar dmitryikh commented on May 11, 2024

@NikEyX , thanks for your interest to leaves and sorry for late response.

Unfortunately, you can't obtain this information from xgboost's binary model file, because there is no such information.. Let me explain this by details:

  1. When you use XGBClassifier.fit in python it performs labels encoding for y, let's say labels 1242, 1152, 1552, 1242 goes to 0, 1, 2, 0 by using sklearn's LabelEncoder. Then only labels like 0, 1, 2, .. goes to xgboost core library, and model obtained can operate only these labels..
  2. There are warnings in XGBClassifier.save/load_model that points on that also:
        The model is saved in an XGBoost internal binary format which is
        universal among the various XGBoost interfaces. Auxiliary attributes of
        the Python Booster object (such as feature names) will not be loaded.
        Label encodings (text labels to numeric labels) will be also lost.
        **If you are using only the Python interface, we recommend pickling the
        model object for best results.

So, python xgboost bindings will be also lost original class labels after save_mode -> load_model operations.

from leaves.

dmitryikh avatar dmitryikh commented on May 11, 2024

btw, util.SigmoidFloat64SliceInplace is not what you want to use in class of multi class classification. In that case you would use softmax transformation on raw tress values in order to obtain probabilities of classes occurrences. Sum of all class probabilities should be 1.0 (this is a property of softmax function).

Currently I'm developing an update for leaves that make it possible apply transformation on tree results (sigmoid for binary classification, softmax for multi class classification, lambda rank for rank problems and so on). Stay tuned!

from leaves.

NikEyX avatar NikEyX commented on May 11, 2024

good to know, thanks for the updates! Love your work, keep it up!

from leaves.

Related Issues (20)

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.