Search in sources :

Example 1 with DeviationMapper

use of com.amazon.randomcutforest.parkservices.state.statistics.DeviationMapper in project random-cut-forest-by-aws by aws.

the class PreprocessorMapper method toModel.

@Override
public Preprocessor toModel(PreprocessorState state, long seed) {
    DeviationMapper deviationMapper = new DeviationMapper();
    Deviation timeStampDeviation = deviationMapper.toModel(state.getTimeStampDeviationState());
    Deviation dataQuality = deviationMapper.toModel(state.getDataQualityState());
    Deviation[] deviations = null;
    if (state.getDeviationStates() != null) {
        deviations = new Deviation[state.getDeviationStates().length];
        for (int i = 0; i < state.getDeviationStates().length; i++) {
            deviations[i] = deviationMapper.toModel(state.getDeviationStates()[i]);
        }
    }
    Preprocessor.Builder<?> preprocessorBuilder = new Preprocessor.Builder<>().forestMode(ForestMode.valueOf(state.getForestMode())).shingleSize(state.getShingleSize()).dimensions(state.getDimensions()).normalizeTime(state.isNormalizeTime()).imputationMethod(ImputationMethod.valueOf(state.getImputationMethod())).fillValues(state.getDefaultFill()).inputLength(state.getInputLength()).weights(state.getWeights()).transformMethod(TransformMethod.valueOf(state.getTransformMethod())).startNormalization(state.getStartNormalization()).useImputedFraction(state.getUseImputedFraction()).timeDeviation(timeStampDeviation).dataQuality(dataQuality);
    if (deviations != null) {
        preprocessorBuilder.deviations(deviations);
    }
    Preprocessor preprocessor = preprocessorBuilder.build();
    preprocessor.setInitialValues(state.getInitialValues());
    preprocessor.setInitialTimeStamps(state.getInitialTimeStamps());
    preprocessor.setClipFactor(state.getClipFactor());
    preprocessor.setValuesSeen(state.getValuesSeen());
    preprocessor.setInternalTimeStamp(state.getInternalTimeStamp());
    preprocessor.setLastShingledInput(state.getLastShingledInput());
    preprocessor.setLastShingledPoint(state.getLastShingledPoint());
    preprocessor.setPreviousTimeStamps(state.getPreviousTimeStamps());
    preprocessor.setNormalizeTime(state.isNormalizeTime());
    return preprocessor;
}
Also used : DeviationMapper(com.amazon.randomcutforest.parkservices.state.statistics.DeviationMapper) Preprocessor(com.amazon.randomcutforest.parkservices.preprocessor.Preprocessor) Deviation(com.amazon.randomcutforest.parkservices.statistics.Deviation)

Example 2 with DeviationMapper

use of com.amazon.randomcutforest.parkservices.state.statistics.DeviationMapper 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 3 with DeviationMapper

use of com.amazon.randomcutforest.parkservices.state.statistics.DeviationMapper in project random-cut-forest-by-aws by aws.

the class PreprocessorMapper method toState.

@Override
public PreprocessorState toState(Preprocessor model) {
    PreprocessorState state = new PreprocessorState();
    state.setShingleSize(model.getShingleSize());
    state.setDimensions(model.getDimension());
    state.setInputLength(model.getInputLength());
    state.setClipFactor(model.getClipFactor());
    state.setDefaultFill(model.getDefaultFill());
    state.setImputationMethod(model.getImputationMethod().name());
    state.setTransformMethod(model.getTransformMethod().name());
    state.setWeights(model.getWeights());
    state.setForestMode(model.getMode().name());
    state.setInitialTimeStamps(model.getInitialTimeStamps());
    state.setInitialValues(model.getInitialValues());
    state.setUseImputedFraction(model.getUseImputedFraction());
    state.setNormalizeTime(model.isNormalizeTime());
    state.setStartNormalization(model.getStartNormalization());
    state.setStopNormalization(model.getStopNormalization());
    state.setPreviousTimeStamps(model.getPreviousTimeStamps());
    state.setLastShingledInput(model.getLastShingledInput());
    state.setLastShingledPoint(model.getLastShingledPoint());
    state.setValuesSeen(model.getValuesSeen());
    state.setInternalTimeStamp(model.getInternalTimeStamp());
    DeviationMapper deviationMapper = new DeviationMapper();
    state.setTimeStampDeviationState(deviationMapper.toState(model.getTimeStampDeviation()));
    state.setDataQualityState(deviationMapper.toState(model.getDataQuality()));
    DeviationState[] deviationStates = null;
    if (model.getDeviationList() != null) {
        Deviation[] list = model.getDeviationList();
        deviationStates = new DeviationState[list.length];
        for (int i = 0; i < list.length; i++) {
            deviationStates[i] = deviationMapper.toState(list[i]);
        }
    }
    state.setDeviationStates(deviationStates);
    return state;
}
Also used : DeviationMapper(com.amazon.randomcutforest.parkservices.state.statistics.DeviationMapper) DeviationState(com.amazon.randomcutforest.parkservices.state.statistics.DeviationState) Deviation(com.amazon.randomcutforest.parkservices.statistics.Deviation)

Example 4 with DeviationMapper

use of com.amazon.randomcutforest.parkservices.state.statistics.DeviationMapper in project random-cut-forest-by-aws by aws.

the class BasicThresholderMapper method toState.

@Override
public BasicThresholderState toState(BasicThresholder model) {
    BasicThresholderState state = new BasicThresholderState();
    DeviationMapper deviationMapper = new DeviationMapper();
    state.setZFactor(model.getZFactor());
    state.setUpperZfactor(model.getUpperZfactor());
    state.setUpperThreshold(model.getUpperThreshold());
    state.setLowerThreshold(model.getLowerThreshold());
    state.setAbsoluteThreshold(model.getAbsoluteThreshold());
    state.setInitialThreshold(model.getInitialThreshold());
    state.setAbsoluteScoreFraction(model.getAbsoluteScoreFraction());
    state.setElasticity(model.getElasticity());
    state.setCount(model.getCount());
    state.setInAnomaly(model.isInPotentialAnomaly());
    state.setAutoThreshold(model.isAutoThreshold());
    state.setMinimumScores(model.getMinimumScores());
    state.setPrimaryDeviationState(deviationMapper.toState(model.getPrimaryDeviation()));
    state.setSecondaryDeviationState(deviationMapper.toState(model.getSecondaryDeviation()));
    state.setThresholdDeviationState(deviationMapper.toState(model.getThresholdDeviation()));
    state.setHorizon(model.getHorizon());
    return state;
}
Also used : DeviationMapper(com.amazon.randomcutforest.parkservices.state.statistics.DeviationMapper)

Aggregations

DeviationMapper (com.amazon.randomcutforest.parkservices.state.statistics.DeviationMapper)4 Deviation (com.amazon.randomcutforest.parkservices.statistics.Deviation)3 Preprocessor (com.amazon.randomcutforest.parkservices.preprocessor.Preprocessor)1 DeviationState (com.amazon.randomcutforest.parkservices.state.statistics.DeviationState)1 BasicThresholder (com.amazon.randomcutforest.parkservices.threshold.BasicThresholder)1