Skip to content

Commit d91ddff

Browse files
authored
Port LightGBM provider (#26)
Port lightgbm provider
1 parent de052b7 commit d91ddff

35 files changed

+62415
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@ target
3838
.gnupg/private-keys-v1.d
3939

4040
openml-h2o/dependency-reduced-pom.xml
41+
openml-lightgbm/lightgbmlib_build

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "openml-lightgbm/make-lightgbm"]
2+
path = openml-lightgbm/make-lightgbm
3+
url = https://github.com/feedzai/make-lightgbm

openml-h2o/src/test/java/com/feedzai/openml/h2o/algos/mocks/BindingRegularParameters.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import water.bindings.pojos.ModelParametersSchemaV3;
55

66
/**
7-
* FIXME
7+
* Mocked class that extends {@link ModelParametersSchemaV3} to match {@link RegularParameters}.
88
*
99
* @author Miguel Cruz (miguel.cruz@feedzai.com)
10-
* @since @@@feedzai.next.release@@@
10+
* @since 1.0.7
1111
*/
1212
public class BindingRegularParameters extends ModelParametersSchemaV3 {
1313

openml-h2o/src/test/java/com/feedzai/openml/h2o/algos/mocks/RegularParameters.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
import water.api.schemas3.ModelParametersSchemaV3;
55

66
/**
7-
* FIXME
7+
* Mocked class that extends {@link water.bindings.pojos.ModelParametersSchemaV3} having a field named
8+
* {@code fields}.
89
*
910
* @author Miguel Cruz (miguel.cruz@feedzai.com)
10-
* @since @@@feedzai.next.release@@@
11+
* @since 1.0.7
1112
*/
1213
public class RegularParameters extends ModelParametersSchemaV3 {
1314

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Copyright (C) 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
2+
Contributed by Richard Henderson <rth@redhat.com>.
3+
4+
This file is part of the GNU OpenMP Library (libgomp).
5+
6+
Libgomp is free software; you can redistribute it and/or modify it
7+
under the terms of the GNU General Public License as published by
8+
the Free Software Foundation; either version 3, or (at your option)
9+
any later version.
10+
11+
Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
12+
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13+
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14+
more details.
15+
16+
Under Section 7 of GPL version 3, you are granted additional
17+
permissions described in the GCC Runtime Library Exception, version
18+
3.1, as published by the Free Software Foundation.
19+
20+
You should have received a copy of the GNU General Public License and
21+
a copy of the GCC Runtime Library Exception along with this program;
22+
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23+
<http://www.gnu.org/licenses/>.
24+

openml-lightgbm/make-lightgbm

Submodule make-lightgbm added at c5bd94e

openml-lightgbm/make.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright (c) 2020 Feedzai
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# @author Sheng Wang (sheng.wang@feedzai.com)
18+
19+
FILE=lightgbmlib_build
20+
if [ ! -d "$FILE" ]; then
21+
echo "entering the folder."
22+
cd make-lightgbm || return
23+
echo "starting run the script"
24+
bash make.sh v2.3.0 || return
25+
echo "exiting the folder."
26+
cd .. || return
27+
echo "move the folder."
28+
mv make-lightgbm/build lightgbmlib_build || return
29+
echo "finished!"
30+
fi

openml-lightgbm/pom.xml

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ The copyright of this file belongs to Feedzai. The file cannot be
4+
~ reproduced in whole or in part, stored in a retrieval system,
5+
~ transmitted in any form, or by any means electronic, mechanical,
6+
~ photocopying, or otherwise, without the prior permission of the owner.
7+
~
8+
~ (c) 2020 Feedzai, Strictly Confidential
9+
-->
10+
11+
<project xmlns="http://maven.apache.org/POM/4.0.0"
12+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
13+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
14+
<parent>
15+
<artifactId>openml-java</artifactId>
16+
<groupId>com.feedzai</groupId>
17+
<version>0.0.0-SNAPSHOT</version>
18+
</parent>
19+
<modelVersion>4.0.0</modelVersion>
20+
21+
<artifactId>openml-lightgbm</artifactId>
22+
23+
<description>Contains an example for the implementation of a LGBM Machine Learning Model and Classifier</description>
24+
25+
<properties>
26+
<lightgbmlib.version>2.3.150</lightgbmlib.version>
27+
</properties>
28+
29+
<dependencies>
30+
<dependency>
31+
<groupId>com.feedzai</groupId>
32+
<artifactId>openml-api</artifactId>
33+
<scope>provided</scope>
34+
</dependency>
35+
<dependency>
36+
<groupId>com.feedzai</groupId>
37+
<artifactId>openml-utils</artifactId>
38+
<scope>provided</scope>
39+
</dependency>
40+
41+
<dependency>
42+
<groupId>com.microsoft.ml.lightgbm</groupId>
43+
<artifactId>lightgbmlib</artifactId>
44+
<version>${lightgbmlib.version}</version>
45+
</dependency>
46+
47+
<dependency>
48+
<groupId>com.google.guava</groupId>
49+
<artifactId>guava</artifactId>
50+
<scope>provided</scope>
51+
</dependency>
52+
<dependency>
53+
<groupId>com.google.auto.service</groupId>
54+
<artifactId>auto-service</artifactId>
55+
</dependency>
56+
57+
<dependency>
58+
<groupId>org.slf4j</groupId>
59+
<artifactId>slf4j-api</artifactId>
60+
</dependency>
61+
62+
<!-- For testing only -->
63+
<dependency>
64+
<groupId>ch.qos.logback</groupId>
65+
<artifactId>logback-core</artifactId>
66+
<scope>test</scope>
67+
</dependency>
68+
<dependency>
69+
<groupId>com.feedzai</groupId>
70+
<artifactId>openml-utils</artifactId>
71+
<type>test-jar</type>
72+
<scope>test</scope>
73+
</dependency>
74+
<dependency>
75+
<groupId>junit</groupId>
76+
<artifactId>junit</artifactId>
77+
<scope>test</scope>
78+
</dependency>
79+
<dependency>
80+
<groupId>org.assertj</groupId>
81+
<artifactId>assertj-core</artifactId>
82+
<scope>test</scope>
83+
</dependency>
84+
<dependency>
85+
<groupId>org.apache.commons</groupId>
86+
<artifactId>commons-csv</artifactId>
87+
<scope>test</scope>
88+
</dependency>
89+
90+
</dependencies>
91+
92+
<build>
93+
94+
<resources>
95+
<resource>
96+
<directory>${project.basedir}/target/resources</directory>
97+
</resource>
98+
</resources>
99+
100+
<plugins>
101+
102+
<plugin>
103+
<artifactId>exec-maven-plugin</artifactId>
104+
<groupId>org.codehaus.mojo</groupId>
105+
<executions>
106+
<execution>
107+
<id>Generate LightGBM Build</id>
108+
<phase>initialize</phase>
109+
<goals>
110+
<goal>exec</goal>
111+
</goals>
112+
<configuration>
113+
<executable>${project.basedir}/make.sh</executable>
114+
</configuration>
115+
</execution>
116+
</executions>
117+
</plugin>
118+
119+
<plugin>
120+
<artifactId>maven-assembly-plugin</artifactId>
121+
<configuration>
122+
<descriptorRefs>
123+
<descriptorRef>jar-with-dependencies</descriptorRef>
124+
</descriptorRefs>
125+
<appendAssemblyId>false</appendAssemblyId>
126+
</configuration>
127+
<executions>
128+
<execution>
129+
<phase>package</phase>
130+
<goals>
131+
<goal>single</goal>
132+
</goals>
133+
</execution>
134+
</executions>
135+
</plugin>
136+
137+
<!-- set locale otherwise the LightGBM core implementation spits wrong results -->
138+
<plugin>
139+
<groupId>org.apache.maven.plugins</groupId>
140+
<artifactId>maven-surefire-plugin</artifactId>
141+
<configuration>
142+
<environmentVariables>
143+
<LC_ALL>C</LC_ALL>
144+
</environmentVariables>
145+
</configuration>
146+
</plugin>
147+
148+
<!-- Install the local copy of the custom build of LightGBM to Maven -->
149+
<plugin>
150+
<groupId>org.apache.maven.plugins</groupId>
151+
<artifactId>maven-install-plugin</artifactId>
152+
<executions>
153+
<execution>
154+
<id>install-custom-lightgbmlib_build</id>
155+
<phase>initialize</phase>
156+
<goals>
157+
<goal>install-file</goal>
158+
</goals>
159+
<configuration>
160+
<file>${project.basedir}/lightgbmlib_build/lightgbmlib.jar</file>
161+
<pomFile>${project.basedir}/lightgbmlib_build/pom.xml</pomFile>
162+
<generatePom>false</generatePom>
163+
</configuration>
164+
</execution>
165+
</executions>
166+
</plugin>
167+
<!-- Copy the shared libraries to the resources folder -->
168+
<plugin>
169+
<groupId>org.apache.maven.plugins</groupId>
170+
<artifactId>maven-resources-plugin</artifactId>
171+
<executions>
172+
<execution>
173+
<id>copy-shared-libs-resources</id>
174+
<phase>generate-resources</phase>
175+
<goals>
176+
<goal>copy-resources</goal>
177+
</goals>
178+
<configuration>
179+
<outputDirectory>${project.basedir}/target/resources</outputDirectory>
180+
<resources>
181+
<resource>
182+
<directory>lightgbmlib_build</directory>
183+
<include>*.so</include>
184+
<include>*.so.1.0.0</include>
185+
</resource>
186+
</resources>
187+
</configuration>
188+
</execution>
189+
<execution>
190+
<id>copy-licences</id>
191+
<phase>generate-resources</phase>
192+
<goals>
193+
<goal>copy-resources</goal>
194+
</goals>
195+
<configuration>
196+
<outputDirectory>${project.basedir}/target/resources</outputDirectory>
197+
<resources>
198+
<resource>
199+
<directory>LICENCES</directory>
200+
</resource>
201+
</resources>
202+
</configuration>
203+
</execution>
204+
</executions>
205+
</plugin>
206+
</plugins>
207+
</build>
208+
</project>
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright 2020 Feedzai
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
package com.feedzai.openml.provider.lightgbm;
19+
20+
import com.feedzai.openml.provider.descriptor.MLAlgorithmDescriptor;
21+
import com.feedzai.openml.provider.descriptor.MachineLearningAlgorithmType;
22+
import com.feedzai.openml.util.algorithm.MLAlgorithmEnum;
23+
24+
import static com.feedzai.openml.util.algorithm.MLAlgorithmEnum.createDescriptor;
25+
26+
/**
27+
* Specifies the LightGBM algorithms that can be imported.
28+
*
29+
* @author Alberto Ferreira (alberto.ferreira@feedzai.com)
30+
* @since 1.0.10
31+
*/
32+
public enum LightGBMAlgorithms implements MLAlgorithmEnum {
33+
34+
/**
35+
* LightGBM binary classifier algorithm.
36+
*/
37+
LIGHTGBM_BINARY_CLASSIFIER(createDescriptor(
38+
"LightGBM Binary Classifier",
39+
LightGBMDescriptorUtil.PARAMS,
40+
MachineLearningAlgorithmType.SUPERVISED_BINARY_CLASSIFICATION,
41+
"https://lightgbm.readthedocs.io/"
42+
)),
43+
;
44+
45+
/**
46+
* {@link MLAlgorithmDescriptor} for this algorithm.
47+
*/
48+
private final MLAlgorithmDescriptor descriptor;
49+
50+
/**
51+
* Constructor.
52+
*
53+
* @param descriptor {@link MLAlgorithmDescriptor} for this algorithm.
54+
*/
55+
LightGBMAlgorithms(final MLAlgorithmDescriptor descriptor) {
56+
this.descriptor = descriptor;
57+
}
58+
59+
@Override
60+
public MLAlgorithmDescriptor getAlgorithmDescriptor() {
61+
return this.descriptor;
62+
}
63+
}

0 commit comments

Comments
 (0)