use of com.amazon.randomcutforest.state.RandomCutForestState in project ml-commons by opensearch-project.
the class BatchRandomCutForest method predict.
@Override
public MLOutput predict(DataFrame dataFrame, Model model) {
if (model == null) {
throw new IllegalArgumentException("No model found for batch RCF prediction.");
}
RandomCutForestState state = (RandomCutForestState) ModelSerDeSer.deserialize(model.getContent());
RandomCutForest forest = rcfMapper.toModel(state);
List<Map<String, Object>> predictResult = process(dataFrame, forest, 0);
return MLPredictionOutput.builder().predictionResult(DataFrameBuilder.load(predictResult)).build();
}
use of com.amazon.randomcutforest.state.RandomCutForestState in project ml-commons by opensearch-project.
the class BatchRandomCutForest method train.
@Override
public Model train(DataFrame dataFrame) {
RandomCutForest forest = createRandomCutForest(dataFrame);
Integer actualTrainingDataSize = trainingDataSize == null ? dataFrame.size() : trainingDataSize;
process(dataFrame, forest, actualTrainingDataSize);
Model model = new Model();
model.setName(FunctionName.BATCH_RCF.name());
model.setVersion(1);
RandomCutForestState state = rcfMapper.toState(forest);
model.setContent(ModelSerDeSer.serialize(state));
return model;
}
Aggregations