Skip to content

Load Json model format in Java Client #1627

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

timotta
Copy link
Contributor

@timotta timotta commented Mar 31, 2021

I hereby agree to the terms of the CLA available at: https://github.com/catboost/catboost/blob/master/CONTRIBUTING.md

This PR enables loading CatBoost Json model format in the Java Client Library.

My intention is to use CatBoost in the LTR Elasticsearch plugin as an alternative to XGBoost. But for doing that it's needed to loading the json model since LTR plugin saves the model as json in Elasticsearch.

Example usage:

import ai.catboost.CatBoostError;
import ai.catboost.CatBoostModel;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public class CatBoostRanker {
    public static void main(String[] args) {
        try {
            final String f = "/home/tiago.motta/Projetos/ltr/catboost_model.json";
            final CatBoostModel catBoostModelByFile = CatBoostModel.loadModel(f, "json");

            final InputStream in = new FileInputStream(f);
            final CatBoostModel catBoostModelByStream = CatBoostModel.loadModel(in, "json");

            System.out.println("=====================================");
            System.out.println(catBoostModelByFile);
            System.out.println(catBoostModelByStream);
            System.out.println("=====================================");

        } catch (CatBoostError | IOException catBoostError) {
            catBoostError.printStackTrace();
        }
    }
}

@timotta timotta marked this pull request as ready for review March 31, 2021 21:57
@kizill
Copy link
Member

kizill commented Apr 1, 2021

@arcadia-devtools Ship it!

@arcadia-devtools
Copy link
Collaborator

CLA already signed

@arcadia-devtools
Copy link
Collaborator

@kizill, internal review request created: 1717394

@kizill
Copy link
Member

kizill commented Aug 30, 2021

@arcadia-devtools Ship it!

2 similar comments
@kizill
Copy link
Member

kizill commented Sep 29, 2021

@arcadia-devtools Ship it!

@kizill
Copy link
Member

kizill commented Oct 1, 2021

@arcadia-devtools Ship it!

@arcadia-devtools
Copy link
Collaborator

@kizill, internal review request updated: 1717394

@andrey-khropov
Copy link
Member

This PR has been merged in 8beda76, unfortunately our robot marks it as closed, not as merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants