This project has retired. For details please refer to its Attic page.
MLServiceResource (Lens 2.0.1-beta-incubating API)

org.apache.lens.server.ml
Class MLServiceResource

java.lang.Object
  extended by org.apache.lens.server.ml.MLServiceResource

@Path(value="/ml")
@Produces(value={"application/json","application/xml"})
public class MLServiceResource
extends Object

Machine Learning service.


Field Summary
static org.apache.commons.logging.Log LOG
          The Constant LOG.
static String ML_UP_MESSAGE
          Message indicating if ML service is up
 
Constructor Summary
MLServiceResource()
          Instantiates a new ML service resource.
 
Method Summary
 javax.ws.rs.core.Response clearModelCache()
          Clear model cache (for admin use).
 String deleteModel(String algorithm, String modelID)
          Delete a model given model ID and algorithm name.
 String deleteTestReport(String algorithm, String reportID)
          DELETE a report given the algorithm name and report ID.
 StringList getAlgoNames()
          Get a list of algos available
 ModelMetadata getModelMetadata(String algorithm, String modelID)
          Get metadata of the model given algorithm and model ID.
 StringList getModelsForAlgo(String algorithm)
          Get model ID list for a given algorithm.
 StringList getParamDescription(String algorithm)
          Gets the human readable param description of an algorithm
 StringList getReportsForAlgorithm(String algoritm)
          Get list of reports for a given algorithm.
 TestReport getTestReport(String algorithm, String reportID)
          Get a single test report given the algorithm name and report id.
 String mlResourceUp()
          Indicates if ML resource is up
 String predict(String algorithm, String modelID, javax.ws.rs.core.UriInfo uriInfo)
          Predict.
 String test(String algorithm, String modelID, String table, LensSessionHandle session, String outputTable)
          Run a test on a model for an algorithm.
 String train(String algorithm, javax.ws.rs.core.MultivaluedMap<String,String> form)
          Train a model given an algorithm name and algorithm parameters
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.commons.logging.Log LOG
The Constant LOG.


ML_UP_MESSAGE

public static final String ML_UP_MESSAGE
Message indicating if ML service is up

See Also:
Constant Field Values
Constructor Detail

MLServiceResource

public MLServiceResource()
Instantiates a new ML service resource.

Method Detail

mlResourceUp

@GET
public String mlResourceUp()
Indicates if ML resource is up

Returns:

getAlgoNames

@GET
@Path(value="algos")
public StringList getAlgoNames()
Get a list of algos available

Returns:

getParamDescription

@GET
@Path(value="algos/{algorithm}")
public StringList getParamDescription(@PathParam(value="algorithm")
                                               String algorithm)
Gets the human readable param description of an algorithm

Parameters:
algorithm - the algorithm
Returns:
the param description

getModelsForAlgo

@GET
@Path(value="models/{algorithm}")
public StringList getModelsForAlgo(@PathParam(value="algorithm")
                                            String algorithm)
                            throws LensException
Get model ID list for a given algorithm.

Parameters:
algorithm - algorithm name
Returns:
the models for algo
Throws:
LensException - the lens exception

getModelMetadata

@GET
@Path(value="models/{algorithm}/{modelID}")
public ModelMetadata getModelMetadata(@PathParam(value="algorithm")
                                               String algorithm,
                                               @PathParam(value="modelID")
                                               String modelID)
                               throws LensException
Get metadata of the model given algorithm and model ID.

Parameters:
algorithm - algorithm name
modelID - model ID
Returns:
model metadata
Throws:
LensException - the lens exception

deleteModel

@DELETE
@Consumes(value={"application/json","application/xml","text/plain"})
@Path(value="models/{algorithm}/{modelID}")
public String deleteModel(@PathParam(value="algorithm")
                                               String algorithm,
                                               @PathParam(value="modelID")
                                               String modelID)
                   throws LensException
Delete a model given model ID and algorithm name.

Parameters:
algorithm - the algorithm
modelID - the model id
Returns:
confirmation text
Throws:
LensException - the lens exception

train

@POST
@Consumes(value="application/x-www-form-urlencoded")
@Path(value="{algorithm}/train")
public String train(@PathParam(value="algorithm")
                                       String algorithm,
                                       javax.ws.rs.core.MultivaluedMap<String,String> form)
             throws LensException
Train a model given an algorithm name and algorithm parameters

Following parameters are mandatory and must be passed as part of the form

  1. table - input Hive table to load training data from
  2. label - name of the labelled column
  3. feature - one entry per feature column. At least one feature column is required

Parameters:
algorithm - algorithm name
form - form data
Returns:
if model is successfully trained, the model ID will be returned
Throws:
LensException - the lens exception

clearModelCache

@DELETE
@Path(value="clearModelCache")
@Produces(value="text/plain")
public javax.ws.rs.core.Response clearModelCache()
Clear model cache (for admin use).

Returns:
OK if the cache was cleared

test

@POST
@Path(value="test/{table}/{algorithm}/{modelID}")
@Consumes(value="multipart/form-data")
public String test(@PathParam(value="algorithm")
                                      String algorithm,
                                      @PathParam(value="modelID")
                                      String modelID,
                                      @PathParam(value="table")
                                      String table,
                                      LensSessionHandle session,
                                      String outputTable)
            throws LensException
Run a test on a model for an algorithm.

Parameters:
algorithm - algorithm name
modelID - model ID
table - Hive table to run test on
session - Lens session ID. This session ID will be used to run the test query
Returns:
Test report ID
Throws:
LensException - the lens exception

getReportsForAlgorithm

@GET
@Path(value="reports/{algorithm}")
public StringList getReportsForAlgorithm(@PathParam(value="algorithm")
                                                  String algoritm)
                                  throws LensException
Get list of reports for a given algorithm.

Parameters:
algoritm - the algoritm
Returns:
the reports for algorithm
Throws:
LensException - the lens exception

getTestReport

@GET
@Path(value="reports/{algorithm}/{reportID}")
public TestReport getTestReport(@PathParam(value="algorithm")
                                         String algorithm,
                                         @PathParam(value="reportID")
                                         String reportID)
                         throws LensException
Get a single test report given the algorithm name and report id.

Parameters:
algorithm - the algorithm
reportID - the report id
Returns:
the test report
Throws:
LensException - the lens exception

deleteTestReport

@DELETE
@Path(value="reports/{algorithm}/{reportID}")
@Consumes(value={"application/json","application/xml","text/plain"})
public String deleteTestReport(@PathParam(value="algorithm")
                                                    String algorithm,
                                                    @PathParam(value="reportID")
                                                    String reportID)
                        throws LensException
DELETE a report given the algorithm name and report ID.

Parameters:
algorithm - the algorithm
reportID - the report id
Returns:
the string
Throws:
LensException - the lens exception

predict

@GET
@Path(value="/predict/{algorithm}/{modelID}")
@Produces(value={"application/atom+xml","application/json"})
public String predict(@PathParam(value="algorithm")
                                        String algorithm,
                                        @PathParam(value="modelID")
                                        String modelID,
                                        @Context
                                        javax.ws.rs.core.UriInfo uriInfo)
               throws LensException
Predict.

Parameters:
algorithm - the algorithm
modelID - the model id
uriInfo - the uri info
Returns:
the string
Throws:
LensException - the lens exception


Copyright © 2014–2015 Apache Software Foundation. All rights reserved.