Search in sources :

Example 1 with BasicThresholder

use of com.amazon.randomcutforest.parkservices.threshold.BasicThresholder in project random-cut-forest-by-aws by aws.

the class BasicThresholderMapper method toModel.

@Override
public BasicThresholder toModel(BasicThresholderState state, long seed) {
    DeviationMapper deviationMapper = new DeviationMapper();
    Deviation primaryDeviation = deviationMapper.toModel(state.getPrimaryDeviationState());
    Deviation secondaryDeviation = deviationMapper.toModel(state.getSecondaryDeviationState());
    Deviation thresholdDeviation = deviationMapper.toModel(state.getThresholdDeviationState());
    BasicThresholder thresholder = new BasicThresholder(primaryDeviation, secondaryDeviation, thresholdDeviation);
    thresholder.setAbsoluteThreshold(state.getAbsoluteThreshold());
    thresholder.setLowerThreshold(state.getLowerThreshold(), state.isAutoThreshold());
    thresholder.setUpperThreshold(state.getUpperThreshold());
    thresholder.setInitialThreshold(state.getInitialThreshold());
    thresholder.setElasticity(state.getElasticity());
    thresholder.setInPotentialAnomaly(state.isInAnomaly());
    thresholder.setHorizon(state.getHorizon());
    thresholder.setCount(state.getCount());
    thresholder.setMinimumScores(state.getMinimumScores());
    thresholder.setAbsoluteScoreFraction(state.getAbsoluteScoreFraction());
    thresholder.setUpperZfactor(state.getUpperZfactor());
    thresholder.setZfactor(state.getZFactor());
    return thresholder;
}
Also used : DeviationMapper(com.amazon.randomcutforest.parkservices.state.statistics.DeviationMapper) Deviation(com.amazon.randomcutforest.parkservices.statistics.Deviation) BasicThresholder(com.amazon.randomcutforest.parkservices.threshold.BasicThresholder)

Example 2 with BasicThresholder

use of com.amazon.randomcutforest.parkservices.threshold.BasicThresholder in project random-cut-forest-by-aws by aws.

the class ThresholdedRandomCutForestMapper method toModel.

@Override
public ThresholdedRandomCutForest toModel(ThresholdedRandomCutForestState state, long seed) {
    RandomCutForestMapper randomCutForestMapper = new RandomCutForestMapper();
    BasicThresholderMapper thresholderMapper = new BasicThresholderMapper();
    PreprocessorMapper preprocessorMapper = new PreprocessorMapper();
    RandomCutForest forest = randomCutForestMapper.toModel(state.getForestState());
    BasicThresholder thresholder = thresholderMapper.toModel(state.getThresholderState());
    Preprocessor preprocessor = preprocessorMapper.toModel(state.getPreprocessorStates()[0]);
    ForestMode forestMode = ForestMode.valueOf(state.getForestMode());
    TransformMethod transformMethod = TransformMethod.valueOf(state.getTransformMethod());
    RCFComputeDescriptor descriptor = new RCFComputeDescriptor(null, 0L);
    descriptor.setRCFScore(state.getLastAnomalyScore());
    descriptor.setInternalTimeStamp(state.getLastAnomalyTimeStamp());
    descriptor.setAttribution(new DiVectorMapper().toModel(state.getLastAnomalyAttribution()));
    descriptor.setRCFPoint(state.getLastAnomalyPoint());
    descriptor.setExpectedRCFPoint(state.getLastExpectedPoint());
    descriptor.setRelativeIndex(state.getLastRelativeIndex());
    descriptor.setForestMode(forestMode);
    descriptor.setTransformMethod(transformMethod);
    descriptor.setImputationMethod(ImputationMethod.valueOf(state.getPreprocessorStates()[0].getImputationMethod()));
    PredictorCorrector predictorCorrector = new PredictorCorrector(thresholder);
    predictorCorrector.setIgnoreSimilar(state.isIgnoreSimilar());
    predictorCorrector.setIgnoreSimilarFactor(state.getIgnoreSimilarFactor());
    predictorCorrector.setTriggerFactor(state.getTriggerFactor());
    predictorCorrector.setNumberOfAttributors(state.getNumberOfAttributors());
    return new ThresholdedRandomCutForest(forestMode, transformMethod, forest, predictorCorrector, preprocessor, descriptor);
}
Also used : ForestMode(com.amazon.randomcutforest.config.ForestMode) BasicThresholderMapper(com.amazon.randomcutforest.parkservices.state.threshold.BasicThresholderMapper) PredictorCorrector(com.amazon.randomcutforest.parkservices.PredictorCorrector) RandomCutForestMapper(com.amazon.randomcutforest.state.RandomCutForestMapper) RandomCutForest(com.amazon.randomcutforest.RandomCutForest) ThresholdedRandomCutForest(com.amazon.randomcutforest.parkservices.ThresholdedRandomCutForest) DiVectorMapper(com.amazon.randomcutforest.state.returntypes.DiVectorMapper) Preprocessor(com.amazon.randomcutforest.parkservices.preprocessor.Preprocessor) PreprocessorMapper(com.amazon.randomcutforest.parkservices.state.preprocessor.PreprocessorMapper) TransformMethod(com.amazon.randomcutforest.config.TransformMethod) IRCFComputeDescriptor(com.amazon.randomcutforest.parkservices.IRCFComputeDescriptor) RCFComputeDescriptor(com.amazon.randomcutforest.parkservices.RCFComputeDescriptor) BasicThresholder(com.amazon.randomcutforest.parkservices.threshold.BasicThresholder) ThresholdedRandomCutForest(com.amazon.randomcutforest.parkservices.ThresholdedRandomCutForest)

Aggregations

BasicThresholder (com.amazon.randomcutforest.parkservices.threshold.BasicThresholder)2 RandomCutForest (com.amazon.randomcutforest.RandomCutForest)1 ForestMode (com.amazon.randomcutforest.config.ForestMode)1 TransformMethod (com.amazon.randomcutforest.config.TransformMethod)1 IRCFComputeDescriptor (com.amazon.randomcutforest.parkservices.IRCFComputeDescriptor)1 PredictorCorrector (com.amazon.randomcutforest.parkservices.PredictorCorrector)1 RCFComputeDescriptor (com.amazon.randomcutforest.parkservices.RCFComputeDescriptor)1 ThresholdedRandomCutForest (com.amazon.randomcutforest.parkservices.ThresholdedRandomCutForest)1 Preprocessor (com.amazon.randomcutforest.parkservices.preprocessor.Preprocessor)1 PreprocessorMapper (com.amazon.randomcutforest.parkservices.state.preprocessor.PreprocessorMapper)1 DeviationMapper (com.amazon.randomcutforest.parkservices.state.statistics.DeviationMapper)1 BasicThresholderMapper (com.amazon.randomcutforest.parkservices.state.threshold.BasicThresholderMapper)1 Deviation (com.amazon.randomcutforest.parkservices.statistics.Deviation)1 RandomCutForestMapper (com.amazon.randomcutforest.state.RandomCutForestMapper)1 DiVectorMapper (com.amazon.randomcutforest.state.returntypes.DiVectorMapper)1