org.wso2.carbon.ml.rest.api

## Class ModelApiV10

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

-     public class ModelApiV10
      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
    `ModelApiV10()`

  - ### Method Summary

    All Methods Instance Methods Concrete 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(String modelName)` Download the model
    `javax.ws.rs.core.Response` | `getAllModels()` Get all models
    `javax.ws.rs.core.Response` | `getModel(String modelName)`
    `javax.ws.rs.core.Response` | `getModelSummary(long modelId)` Get the model summary
    `javax.ws.rs.core.Response` | `getRecommendations(long modelId, int userId, int noOfProducts)` Get the model data
    `javax.ws.rs.core.Response` | `options()`
    `javax.ws.rs.core.Response` | `predict(long modelId, List<String[]> data)` Make predictions using a model
    `javax.ws.rs.core.Response` | `predict(long modelId, String dataFormat, InputStream inputStream)` Predict using a file and return as a list of predicted values.
    `javax.ws.rs.core.Response` | `publishModel(long modelId)` Publish the model to ML registry
    `javax.ws.rs.core.Response` | `streamingPredict(long modelId, String dataFormat, String columnHeader, InputStream inputStream)` 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

    - #### ModelApiV10

          public ModelApiV10()

  - ### 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)

      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)

      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
      Returns:
        JSON array of predictions

    - #### streamingPredict

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

      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
      Returns:
        A file as a `StreamingOutput`

    - #### predict

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

      Make predictions using a model
      Parameters:
        `modelId` - Unique id of the model
        `data` - List of string arrays containing the feature values used for predictions
      Returns:
        JSON array of predicted values

    - #### getRecommendations

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

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

    - #### getModel

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

    - #### 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(String modelName)

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

Copyright © 2018 WSO2, Inc.. All Rights Reserved.