-
Notifications
You must be signed in to change notification settings - Fork 9
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
feat(l2gprediction): add score explanation based on features #939
base: dev
Are you sure you want to change the base?
Conversation
…-shapley-predictions
The new version fixes the bug in the previous one by avoiding the operations with dictionaries, and just building the new map by joining the initial dataframe with the dataframe with the contributions. Getting the shapley values takes time, but in my experiments creating the Spark dataframe from the Pandas df was the real bottleneck. The code might complain with memory issues when run locally on a very big dataframe. I have tried avoiding this by using Pandas UDFs taking this and this as a guide, but Spark kept crashing due to serialization issues. Predicting now has gone from 6m to 13m (job). All predictions have their explanations built in. |
✨ Context
This PR closes opentargets/issues#3664
This is how the prioritisation for the
44acafc7985c3180b072394a28d7bad9
locus row looks like:All results available at:
gs://ot-team/irene/l2g/06122024/locus_to_gene_predictions
All predictions have their corresponding explanations.
🛠 What does this PR implement
shapleyValues
field (map type) in the prediction schemaconvert_map_type_to_columns
to convert the feature annotation in thelocusToGeneFeatures
map type to a dataframe that I can pass to the SHAP explainermodel
as an instance attribute to the Predictions dataset.explain
method in the predictions dataset. Calculates shapley values and returns another object with the new column.Dataset.filter
so that the returned new instance of the object maintains the attributes. This was necessary to propagate themodel
instance attribute after each modification of the predictions dataset.🙈 Missing
predictions.explain()
interactively.🚦 Before submitting
dev
branch?make test
)?poetry run pre-commit run --all-files
)?