use of org.opensearch.ml.common.parameter.MLAlgoParams in project ml-commons by opensearch-project.
the class MLCommonsClassLoaderTests method testClassLoader_Return_MLAlgoParams.
@Test
public void testClassLoader_Return_MLAlgoParams() {
MLAlgoParams mlAlgoParams = MLCommonsClassLoader.initInstance(FunctionName.SAMPLE_ALGO, streamInput, StreamInput.class);
assertTrue(mlAlgoParams instanceof SampleAlgoParams);
assertEquals(params.getSampleParam(), ((SampleAlgoParams) mlAlgoParams).getSampleParam());
}
use of org.opensearch.ml.common.parameter.MLAlgoParams in project ml-commons by opensearch-project.
the class MLEngineTest method trainAndPredictWithKmeans.
@Test
public void trainAndPredictWithKmeans() {
int dataSize = 100;
MLAlgoParams parameters = KMeansParams.builder().build();
DataFrame dataFrame = constructKMeansDataFrame(dataSize);
MLInputDataset inputData = new DataFrameInputDataset(dataFrame);
Input input = new MLInput(FunctionName.KMEANS, parameters, inputData);
MLPredictionOutput output = (MLPredictionOutput) MLEngine.trainAndPredict(input);
Assert.assertEquals(dataSize, output.getPredictionResult().size());
}
Aggregations