org.apache.lens.client
Class LensMLClient

java.lang.Object
  extended by org.apache.lens.client.LensMLClient
All Implemented Interfaces:
Closeable, LensML

public class LensMLClient
extends Object
implements LensML, Closeable

Client side implementation of LensML


Field Summary
 
Fields inherited from interface org.apache.lens.ml.LensML
NAME
 
Constructor Summary
LensMLClient(LensConnectionParams clientConf, LensSessionHandle sessionHandle)
          Instantiates a new lens ml client.
LensMLClient(LensConnectionParams clientConf, String password)
          Instantiates a new lens ml client.
 
Method Summary
 void close()
          Close connection
 void deleteModel(String algorithm, String modelID)
          Permanently delete a model instance.
 void deleteTestReport(String algorithm, String reportID)
          Permanently delete a test report instance.
 MLAlgo getAlgoForName(String algorithm)
          Get a algo object instance which could be used to generate a model of the given algorithm.
 Map<String,String> getAlgoParamDescription(String algorithm)
          Get user friendly information about parameters accepted by the algorithm.
 List<String> getAlgorithms()
          Get list of available machine learning algorithms
 MLModel getModel(String algorithm, String modelId)
          Get a model instance given the algorithm name and model ID.
 String getModelPath(String algorithm, String modelID)
          Get the FS location where model instance is saved.
 List<String> getModels(String algorithm)
          Get model IDs for the given algorithm.
 LensSessionHandle getSessionHandle()
           
 MLTestReport getTestReport(String algorithm, String reportID)
          Get a test report by ID.
 List<String> getTestReports(String algorithm)
          Get test reports for an algorithm.
 Object predict(String algorithm, String modelID, Object[] features)
          Online predict call given a model ID, algorithm name and sample feature values.
 MLTestReport testModel(LensSessionHandle session, String table, String algorithm, String modelID, String outputTable)
          Evaluate model by running it against test data contained in the given table.
 String train(String table, String algorithm, String[] args)
          Create a model using the given HCatalog table as input.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LensMLClient

public LensMLClient(LensConnectionParams clientConf,
                    String password)
Instantiates a new lens ml client.

Parameters:
clientConf - the client conf

LensMLClient

public LensMLClient(LensConnectionParams clientConf,
                    LensSessionHandle sessionHandle)
Instantiates a new lens ml client.

Parameters:
clientConf - the client conf
Method Detail

getAlgorithms

public List<String> getAlgorithms()
Get list of available machine learning algorithms

Specified by:
getAlgorithms in interface LensML
Returns:

getAlgoParamDescription

public Map<String,String> getAlgoParamDescription(String algorithm)
Get user friendly information about parameters accepted by the algorithm.

Specified by:
getAlgoParamDescription in interface LensML
Parameters:
algorithm - the algorithm
Returns:
map of param key to its help message

getAlgoForName

public MLAlgo getAlgoForName(String algorithm)
                      throws LensException
Get a algo object instance which could be used to generate a model of the given algorithm.

Specified by:
getAlgoForName in interface LensML
Parameters:
algorithm - the algorithm
Returns:
the algo for name
Throws:
LensException - the lens exception

train

public String train(String table,
                    String algorithm,
                    String[] args)
             throws LensException
Create a model using the given HCatalog table as input. The arguments should contain information needeed to generate the model.

Specified by:
train in interface LensML
Parameters:
table - the table
algorithm - the algorithm
args - the args
Returns:
Unique ID of the model created after training is complete
Throws:
LensException - the lens exception

getModels

public List<String> getModels(String algorithm)
                       throws LensException
Get model IDs for the given algorithm.

Specified by:
getModels in interface LensML
Parameters:
algorithm - the algorithm
Returns:
the models
Throws:
LensException - the lens exception

getModel

public MLModel getModel(String algorithm,
                        String modelId)
                 throws LensException
Get a model instance given the algorithm name and model ID.

Specified by:
getModel in interface LensML
Parameters:
algorithm - the algorithm
modelId - the model id
Returns:
the model
Throws:
LensException - the lens exception

getModelPath

public String getModelPath(String algorithm,
                           String modelID)
Get the FS location where model instance is saved.

Specified by:
getModelPath in interface LensML
Parameters:
algorithm - the algorithm
modelID - the model id
Returns:
the model path

testModel

public MLTestReport testModel(LensSessionHandle session,
                              String table,
                              String algorithm,
                              String modelID,
                              String outputTable)
                       throws LensException
Evaluate model by running it against test data contained in the given table.

Specified by:
testModel in interface LensML
Parameters:
session - the session
table - the table
algorithm - the algorithm
modelID - the model id
Returns:
Test report object containing test output table, and various evaluation metrics
Throws:
LensException - the lens exception

getTestReports

public List<String> getTestReports(String algorithm)
                            throws LensException
Get test reports for an algorithm.

Specified by:
getTestReports in interface LensML
Parameters:
algorithm - the algorithm
Returns:
the test reports
Throws:
LensException - the lens exception

getTestReport

public MLTestReport getTestReport(String algorithm,
                                  String reportID)
                           throws LensException
Get a test report by ID.

Specified by:
getTestReport in interface LensML
Parameters:
algorithm - the algorithm
reportID - the report id
Returns:
the test report
Throws:
LensException - the lens exception

predict

public Object predict(String algorithm,
                      String modelID,
                      Object[] features)
               throws LensException
Online predict call given a model ID, algorithm name and sample feature values.

Specified by:
predict in interface LensML
Parameters:
algorithm - the algorithm
modelID - the model id
features - the features
Returns:
prediction result
Throws:
LensException - the lens exception

deleteModel

public void deleteModel(String algorithm,
                        String modelID)
                 throws LensException
Permanently delete a model instance.

Specified by:
deleteModel in interface LensML
Parameters:
algorithm - the algorithm
modelID - the model id
Throws:
LensException - the lens exception

deleteTestReport

public void deleteTestReport(String algorithm,
                             String reportID)
                      throws LensException
Permanently delete a test report instance.

Specified by:
deleteTestReport in interface LensML
Parameters:
algorithm - the algorithm
reportID - the report id
Throws:
LensException - the lens exception

close

public void close()
           throws IOException
Close connection

Specified by:
close in interface Closeable
Throws:
IOException

getSessionHandle

public LensSessionHandle getSessionHandle()


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