Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
remove deprecated code
Browse files Browse the repository at this point in the history
  • Loading branch information
Lai authored and wnbts committed Sep 14, 2020
1 parent e702594 commit 0fbfeac
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 190 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -325,42 +325,6 @@ public long estimateModelSize(RandomCutForest forest) {
.getDimensions() * (Long.SIZE / Byte.SIZE);
}

/**
* Gets the RCF anomaly result using the specified model.
*
* @deprecated use getRcfResult with listener instead.
*
* @param detectorId ID of the detector
* @param modelId ID of the model to score the point
* @param point features of the data point
* @return RCF result for the input point, including a score
* @throws ResourceNotFoundException when the model is not found
* @throws LimitExceededException when a limit is exceeded for the model
*/
@Deprecated
public RcfResult getRcfResult(String detectorId, String modelId, double[] point) {
ModelState<RandomCutForest> modelState = forests
.computeIfAbsent(
modelId,
model -> checkpointDao
.getModelCheckpoint(model)
.map(
checkpoint -> AccessController.doPrivileged((PrivilegedAction<RandomCutForest>) () -> rcfSerde.fromJson(checkpoint))
)
.filter(rcf -> isHostingAllowed(detectorId, rcf))
.map(rcf -> new ModelState<>(rcf, modelId, detectorId, ModelType.RCF.getName(), clock.instant()))
.orElseThrow(() -> new ResourceNotFoundException(detectorId, CommonErrorMessages.NO_CHECKPOINT_ERR_MSG + modelId))
);

RandomCutForest rcf = modelState.getModel();
double score = rcf.getAnomalyScore(point);
double confidence = computeRcfConfidence(rcf);
int forestSize = rcf.getNumberOfTrees();
rcf.update(point);
modelState.setLastUsedTime(clock.instant());
return new RcfResult(score, confidence, forestSize);
}

/**
* Returns to listener the RCF anomaly result using the specified model.
*
Expand Down Expand Up @@ -435,40 +399,6 @@ private void processRcfCheckpoint(Optional<String> rcfCheckpoint, String modelId
}
}

/**
* Gets the result using the specified thresholding model.
*
* @deprecated use getThresholdingResult with listener instead.
*
* @param detectorId ID of the detector
* @param modelId ID of the thresholding model
* @param score raw anomaly score
* @return thresholding model result for the raw score
* @throws ResourceNotFoundException when the model is not found
*/
@Deprecated
public ThresholdingResult getThresholdingResult(String detectorId, String modelId, double score) {
ModelState<ThresholdingModel> modelState = thresholds
.computeIfAbsent(
modelId,
model -> checkpointDao
.getModelCheckpoint(model)
.map(
checkpoint -> AccessController
.doPrivileged((PrivilegedAction<ThresholdingModel>) () -> gson.fromJson(checkpoint, thresholdingModelClass))
)
.map(threshold -> new ModelState<>(threshold, modelId, detectorId, ModelType.THRESHOLD.getName(), clock.instant()))
.orElseThrow(() -> new ResourceNotFoundException(detectorId, CommonErrorMessages.NO_CHECKPOINT_ERR_MSG + modelId))
);

ThresholdingModel threshold = modelState.getModel();
double grade = threshold.grade(score);
double confidence = threshold.confidence();
threshold.update(score);
modelState.setLastUsedTime(clock.instant());
return new ThresholdingResult(grade, confidence);
}

/**
* Returns to listener the result using the specified thresholding model.
*
Expand Down
Loading

0 comments on commit 0fbfeac

Please sign in to comment.