Machine Box Classificationbox Client Library in Java (using Retrofit2)
maven artifact coming soon
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.
It's easy! Sign up and you can run the box locally with docker in just a few minutes!
// 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());
}
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.
- 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
MIT License
Copyright (c) 2018 josh rotenberg
Please see the LICENSE for more information.