Skip to content

Conversation

@Googleton
Copy link
Contributor

Description

@Googleton Googleton requested a review from andreybavt June 23, 2023 09:12
@Googleton
Copy link
Contributor Author

For some reason my formatter still changed a ton of white spaces. Any idea @andreybavt ?

@andreybavt andreybavt requested a review from kevinmessiaen June 27, 2023 13:04
@andreybavt andreybavt marked this pull request as ready for review June 30, 2023 09:06


# Classification
def test_instance_if_not_none(german_credit_model, german_credit_data):
Copy link
Member

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

Comment on lines +7 to +8
current: Pushes | undefined;
identifier: PushIdentifier | undefined;
Copy link
Member

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:

Suggested change
current: Pushes | undefined;
identifier: PushIdentifier | undefined;
current?: Pushes;
identifier?: PushIdentifier;

Comment on lines 41 to 42
// @ts-ignore
this.pushes[modelId][datasetId][rowNb] = await api.getPushes(modelId, datasetId, rowNb);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// @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");
Copy link
Member

@kevinmessiaen kevinmessiaen Jul 3, 2023

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

Suggested change
console.log("RowNb changed");

Comment on lines 526 to 544
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
Copy link
Member

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:
Copy link
Member

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
Copy link
Member

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]))
Copy link
Member

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.

Copy link
Contributor

@andreybavt andreybavt left a 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
Copy link
Contributor

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}`, {
Copy link
Contributor

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'
Copy link
Contributor

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

this.identifier = {modelId, datasetId, rowNb, inputData, modelFeatures};
this.current = undefined;

// if (!this.pushes[modelId]) {
Copy link
Contributor

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">
Copy link
Contributor

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
Googleton and others added 26 commits August 29, 2023 14:23
# Conflicts:
#	backend/src/main/resources/config/liquibase/master.xml
#	frontend/src/generated-sources/index.ts
#	frontend/src/generated-sources/j2ts-generated-metadata.json
# Conflicts:
#	frontend/src/views/main/project/Inspector.vue
…to feature/merging-push-feature

# Conflicts:
#	python-client/giskard/push/utils.py
@sonarqubecloud
Copy link

sonarqubecloud bot commented Sep 1, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

46.4% 46.4% Coverage
0.0% 0.0% Duplication

@andreybavt andreybavt merged commit 495d238 into main Sep 1, 2023
andreybavt added a commit that referenced this pull request Sep 5, 2023
)

* 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]>
andreybavt added a commit that referenced this pull request Sep 6, 2023
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backend Frontend Python Pull requests that update Python code

Development

Successfully merging this pull request may close these issues.

7 participants