Search in sources :

Example 1 with MLPredictionTaskRequest

use of org.opensearch.ml.common.transport.prediction.MLPredictionTaskRequest in project ml-commons by opensearch-project.

the class PredictionITTests method testPredictionWithoutAlgorithm.

public void testPredictionWithoutAlgorithm() throws IOException {
    MLInput mlInput = MLInput.builder().inputDataset(DATA_FRAME_INPUT_DATASET).build();
    MLPredictionTaskRequest predictionRequest = new MLPredictionTaskRequest(taskId, mlInput);
    ActionFuture<MLTaskResponse> predictionFuture = client().execute(MLPredictionTaskAction.INSTANCE, predictionRequest);
    expectThrows(ActionRequestValidationException.class, () -> predictionFuture.actionGet());
}
Also used : MLTaskResponse(org.opensearch.ml.common.transport.MLTaskResponse) MLInput(org.opensearch.ml.common.parameter.MLInput) MLPredictionTaskRequest(org.opensearch.ml.common.transport.prediction.MLPredictionTaskRequest)

Example 2 with MLPredictionTaskRequest

use of org.opensearch.ml.common.transport.prediction.MLPredictionTaskRequest in project ml-commons by opensearch-project.

the class PredictionITTests method testPredictionWithoutModelId.

public void testPredictionWithoutModelId() throws IOException {
    MLInput mlInput = MLInput.builder().algorithm(FunctionName.KMEANS).inputDataset(DATA_FRAME_INPUT_DATASET).build();
    MLPredictionTaskRequest predictionRequest = new MLPredictionTaskRequest("", mlInput);
    ActionFuture<MLTaskResponse> predictionFuture = client().execute(MLPredictionTaskAction.INSTANCE, predictionRequest);
    expectThrows(ResourceNotFoundException.class, () -> predictionFuture.actionGet());
}
Also used : MLTaskResponse(org.opensearch.ml.common.transport.MLTaskResponse) MLInput(org.opensearch.ml.common.parameter.MLInput) MLPredictionTaskRequest(org.opensearch.ml.common.transport.prediction.MLPredictionTaskRequest)

Example 3 with MLPredictionTaskRequest

use of org.opensearch.ml.common.transport.prediction.MLPredictionTaskRequest in project ml-commons by opensearch-project.

the class PredictionITTests method testPredictionWithEmptyDataset.

public void testPredictionWithEmptyDataset() throws IOException {
    MLInputDataset emptySearchInputDataset = generateEmptyDataset();
    MLInput mlInput = MLInput.builder().algorithm(FunctionName.KMEANS).inputDataset(emptySearchInputDataset).build();
    MLPredictionTaskRequest predictionRequest = new MLPredictionTaskRequest(taskId, mlInput);
    ActionFuture<MLTaskResponse> predictionFuture = client().execute(MLPredictionTaskAction.INSTANCE, predictionRequest);
    expectThrows(IllegalArgumentException.class, () -> predictionFuture.actionGet());
}
Also used : MLTaskResponse(org.opensearch.ml.common.transport.MLTaskResponse) MLInput(org.opensearch.ml.common.parameter.MLInput) MLInputDataset(org.opensearch.ml.common.dataset.MLInputDataset) MLPredictionTaskRequest(org.opensearch.ml.common.transport.prediction.MLPredictionTaskRequest)

Example 4 with MLPredictionTaskRequest

use of org.opensearch.ml.common.transport.prediction.MLPredictionTaskRequest in project ml-commons by opensearch-project.

the class PredictionITTests method testPredictionWithoutDataset.

public void testPredictionWithoutDataset() throws IOException {
    MLInput mlInput = MLInput.builder().algorithm(FunctionName.KMEANS).build();
    MLPredictionTaskRequest predictionRequest = new MLPredictionTaskRequest(taskId, mlInput);
    ActionFuture<MLTaskResponse> predictionFuture = client().execute(MLPredictionTaskAction.INSTANCE, predictionRequest);
    expectThrows(ActionRequestValidationException.class, () -> predictionFuture.actionGet());
}
Also used : MLTaskResponse(org.opensearch.ml.common.transport.MLTaskResponse) MLInput(org.opensearch.ml.common.parameter.MLInput) MLPredictionTaskRequest(org.opensearch.ml.common.transport.prediction.MLPredictionTaskRequest)

Example 5 with MLPredictionTaskRequest

use of org.opensearch.ml.common.transport.prediction.MLPredictionTaskRequest in project ml-commons by opensearch-project.

the class MachineLearningNodeClient method predict.

@Override
public void predict(String modelId, MLInput mlInput, ActionListener<MLOutput> listener) {
    validateMLInput(mlInput, true);
    MLPredictionTaskRequest predictionRequest = MLPredictionTaskRequest.builder().mlInput(mlInput).modelId(modelId).build();
    client.execute(MLPredictionTaskAction.INSTANCE, predictionRequest, getMlPredictionTaskResponseActionListener(listener));
}
Also used : MLPredictionTaskRequest(org.opensearch.ml.common.transport.prediction.MLPredictionTaskRequest)

Aggregations

MLPredictionTaskRequest (org.opensearch.ml.common.transport.prediction.MLPredictionTaskRequest)8 MLInput (org.opensearch.ml.common.parameter.MLInput)6 MLTaskResponse (org.opensearch.ml.common.transport.MLTaskResponse)5 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 XContentBuilder (org.opensearch.common.xcontent.XContentBuilder)1 XContentParser (org.opensearch.common.xcontent.XContentParser)1 MLInputDataset (org.opensearch.ml.common.dataset.MLInputDataset)1 MLPredictionOutput (org.opensearch.ml.common.parameter.MLPredictionOutput)1