Giter Site home page Giter Site logo

adamingas / ordinalgbt Goto Github PK

View Code? Open in Web Editor NEW
8.0 1.0 0.0 630 KB

A package to build Gradient boosted trees for ordinal labels

Home Page: https://ordinalgbt.readthedocs.io/

License: BSD 3-Clause "New" or "Revised" License

Jupyter Notebook 94.30% Python 5.70%
catboost gbm gradient-boosting gradient-boosting-classifier lightgbm ordinal-classification ordinal-regression xgboost lightgbm-mo

ordinalgbt's Introduction

Python application

OrdinalGBT

Introduction

OrdinalGBT, which stands for Ordinal gradient boosted trees, is a Python package that implements an ordinal regression loss function using the lightGBM framework. Ordinal regression is a type of regression analysis used for predicting an ordinal variable, i.e. a variable that can be sorted in some order. LightGBM is a gradient boosting framework that uses tree-based learning algorithms and is designed to be distributed and efficient.

Installation

You can install OrdinalGBT using pip:

pip install ordinalgbt

Usage

Here are a few examples on how to use the LGBMOrdinal class:

  1. Fitting the model
from ordinalgbt.lgb import LGBMOrdinal
import numpy as np

# Create the model
model = LGBMOrdinal()

# Generate some data
X = np.random.rand(100, 10)
y = np.random.randint(0, 3, 100)

# Fit the model
model.fit(X, y)
  1. Predicting with the model

After fitting the model, you can use it to make predictions:

# Generate some new data
X_new = np.random.rand(10, 10)

# Use the model to make predictions
# the .predict method returns the class prediction rather than raw score or
# probabilities
y_pred = model.predict(X_new)

print(y_pred)
  1. Predicting probabilities with the model

The predict_proba method can be used to get the probabilities of each class:

# Use the model to predict probabilities
y_proba = model.predict_proba(X_new)

print(y_proba)

TODOs

  • Create XGBoost and Catboost implementations
  • Bring test coverage to 100%
  • Implement the all-thresholds loss function
  • Implement the ordistic loss function
  • Create more stable sigmoid calculation
  • Experiment with bounded and unbounded optimisation for the thresholds
  • Identify way to reduce jumps due to large gradient

ordinalgbt's People

Contributors

adamingas avatar spanashis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

ordinalgbt's Issues

Support for Loss Matrix (Cost Sensitive Classification)

Have you thought on the following case, Cost Sensitive Classification:

$$ \boldsymbol{L} = \begin{bmatrix} l \left( y = 1, \hat{y} = 1 \right) & l \left( y = 1, \hat{y} = 2 \right) & \dots & l \left( y = 1, \hat{y} = K \right) \\ l \left( y = 2, \hat{y} = 1 \right) & l \left( y = 2, \hat{y} = 2 \right) & \dots & l \left( y = 2, \hat{y} = K \right) \\ \vdots & \vdots & \vdots & \vdots \\ l \left( y = K, \hat{y} = 1 \right) & l \left( y = K, \hat{y} = 2 \right) & \dots & l \left( y = K, \hat{y} = K \right) \end{bmatrix} $$

Is there a way to implement is where the Gradient and Hessian are easy to calculate for LightGBM?

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.