Machine Box Classificationbox Client Library in Java
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.mvn/wrapper
src
.gitignore
LICENSE
README.md
mvnw
mvnw.cmd
pom.xml

README.md

classificationbox-java

Machine Box Classificationbox Client Library in Java (using Retrofit2)

Installation

maven artifact coming soon

Overview

classificationbox-java is a Java/JVM client binding for Classificationbox using Retrofit. It is overall a fairly low level implementation, meaning that it essentially exposes all of the available REST API endpoints as methods with POJO request/response classes where appropriate and otherwise stays out of your way.

This implementation grew out of small personal project and is not sponsored or supported directly by Machine Box.

Issues, pull requests, and suggestions are encouraged and appreciated.

Usage

Run Classificationbox

It's easy! Sign up and you can run the box locally with docker in just a few minutes!

Create a new client and create a model

// create a client. by default, the client points to localhost:8080 without basic authentication
ClassificationBoxClient defaultClient = ClassificationBoxClient.defaultClient();

// create a list of classes
List<String> classes = new ArrayList<String>();
classes.add("class1");
classes.add("class2");
classes.add("class3");

CreateModelRequest cmr = new CreateModelRequest("sentimentModel", classes)
                .withId("sentiment1")
                .addOption(ModelOption.NGRAMS, 1)
                .addOption(ModelOption.SKIPGRAMS, 1);

Response<CreateModelResponse> response = defaultClient.service.createModel(cmr).execute();
if(response.isSuccessful() && response.body().getSuccess()) {
    System.out.printf("hooray! %s\n", response.body().getName());
}

Teach the model

TeachModelRequest tmr = new TeachModelRequest("class1");
tmr.addInput(new ModelInput("user_age", FeatureType.NUMBER, "25"));
tmr.addInput(new ModelInput("user_interest", FeatureType.LIST, "music,cooking,ml"));
tmr.addInput(new ModelInput("user_location", FeatureType.KEYWORD, "London"));

Response<TeachModelResponse> response = getClient().service().teachModel("sentiment1", tmr).execute();

See the integration tests for more examples.

TODO

  • Test error cases
  • Test Request/Response POJOs
  • Document Request/Response POJOs
  • Handle /info, /healthz, /liveness, /readyz endpoints
  • Handle alternate state upload methods
  • CI/CD
  • Small sample application

License

MIT License

Copyright (c) 2018 josh rotenberg

Please see the LICENSE for more information.