Search in sources :

Example 1 with ThresholdedRandomCutForestState

use of com.amazon.randomcutforest.parkservices.state.ThresholdedRandomCutForestState in project ml-commons by opensearch-project.

the class FixedInTimeRandomCutForest method predict.

@Override
public MLOutput predict(DataFrame dataFrame, Model model) {
    if (model == null) {
        throw new IllegalArgumentException("No model found for FIT RCF prediction.");
    }
    ThresholdedRandomCutForestState state = (ThresholdedRandomCutForestState) ModelSerDeSer.deserialize(model.getContent());
    ThresholdedRandomCutForest forest = trcfMapper.toModel(state);
    List<Map<String, Object>> predictResult = process(dataFrame, forest);
    return MLPredictionOutput.builder().predictionResult(DataFrameBuilder.load(predictResult)).build();
}
Also used : ThresholdedRandomCutForestState(com.amazon.randomcutforest.parkservices.state.ThresholdedRandomCutForestState) HashMap(java.util.HashMap) Map(java.util.Map) ThresholdedRandomCutForest(com.amazon.randomcutforest.parkservices.ThresholdedRandomCutForest)

Example 2 with ThresholdedRandomCutForestState

use of com.amazon.randomcutforest.parkservices.state.ThresholdedRandomCutForestState in project ml-commons by opensearch-project.

the class FixedInTimeRandomCutForest method train.

@Override
public Model train(DataFrame dataFrame) {
    ThresholdedRandomCutForest forest = createThresholdedRandomCutForest(dataFrame);
    process(dataFrame, forest);
    Model model = new Model();
    model.setName(FunctionName.FIT_RCF.name());
    model.setVersion(1);
    ThresholdedRandomCutForestState state = trcfMapper.toState(forest);
    model.setContent(ModelSerDeSer.serialize(state));
    return model;
}
Also used : Model(org.opensearch.ml.common.parameter.Model) ThresholdedRandomCutForestState(com.amazon.randomcutforest.parkservices.state.ThresholdedRandomCutForestState) ThresholdedRandomCutForest(com.amazon.randomcutforest.parkservices.ThresholdedRandomCutForest)

Aggregations

ThresholdedRandomCutForest (com.amazon.randomcutforest.parkservices.ThresholdedRandomCutForest)2 ThresholdedRandomCutForestState (com.amazon.randomcutforest.parkservices.state.ThresholdedRandomCutForestState)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Model (org.opensearch.ml.common.parameter.Model)1