-
-
Notifications
You must be signed in to change notification settings - Fork 378
Push Feature - Merged #1198
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
Push Feature - Merged #1198
Conversation
|
For some reason my formatter still changed a ton of white spaces. Any idea @andreybavt ? |
Removed self.idrow to avoid pickling "self"
…to feature/merging-push-feature
…to feature/merging-push-feature # Conflicts: # python-client/giskard/ml_worker/server/ml_worker_service.py
|
|
||
|
|
||
| # Classification | ||
| def test_instance_if_not_none(german_credit_model, german_credit_data): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that we can have parameterized tests to avoid rewriting the same test for each model type
| current: Pushes | undefined; | ||
| identifier: PushIdentifier | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use ?: in ts to say that a field is optional:
| current: Pushes | undefined; | |
| identifier: PushIdentifier | undefined; | |
| current?: Pushes; | |
| identifier?: PushIdentifier; |
frontend/src/stores/push.ts
Outdated
| // @ts-ignore | ||
| this.pushes[modelId][datasetId][rowNb] = await api.getPushes(modelId, datasetId, rowNb); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // @ts-ignore | |
| this.pushes[modelId][datasetId][rowNb] = await api.getPushes(modelId, datasetId, rowNb); | |
| this.pushes[modelId][datasetId][rowNb] = await api.getPushes(modelId, datasetId, rowNb) as Pushes; |
| } | ||
| watch(() => rowNb.value, async (newValue, oldValue) => { | ||
| console.log("RowNb changed"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can delete this log
| console.log("RowNb changed"); |
| if contribs is not None: | ||
| contrib_grpc = contribs.to_grpc() | ||
| else: | ||
| contrib_grpc = None | ||
|
|
||
| if perturbs is not None: | ||
| perturb_grpc = perturbs.to_grpc() | ||
| else: | ||
| perturb_grpc = None | ||
|
|
||
| if overconf is not None: | ||
| overconf_grpc = overconf.to_grpc() | ||
| else: | ||
| overconf_grpc = None | ||
|
|
||
| if borderl is not None: | ||
| borderl_grpc = borderl.to_grpc() | ||
| else: | ||
| borderl_grpc = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have feeling that this code is a bit repetitive. To me it would be better if we store those push in a list/dict to better handle them in a loop:
pushes = {
PushKind.Perturbation: create_perturbation_push(model, dataset, request.rowidx),
...
}
pushes_grpc = { push_kind: push.to_grpc() if push is not None else None for push_kind, push for pushes.items()
| borderl_grpc = None | ||
|
|
||
| if request.cta_kind > 0 and request.push_kind > 0: | ||
| if request.push_kind == PushKind.Perturbation: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plus this would become: push = pushes[request.push_kind]
| # slice_df = ds.copy() | ||
| # slice_df.df = df.reset_index(drop=True) | ||
| # slice_df.meta.number_of_rows = 1 | ||
| # slice_df = ds.slice(lambda row: row.eq(df.iloc[0]).all(axis=None)) 3 solutions I think the first is the best |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I also think that the first looks cleaner
| shap_res = _contribution_push(model, ds, idrow) | ||
| slice_df = ds.slice(lambda df: df.loc[[idrow]], row_level=False) | ||
| shap_res = _contribution_push(model, ds, df) | ||
| slice_df = ds.slice(lambda row: row.equals(df.iloc[0])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why we need to do a row by row comparison like that, it seems suboptimal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check Sonar's issues and please fix them too
| import java.util.Map; | ||
|
|
||
| @Service | ||
| //@Transactional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's rightfully not transactional since it's communicating with the ML Worker inside, you can remove the comment
| ); | ||
| }, | ||
| async getPushes(modelId: string, datasetId: string, idx: number, features: any) { | ||
| return apiV2.post<unknown, unknown>(`/pushes/${modelId}/${datasetId}/${idx}`, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you use Post request to get elements?
Why not specifying the type of the return object?
| selectedSlicingFunction: { | ||
| uuid: undefined, | ||
| params: [], | ||
| type: 'SLICING' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'SLICING' should probably be an enum
frontend/src/stores/push.ts
Outdated
| this.identifier = {modelId, datasetId, rowNb, inputData, modelFeatures}; | ||
| this.current = undefined; | ||
|
|
||
| // if (!this.pushes[modelId]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cleanup
| <v-btn small icon outlined color="warning" class="ml-1" | ||
| v-on="{ ...onMenu, ...onTooltip }"> | ||
| <v-icon size="18" color="warning">mdi-alert-outline</v-icon> | ||
| <!--<v-badge top overlap color="transparent"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cleanup
# Conflicts: # frontend/src/generated-sources/j2ts-generated-metadata.json # frontend/src/views/main/project/Inspector.vue
…to feature/merging-push-feature
…ature/merging-push-feature
…to feature/merging-push-feature
…to feature/merging-push-feature
# Conflicts: # backend/src/main/resources/config/liquibase/master.xml # frontend/src/generated-sources/index.ts # frontend/src/generated-sources/j2ts-generated-metadata.json
…to feature/merging-push-feature
# Conflicts: # frontend/src/views/main/project/Inspector.vue
…to feature/merging-push-feature
…to feature/merging-push-feature # Conflicts: # python-client/giskard/push/utils.py
|
Kudos, SonarCloud Quality Gate passed! |
) * Push Feature - Merged (#1198) Push feature --------- Co-authored-by: Mathieu Roques <[email protected]> Co-authored-by: Andrey Avtomonov <[email protected]> Co-authored-by: Kevin Messiaen <[email protected]> Co-authored-by: Rabah Abdul Khalek <[email protected]> Co-authored-by: Henrique Chaves <[email protected]> Co-authored-by: Henrique Chaves <[email protected]> * reducing bounds for push contribution * fixed missing if * restored Frontend.run.xml * list to tuple * fixed tests * fixed tests --------- Co-authored-by: Googleton <[email protected]> Co-authored-by: Mathieu Roques <[email protected]> Co-authored-by: Andrey Avtomonov <[email protected]> Co-authored-by: Kevin Messiaen <[email protected]> Co-authored-by: Henrique Chaves <[email protected]> Co-authored-by: Henrique Chaves <[email protected]>
* hashed TextTypoTransformation * Push Feature - Merged (#1198) Push feature --------- Co-authored-by: Mathieu Roques <[email protected]> Co-authored-by: Andrey Avtomonov <[email protected]> Co-authored-by: Kevin Messiaen <[email protected]> Co-authored-by: Rabah Abdul Khalek <[email protected]> Co-authored-by: Henrique Chaves <[email protected]> Co-authored-by: Henrique Chaves <[email protected]> * Update python-client/giskard/push/perturbation.py Co-authored-by: Andrey Avtomonov <[email protected]> * removed hashing logic, using seed-based approach instead * added comment about hashed_seed --------- Co-authored-by: Googleton <[email protected]> Co-authored-by: Mathieu Roques <[email protected]> Co-authored-by: Andrey Avtomonov <[email protected]> Co-authored-by: Kevin Messiaen <[email protected]> Co-authored-by: Henrique Chaves <[email protected]> Co-authored-by: Henrique Chaves <[email protected]>








Description