Search in sources :

Example 1 with DataFrame

use of org.opensearch.ml.common.dataframe.DataFrame in project ml-commons by opensearch-project.

the class MLPredictionTaskRequestTest method setUp.

@Before
public void setUp() {
    DataFrame dataFrame = DataFrameBuilder.load(Collections.singletonList(new HashMap<String, Object>() {

        {
            put("key1", 2.0D);
        }
    }));
    mlInput = MLInput.builder().algorithm(FunctionName.KMEANS).parameters(KMeansParams.builder().centroids(1).build()).inputDataset(DataFrameInputDataset.builder().dataFrame(dataFrame).build()).build();
}
Also used : HashMap(java.util.HashMap) DataFrame(org.opensearch.ml.common.dataframe.DataFrame) Before(org.junit.Before)

Example 2 with DataFrame

use of org.opensearch.ml.common.dataframe.DataFrame in project ml-commons by opensearch-project.

the class MLTrainingTaskRequestTest method setUp.

@Before
public void setUp() {
    DataFrame dataFrame = DataFrameBuilder.load(Collections.singletonList(new HashMap<String, Object>() {

        {
            put("key1", 2.0D);
        }
    }));
    mlInput = MLInput.builder().algorithm(FunctionName.KMEANS).parameters(KMeansParams.builder().centroids(1).build()).inputDataset(DataFrameInputDataset.builder().dataFrame(dataFrame).build()).build();
}
Also used : HashMap(java.util.HashMap) DataFrame(org.opensearch.ml.common.dataframe.DataFrame) Before(org.junit.Before)

Example 3 with DataFrame

use of org.opensearch.ml.common.dataframe.DataFrame in project ml-commons by opensearch-project.

the class MLPredictionOutputTest method setUp.

@Before
public void setUp() {
    ColumnMeta[] columnMetas = new ColumnMeta[] { new ColumnMeta("test", ColumnType.INTEGER) };
    List<Row> rows = new ArrayList<>();
    rows.add(new Row(new ColumnValue[] { new IntValue(1) }));
    rows.add(new Row(new ColumnValue[] { new IntValue(2) }));
    DataFrame dataFrame = new DefaultDataFrame(columnMetas, rows);
    output = MLPredictionOutput.builder().taskId("test_task_id").status("test_status").predictionResult(dataFrame).build();
}
Also used : ColumnMeta(org.opensearch.ml.common.dataframe.ColumnMeta) ArrayList(java.util.ArrayList) ColumnValue(org.opensearch.ml.common.dataframe.ColumnValue) Row(org.opensearch.ml.common.dataframe.Row) DataFrame(org.opensearch.ml.common.dataframe.DataFrame) DefaultDataFrame(org.opensearch.ml.common.dataframe.DefaultDataFrame) IntValue(org.opensearch.ml.common.dataframe.IntValue) DefaultDataFrame(org.opensearch.ml.common.dataframe.DefaultDataFrame) Before(org.junit.Before)

Example 4 with DataFrame

use of org.opensearch.ml.common.dataframe.DataFrame in project ml-commons by opensearch-project.

the class MLInputDatasetHandlerTests method testSearchQueryInputDatasetWrongType.

public void testSearchQueryInputDatasetWrongType() {
    expectedEx.expect(IllegalArgumentException.class);
    expectedEx.expectMessage("Input dataset is not SEARCH_QUERY type.");
    DataFrame testDataFrame = DataFrameBuilder.load(Collections.singletonList(new HashMap<String, Object>() {

        {
            put("key1", 2.0D);
        }
    }));
    DataFrameInputDataset dataFrameInputDataset = DataFrameInputDataset.builder().dataFrame(testDataFrame).build();
    mlInputDatasetHandler.parseSearchQueryInput(dataFrameInputDataset, listener);
}
Also used : DataFrameInputDataset(org.opensearch.ml.common.dataset.DataFrameInputDataset) HashMap(java.util.HashMap) DataFrame(org.opensearch.ml.common.dataframe.DataFrame)

Example 5 with DataFrame

use of org.opensearch.ml.common.dataframe.DataFrame in project ml-commons by opensearch-project.

the class MLInputDatasetHandlerTests method testDataFrameInputDataset.

public void testDataFrameInputDataset() {
    DataFrame testDataFrame = DataFrameBuilder.load(Collections.singletonList(new HashMap<String, Object>() {

        {
            put("key1", 2.0D);
        }
    }));
    DataFrameInputDataset dataFrameInputDataset = DataFrameInputDataset.builder().dataFrame(testDataFrame).build();
    DataFrame result = mlInputDatasetHandler.parseDataFrameInput(dataFrameInputDataset);
    Assert.assertEquals(testDataFrame, result);
}
Also used : DataFrameInputDataset(org.opensearch.ml.common.dataset.DataFrameInputDataset) HashMap(java.util.HashMap) DataFrame(org.opensearch.ml.common.dataframe.DataFrame)

Aggregations

DataFrame (org.opensearch.ml.common.dataframe.DataFrame)34 ColumnMeta (org.opensearch.ml.common.dataframe.ColumnMeta)10 DefaultDataFrame (org.opensearch.ml.common.dataframe.DefaultDataFrame)10 MLPredictionOutput (org.opensearch.ml.common.parameter.MLPredictionOutput)10 MLInput (org.opensearch.ml.common.parameter.MLInput)9 ArrayList (java.util.ArrayList)8 Test (org.junit.Test)8 Model (org.opensearch.ml.common.parameter.Model)8 Row (org.opensearch.ml.common.dataframe.Row)7 DataFrameInputDataset (org.opensearch.ml.common.dataset.DataFrameInputDataset)7 MLInputDataset (org.opensearch.ml.common.dataset.MLInputDataset)7 KMeansHelper.constructKMeansDataFrame (org.opensearch.ml.engine.helper.KMeansHelper.constructKMeansDataFrame)7 HashMap (java.util.HashMap)6 ColumnValue (org.opensearch.ml.common.dataframe.ColumnValue)6 LinearRegressionHelper.constructLinearRegressionPredictionDataFrame (org.opensearch.ml.engine.helper.LinearRegressionHelper.constructLinearRegressionPredictionDataFrame)5 LinearRegressionHelper.constructLinearRegressionTrainDataFrame (org.opensearch.ml.engine.helper.LinearRegressionHelper.constructLinearRegressionTrainDataFrame)5 List (java.util.List)4 Before (org.junit.Before)4 Input (org.opensearch.ml.common.parameter.Input)4 LocalSampleCalculatorInput (org.opensearch.ml.common.parameter.LocalSampleCalculatorInput)4