org.wso2.carbon.ml.rest.api

## Class ModelApiV11

- java.lang.Object
- - org.wso2.carbon.ml.rest.api.MLRestAPI
  - - org.wso2.carbon.ml.rest.api.ModelApiV11

-     public class ModelApiV11
      extends MLRestAPI

  This class is to handle REST verbs GET , POST and DELETE.

- - ### Field Summary

    - ### Fields inherited from class org.wso2.carbon.ml.rest.api.MLRestAPI

      `auditLog`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ModelApiV11()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `javax.ws.rs.core.Response` | `addStorage(long modelId, org.wso2.carbon.ml.commons.domain.MLStorage storage)` Create a new model storage
    `javax.ws.rs.core.Response` | `buildModel(long modelId)` Build the model
    `javax.ws.rs.core.Response` | `createModel(org.wso2.carbon.ml.commons.domain.MLModelData model)` Create a new Model.
    `javax.ws.rs.core.Response` | `deleteModel(long modelId)` Delete a model
    `javax.ws.rs.core.Response` | `exportModel(long modelId, String mode)` Download the model
    `javax.ws.rs.core.Response` | `getAllModels()` Get all models
    `javax.ws.rs.core.Response` | `getModel(String modelName)` Get the model data
    `javax.ws.rs.core.Response` | `getModelSummary(long modelId)` Get the model summary
    `javax.ws.rs.core.Response` | `getProductRecommendations(long modelId, int userId, int noOfProducts)` Get a list of recommended products for a given user using the given model.
    `javax.ws.rs.core.Response` | `getUserRecommendations(long modelId, int productId, int noOfUsers)` Get a list of recommended users for a given product using the given model.
    `javax.ws.rs.core.Response` | `options()`
    `javax.ws.rs.core.Response` | `predict(long modelId, List<String[]> data, double percentile, boolean skipDecoding)` Make predictions using a model
    `javax.ws.rs.core.Response` | `predict(long modelId, String dataFormat, InputStream inputStream, double percentile, boolean skipDecoding)` Predict using a file and return as a list of predicted values.
    `javax.ws.rs.core.Response` | `publishModel(long modelId, String mode)` Publish the model to ML registry
    `javax.ws.rs.core.Response` | `streamingPredict(long modelId, String dataFormat, String columnHeader, InputStream inputStream, double percentile, boolean skipDecoding)` Predict using a file and return predictions as a CSV.

    - ### Methods inherited from class org.wso2.carbon.ml.rest.api.MLRestAPI

      `getTenantID`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ModelApiV11

          public ModelApiV11()

  - ### Method Detail

    - #### options

          public javax.ws.rs.core.Response options()

    - #### createModel

          public javax.ws.rs.core.Response createModel(org.wso2.carbon.ml.commons.domain.MLModelData model)

      Create a new Model.
      Parameters:
        `model` - `MLModelData` object
      Returns:
        JSON of `MLModelData` object

    - #### addStorage

          public javax.ws.rs.core.Response addStorage(long modelId,
                                             org.wso2.carbon.ml.commons.domain.MLStorage storage)

      Create a new model storage
      Parameters:
        `modelId` - Unique id of the model
        `storage` - `MLStorage` object

    - #### buildModel

          public javax.ws.rs.core.Response buildModel(long modelId)

      Build the model
      Parameters:
        `modelId` - Unique id of the model to be built.

    - #### publishModel

          public javax.ws.rs.core.Response publishModel(long modelId,
                                               String mode)

      Publish the model to ML registry
      Parameters:
        `modelId` - Unique id of the model to be published
      Returns:
        JSON of `MLResponseBean` containing the published location of the model

    - #### predict

          public javax.ws.rs.core.Response predict(long modelId,
                                          String dataFormat,
                                          InputStream inputStream,
                                          double percentile,
                                          boolean skipDecoding)

      Predict using a file and return as a list of predicted values.
      Parameters:
        `modelId` - Unique id of the model
        `dataFormat` - Data format of the file (CSV or TSV)
        `inputStream` - File input stream generated from the file used for predictions
        `percentile` - a threshold value used to identified cluster boundaries
        `skipDecoding` - whether the decoding should not be done (true or false)
      Returns:
        JSON array of predictions

    - #### streamingPredict

          public javax.ws.rs.core.Response streamingPredict(long modelId,
                                                   String dataFormat,
                                                   String columnHeader,
                                                   InputStream inputStream,
                                                   double percentile,
                                                   boolean skipDecoding)

      Predict using a file and return predictions as a CSV.
      Parameters:
        `modelId` - Unique id of the model
        `dataFormat` - Data format of the file (CSV or TSV)
        `columnHeader` - Whether the file contains the column header as the first row (YES or NO)
        `inputStream` - Input stream generated from the file used for predictions
        `percentile` - a threshold value used to identified cluster boundaries
        `skipDecoding` - whether the decoding should not be done (true or false)
      Returns:
        A file as a `StreamingOutput`

    - #### predict

          public javax.ws.rs.core.Response predict(long modelId,
                                          List<String[]> data,
                                          double percentile,
                                          boolean skipDecoding)

      Make predictions using a model
      Parameters:
        `modelId` - Unique id of the model
        `data` - List of string arrays containing the feature values used for predictions
        `percentile` - a threshold value used to identified cluster boundaries
        `skipDecoding` - whether the decoding should not be done (true or false)
      Returns:
        JSON array of predicted values

    - #### getModel

          public javax.ws.rs.core.Response getModel(String modelName)

      Get the model data
      Parameters:
        `modelName` - Name of the model
      Returns:
        JSON of `MLModelData` object

    - #### getAllModels

          public javax.ws.rs.core.Response getAllModels()

      Get all models
      Returns:
        JSON array of `MLModelData` objects

    - #### deleteModel

          public javax.ws.rs.core.Response deleteModel(long modelId)

      Delete a model
      Parameters:
        `modelId` - Unique id of the model

    - #### getModelSummary

          public javax.ws.rs.core.Response getModelSummary(long modelId)

      Get the model summary
      Parameters:
        `modelId` - Unique id of the model
      Returns:
        JSON of `ModelSummary` object

    - #### exportModel

          public javax.ws.rs.core.Response exportModel(long modelId,
                                              String mode)

      Download the model
      Parameters:
        `modelId` - Name of the model
      Returns:
        A `MLModel` as a `StreamingOutput`

    - #### getProductRecommendations

          public javax.ws.rs.core.Response getProductRecommendations(long modelId,
                                                            int userId,
                                                            int noOfProducts)

      Get a list of recommended products for a given user using the given model.
      Parameters:
        `modelId` - id of the recommendation model to be used.
        `userId` - id of the user.
        `noOfProducts` - number of recommendations required.
      Returns:
        an array of product recommendations.

    - #### getUserRecommendations

          public javax.ws.rs.core.Response getUserRecommendations(long modelId,
                                                         int productId,
                                                         int noOfUsers)

      Get a list of recommended users for a given product using the given model.
      Parameters:
        `modelId` - id of the recommendation model to be used.
        `productId` - id of the product.
        `noOfUsers` - number of recommendations required.
      Returns:
        an array of user recommendations.

Copyright © 2017 WSO2, Inc.. All rights reserved.