Skip to content

Commit

Permalink
Change Outlier call depending on type
Browse files Browse the repository at this point in the history
  • Loading branch information
ukclivecox authored and seldondev committed Jul 27, 2020
1 parent f15d00f commit 6f61bb6
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions components/alibi-detect-server/adserver/od_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,24 @@ def process_event(self, inputs: List, headers: Dict) -> Dict:
and headers[HEADER_RETURN_FEATURE_SCORE] == "true"
):
ret_feature_score = True
od_preds = self.model.predict(
X,
outlier_type=outlier_type,
# use 'feature' or 'instance' level
return_feature_score=ret_feature_score,
# scores used to determine outliers
return_instance_score=ret_instance_score,
)
op_preds = {}
name = self.model.meta['name']
if name == 'IForest' or name == 'OutlierAEGMM' or \
name == 'Mahalanobis' or name == 'SpectralResidual' or \
name == 'OutlierVAEGMM':
od_preds = self.model.predict(
X,
# scores used to determine outliers
return_instance_score=ret_instance_score,
)
else:
od_preds = self.model.predict(
X,
outlier_type=outlier_type,
# use 'feature' or 'instance' level
return_feature_score=ret_feature_score,
# scores used to determine outliers
return_instance_score=ret_instance_score,
)

return json.loads(json.dumps(od_preds, cls=NumpyEncoder))

0 comments on commit 6f61bb6

Please sign in to comment.