Skip to content

Commit

Permalink
Port LightGBM provider (#26)
Browse files Browse the repository at this point in the history
Port lightgbm provider
  • Loading branch information
shengwangsw authored Jul 10, 2020
1 parent de052b7 commit d91ddff
Show file tree
Hide file tree
Showing 35 changed files with 62,415 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ target
.gnupg/private-keys-v1.d

openml-h2o/dependency-reduced-pom.xml
openml-lightgbm/lightgbmlib_build
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "openml-lightgbm/make-lightgbm"]
path = openml-lightgbm/make-lightgbm
url = https://github.com/feedzai/make-lightgbm
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import water.bindings.pojos.ModelParametersSchemaV3;

/**
* FIXME
* Mocked class that extends {@link ModelParametersSchemaV3} to match {@link RegularParameters}.
*
* @author Miguel Cruz ([email protected])
* @since @@@feedzai.next.release@@@
* @since 1.0.7
*/
public class BindingRegularParameters extends ModelParametersSchemaV3 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
import water.api.schemas3.ModelParametersSchemaV3;

/**
* FIXME
* Mocked class that extends {@link water.bindings.pojos.ModelParametersSchemaV3} having a field named
* {@code fields}.
*
* @author Miguel Cruz ([email protected])
* @since @@@feedzai.next.release@@@
* @since 1.0.7
*/
public class RegularParameters extends ModelParametersSchemaV3 {

Expand Down
24 changes: 24 additions & 0 deletions openml-lightgbm/LICENCES/libopenmp.licence
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Copyright (C) 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
Contributed by Richard Henderson <[email protected]>.

This file is part of the GNU OpenMP Library (libgomp).

Libgomp is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.

Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.

Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.

You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>.

1 change: 1 addition & 0 deletions openml-lightgbm/make-lightgbm
Submodule make-lightgbm added at c5bd94
30 changes: 30 additions & 0 deletions openml-lightgbm/make.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash

# Copyright (c) 2020 Feedzai
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# @author Sheng Wang ([email protected])

FILE=lightgbmlib_build
if [ ! -d "$FILE" ]; then
echo "entering the folder."
cd make-lightgbm || return
echo "starting run the script"
bash make.sh v2.3.0 || return
echo "exiting the folder."
cd .. || return
echo "move the folder."
mv make-lightgbm/build lightgbmlib_build || return
echo "finished!"
fi
208 changes: 208 additions & 0 deletions openml-lightgbm/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ The copyright of this file belongs to Feedzai. The file cannot be
~ reproduced in whole or in part, stored in a retrieval system,
~ transmitted in any form, or by any means electronic, mechanical,
~ photocopying, or otherwise, without the prior permission of the owner.
~
~ (c) 2020 Feedzai, Strictly Confidential
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>openml-java</artifactId>
<groupId>com.feedzai</groupId>
<version>0.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>openml-lightgbm</artifactId>

<description>Contains an example for the implementation of a LGBM Machine Learning Model and Classifier</description>

<properties>
<lightgbmlib.version>2.3.150</lightgbmlib.version>
</properties>

<dependencies>
<dependency>
<groupId>com.feedzai</groupId>
<artifactId>openml-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.feedzai</groupId>
<artifactId>openml-utils</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.microsoft.ml.lightgbm</groupId>
<artifactId>lightgbmlib</artifactId>
<version>${lightgbmlib.version}</version>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service</artifactId>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>

<!-- For testing only -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.feedzai</groupId>
<artifactId>openml-utils</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

<build>

<resources>
<resource>
<directory>${project.basedir}/target/resources</directory>
</resource>
</resources>

<plugins>

<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<executions>
<execution>
<id>Generate LightGBM Build</id>
<phase>initialize</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${project.basedir}/make.sh</executable>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- set locale otherwise the LightGBM core implementation spits wrong results -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<environmentVariables>
<LC_ALL>C</LC_ALL>
</environmentVariables>
</configuration>
</plugin>

<!-- Install the local copy of the custom build of LightGBM to Maven -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<executions>
<execution>
<id>install-custom-lightgbmlib_build</id>
<phase>initialize</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<file>${project.basedir}/lightgbmlib_build/lightgbmlib.jar</file>
<pomFile>${project.basedir}/lightgbmlib_build/pom.xml</pomFile>
<generatePom>false</generatePom>
</configuration>
</execution>
</executions>
</plugin>
<!-- Copy the shared libraries to the resources folder -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-shared-libs-resources</id>
<phase>generate-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.basedir}/target/resources</outputDirectory>
<resources>
<resource>
<directory>lightgbmlib_build</directory>
<include>*.so</include>
<include>*.so.1.0.0</include>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy-licences</id>
<phase>generate-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.basedir}/target/resources</outputDirectory>
<resources>
<resource>
<directory>LICENCES</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright 2020 Feedzai
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.feedzai.openml.provider.lightgbm;

import com.feedzai.openml.provider.descriptor.MLAlgorithmDescriptor;
import com.feedzai.openml.provider.descriptor.MachineLearningAlgorithmType;
import com.feedzai.openml.util.algorithm.MLAlgorithmEnum;

import static com.feedzai.openml.util.algorithm.MLAlgorithmEnum.createDescriptor;

/**
* Specifies the LightGBM algorithms that can be imported.
*
* @author Alberto Ferreira ([email protected])
* @since 1.0.10
*/
public enum LightGBMAlgorithms implements MLAlgorithmEnum {

/**
* LightGBM binary classifier algorithm.
*/
LIGHTGBM_BINARY_CLASSIFIER(createDescriptor(
"LightGBM Binary Classifier",
LightGBMDescriptorUtil.PARAMS,
MachineLearningAlgorithmType.SUPERVISED_BINARY_CLASSIFICATION,
"https://lightgbm.readthedocs.io/"
)),
;

/**
* {@link MLAlgorithmDescriptor} for this algorithm.
*/
private final MLAlgorithmDescriptor descriptor;

/**
* Constructor.
*
* @param descriptor {@link MLAlgorithmDescriptor} for this algorithm.
*/
LightGBMAlgorithms(final MLAlgorithmDescriptor descriptor) {
this.descriptor = descriptor;
}

@Override
public MLAlgorithmDescriptor getAlgorithmDescriptor() {
return this.descriptor;
}
}
Loading

0 comments on commit d91ddff

Please sign in to comment.