JavaCPP Platform for shap4j

Java wrapper of the SHAP library (https://github.com/slundberg/shap)

Лицензия

Лицензия

Категории

Категории

ORM Данные
Группа

Группа

io.github.xydrolase
Идентификатор

Идентификатор

shap4j-platform
Последняя версия

Последняя версия

0.0.2
Дата

Дата

Тип

Тип

jar
Описание

Описание

JavaCPP Platform for shap4j
Java wrapper of the SHAP library (https://github.com/slundberg/shap)
Организация-разработчик

Организация-разработчик

io.github.xydrolase

Скачать shap4j-platform

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/io.github.xydrolase/shap4j-platform/ -->
<dependency>
    <groupId>io.github.xydrolase</groupId>
    <artifactId>shap4j-platform</artifactId>
    <version>0.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.xydrolase/shap4j-platform/
implementation 'io.github.xydrolase:shap4j-platform:0.0.2'
// https://jarcasting.com/artifacts/io.github.xydrolase/shap4j-platform/
implementation ("io.github.xydrolase:shap4j-platform:0.0.2")
'io.github.xydrolase:shap4j-platform:jar:0.0.2'
<dependency org="io.github.xydrolase" name="shap4j-platform" rev="0.0.2">
  <artifact name="shap4j-platform" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.xydrolase', module='shap4j-platform', version='0.0.2')
)
libraryDependencies += "io.github.xydrolase" % "shap4j-platform" % "0.0.2"
[io.github.xydrolase/shap4j-platform "0.0.2"]

Зависимости

compile (3)

Идентификатор библиотеки Тип Версия
io.github.xydrolase : shap4j jar 0.0.2
io.github.xydrolase : shap4j jar 0.0.2
io.github.xydrolase : shap4j jar 0.0.2

Модули Проекта

Данный проект не имеет модулей.

shap4j

Build Status javadoc

Java interface for the SHAP (SHapley Additive exPlanations) library for tree ensembles (TreeExplainer). Note that shap4j is not a pure Java port of SHAP. Rather, it utilizes JavaCPP to provide a Java-Native Interface (JNI) on top of the fast C++ implementation of TreeExplainer. In this sense, shap4j leverages the same underlying native code that powers the Python version of TreeExplainer, to ensure validity and efficiency.

Current supported platforms:

  • macosx-x86_64
  • linux-x86_64

Use cases

shap4j enables lean SHAP integration in JVM projects, i.e. a project can import shap4j as the sole dependency, without having to depend on heavier third-party tree ensemble libraries, e.g. xgboost4j.

Tree ensemble model conversion

In order for shap4j to explain a tree ensemble model, that model must be provided in a .shap4j data file, which can be generated from model dumps (pickle files) of XGBoost/LightGBM/CatBoost/sklearn using the companion Python library shap4j-data-converter.

Usage

Maven

<dependency>
  <groupId>io.github.xydrolase</groupId>
  <artifactId>shap4j-platform</artifactId>
  <version>0.0.2</version>
</dependency>

SBT

libraryDependencies += "io.github.xydrolase" % "shap4j-platform" % "0.0.2"

Example usage

package examples;

import java.nio.file.Files;
import java.io.File;
import shap4j.TreeExplainer;

class ExampleApp {
    public static void main(String[] args) throws Exception {
        byte[] data = Files.readAllBytes(new File("boston.shap4j").toPath());
        TreeExplainer explainer = new TreeExplainer(data);
        double[] x = {
                6.320e-03, 1.800e+01, 2.310e+00, 0.000e+00, 5.380e-01, 6.575e+00,
                6.520e+01, 4.090e+00, 1.000e+00, 2.960e+02, 1.530e+01, 3.969e+02,
                4.980e+00
        };
        double[] shapValues = explainer.shapValues(x, false);

        System.out.println("SHAP values: " + Arrays.toString(shapValues));
    }
}

The data file boston.shap4j can be found here. Or, you can follow the examples in shap4j-data-converter to generate it yourself.

API Docs

Версии библиотеки

Версия
0.0.2
0.0.1