use of org.opensearch.ml.common.parameter.FunctionName in project ml-commons by opensearch-project.
the class MLEngineClassLoader method loadClassMapping.
public static void loadClassMapping() {
Reflections reflections = new Reflections("org.opensearch.ml.engine.algorithms");
Set<Class<?>> classes = reflections.getTypesAnnotatedWith(Function.class);
// Load ML algorithm parameter class
for (Class<?> clazz : classes) {
Function function = clazz.getAnnotation(Function.class);
FunctionName functionName = function.value();
if (functionName != null) {
mlAlgoClassMap.put(functionName, clazz);
}
}
}
use of org.opensearch.ml.common.parameter.FunctionName in project ml-commons by opensearch-project.
the class MLEngineTest method train_UnsupportedAlgorithm.
@Test
public void train_UnsupportedAlgorithm() {
exceptionRule.expect(IllegalArgumentException.class);
exceptionRule.expectMessage("Unsupported algorithm: LINEAR_REGRESSION");
FunctionName algoName = FunctionName.LINEAR_REGRESSION;
try (MockedStatic<MLEngineClassLoader> loader = Mockito.mockStatic(MLEngineClassLoader.class)) {
loader.when(() -> MLEngineClassLoader.initInstance(algoName, null, MLAlgoParams.class)).thenReturn(null);
MLInputDataset inputDataset = DataFrameInputDataset.builder().dataFrame(constructKMeansDataFrame(10)).build();
MLEngine.train(MLInput.builder().algorithm(algoName).inputDataset(inputDataset).build());
}
}
Aggregations