Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents
maxLevel3

...

This guide demonstrates how to use a downloaded ML model generated using WSO2 ML in plain Java code. This guide uses the <ML_HOME>https://github.com/wso2/carbon-ml/tree/master/samples/model-usage/ sample Java client implementation.

...

Info

You can stop the WSO2 ML server after generating the required model, since this process of using the model in a Java client does not require a running ML server.

Building the sample

To build this sample, a Java project should be created as follows.

...

The complete project created above can be found in the <ML_HOME>at https://github.com/wso2/carbon-ml/tree/master/samples/model-usage directory.  To build this, execute the following command from this directorythe model-usage directory.

Code Block
mvn clean install

...

To execute this sample, execute the following command from the <ML_HOME>/samples/model-usage directory.

Code Block
mvn exec:java

...

Code Block
INFO  [MLModelUsageSample] - Algorithm Type : Classification
INFO  [MLModelUsageSample] - Algorithm Name : LOGISTIC_REGRESSION
INFO  [MLModelUsageSample] - Response Variable : Class
INFO  [MLModelUsageSample] - Features : [Feature [name=Age, index=7, type=NUMERICAL, imputeOption=DISCARD, include=true], Feature [name=BMI, index=5, type=NUMERICAL, imputeOption=DISCARD, include=true], Feature [name=DBP, index=2, type=NUMERICAL, imputeOption=DISCARD, include=true], Feature [name=DPF, index=6, type=NUMERICAL, imputeOption=DISCARD, include=true], Feature [name=NumPregnancies, index=0, type=NUMERICAL, imputeOption=DISCARD, include=true], Feature [name=PG2, index=1, type=NUMERICAL, imputeOption=DISCARD, include=true], Feature [name=SI2, index=4, type=NUMERICAL, imputeOption=DISCARD, include=true], Feature [name=TSFT, index=3, type=NUMERICAL, imputeOption=DISCARD, include=true]]
Sep 03WARN  [org.wso2.carbon.ml.core.impl.Predictor] - Metric Service is not available!
Sep 24, 2015 93:3506:2028 AMPM com.github.fommil.netlib.BLAS <clinit>
WARNING: Failed to load implementation from: com.github.fommil.netlib.NativeSystemBLAS
Sep 0324, 2015 93:3506:2028 AMPM com.github.fommil.netlib.BLAS <clinit>
WARNING: Failed to load implementation from: com.github.fommil.netlib.NativeRefBLAS
INFO  [MLModelUsageSample] - PredictionsFeature : [0, 0]values list 1 : [2, 84, 0, 0, 0, 0.0, 0.304, 21]
INFO  [MLModelUsageSample] - Prediction : 1
INFO  [MLModelUsageSample] - Feature values list 2 : [0, 101, 80, 40, 0, 26, 0.5, 33]
INFO  [MLModelUsageSample] - Prediction : 0
Info

If you package this project as a JAR file, add the following JAR files that are found in the <ML_HOME>/repository/components/plugins/ directory in the classpath when executing it.

  • arpack_combined_0.1.0.wso2v1.jar
  • breeze_2.10_0.11.1.wso2v1.jar
  • commons-logging-1.2.jar
  • core_1.1.2.wso2v1.jar
  • org.scala-lang.scala-library_2.10.4.v20140209-180020-VFINAL-b66a39653b.jar
  • org.wso2.carbon.metrics.manager_1.1.0.jar
  • org.wso2.carbon.ml.commons_1.0.1.SNAPSHOT.jar
  • org.wso2.carbon.ml.core_1.0.1.SNAPSHOT.jar
  • slf4j.api_1.7.5.jar
  • spark-core_2.10_1.4.1.wso2v1.jar
  • spark-mllib_2.10_1.4.1.wso2v1.jar