Search in sources :

Example 1 with MLAlgoParams

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());
}
Also used : MLAlgoParams(org.opensearch.ml.common.parameter.MLAlgoParams) SampleAlgoParams(org.opensearch.ml.common.parameter.SampleAlgoParams) Test(org.junit.Test)

Example 2 with MLAlgoParams

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());
}
Also used : MLInput(org.opensearch.ml.common.parameter.MLInput) Input(org.opensearch.ml.common.parameter.Input) LocalSampleCalculatorInput(org.opensearch.ml.common.parameter.LocalSampleCalculatorInput) MLInput(org.opensearch.ml.common.parameter.MLInput) DataFrameInputDataset(org.opensearch.ml.common.dataset.DataFrameInputDataset) MLInputDataset(org.opensearch.ml.common.dataset.MLInputDataset) MLPredictionOutput(org.opensearch.ml.common.parameter.MLPredictionOutput) LinearRegressionHelper.constructLinearRegressionPredictionDataFrame(org.opensearch.ml.engine.helper.LinearRegressionHelper.constructLinearRegressionPredictionDataFrame) KMeansHelper.constructKMeansDataFrame(org.opensearch.ml.engine.helper.KMeansHelper.constructKMeansDataFrame) LinearRegressionHelper.constructLinearRegressionTrainDataFrame(org.opensearch.ml.engine.helper.LinearRegressionHelper.constructLinearRegressionTrainDataFrame) DataFrame(org.opensearch.ml.common.dataframe.DataFrame) MLAlgoParams(org.opensearch.ml.common.parameter.MLAlgoParams) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 MLAlgoParams (org.opensearch.ml.common.parameter.MLAlgoParams)2 DataFrame (org.opensearch.ml.common.dataframe.DataFrame)1 DataFrameInputDataset (org.opensearch.ml.common.dataset.DataFrameInputDataset)1 MLInputDataset (org.opensearch.ml.common.dataset.MLInputDataset)1 Input (org.opensearch.ml.common.parameter.Input)1 LocalSampleCalculatorInput (org.opensearch.ml.common.parameter.LocalSampleCalculatorInput)1 MLInput (org.opensearch.ml.common.parameter.MLInput)1 MLPredictionOutput (org.opensearch.ml.common.parameter.MLPredictionOutput)1 SampleAlgoParams (org.opensearch.ml.common.parameter.SampleAlgoParams)1 KMeansHelper.constructKMeansDataFrame (org.opensearch.ml.engine.helper.KMeansHelper.constructKMeansDataFrame)1 LinearRegressionHelper.constructLinearRegressionPredictionDataFrame (org.opensearch.ml.engine.helper.LinearRegressionHelper.constructLinearRegressionPredictionDataFrame)1 LinearRegressionHelper.constructLinearRegressionTrainDataFrame (org.opensearch.ml.engine.helper.LinearRegressionHelper.constructLinearRegressionTrainDataFrame)1