Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Outlier call depending on type #2205

Merged
merged 1 commit into from
Jul 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would model meta name always be set? Otherwise may be worth adding .get("name", None) to avoid exception

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok i seen, thanks for the reference

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))