Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
course_materials
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nlu_public
course_materials
Compare revisions
67abe33d52e7626b548e5c1b5b3de8e2062cea55 to c6f9c7542cde4eb6bb3c6d8f89694d99d657edb8
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
nlu_public/course_materials
Select target project
No results found
c6f9c7542cde4eb6bb3c6d8f89694d99d657edb8
Select Git revision
Branches
main
Swap
Target
nlu_public/course_materials
Select target project
nlu_public/course_materials
1 result
67abe33d52e7626b548e5c1b5b3de8e2062cea55
Select Git revision
Branches
main
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (2)
commit
· 80c05445
Shay Cohen
authored
2 weeks ago
80c05445
commit
· c6f9c754
Shay Cohen
authored
2 weeks ago
c6f9c754
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
2025/coursework/cw2/code_question/shapley_value_evaluation.py
+0
-20
0 additions, 20 deletions
.../coursework/cw2/code_question/shapley_value_evaluation.py
2025/coursework/cw2/cw2.zip
+0
-0
0 additions, 0 deletions
2025/coursework/cw2/cw2.zip
with
0 additions
and
20 deletions
2025/coursework/cw2/code_question/shapley_value_evaluation.py
View file @
c6f9c754
...
...
@@ -18,10 +18,6 @@ def get_missing_steps(row, steps):
###Question 4: INSERT CODE HERE: Get missing steps as a tuple for each row.###
##############################################################################
raise
NotImplementedError
(
"
Get missing steps as a tuple for each row.
"
)
for
step
in
steps
:
col_name
=
f
'
step
{
step
}
_missing
'
if
row
[
col_name
]
==
1
:
missing_steps
.
append
(
step
)
return
tuple
(
sorted
(
missing_steps
))
def
generate_all_subsets
(
steps
):
...
...
@@ -53,13 +49,6 @@ def compute_v_S(df, all_subsets_missing):
###Question 5: INSERT CODE HERE: Compute v(S) for all subsets of missing steps.###
##################################################################################
raise
NotImplementedError
(
"
Implement the code to compute v(S) for all subsets of missing steps.
"
)
v_S
=
{}
grouped
=
df
.
groupby
(
'
missing_steps
'
)[
'
is_correct
'
].
mean
().
to_dict
()
for
S
in
all_subsets_missing
:
if
S
in
grouped
:
v_S
[
S
]
=
grouped
[
S
]
else
:
v_S
[
S
]
=
np
.
nan
# Code Explanation: Please do not remove. Assign NaN if the subset is not in the data
return
v_S
def
compute_marginal_contributions
(
steps
,
v_S
):
...
...
@@ -87,15 +76,6 @@ def compute_marginal_contributions(steps, v_S):
###Question 6: INSERT CODE HERE: Retrieve S_i, S_i_union_i, S_i_sorted, S_i_union_i_sorted###
#############################################################################################
raise
NotImplementedError
(
"
Implement the retrieval of S_i, S_i_union_i, and their sorted tuples.
"
)
S_i
=
set
(
pi
[:
idx_i
])
# Steps before i in the permutation
S_i_union_i
=
S_i
.
union
({
i
})
# Code Explanation below: Please do not remove. Additional tips about the function: Compute missing steps for S_i and S_i_union_i
missing_S_i
=
total_steps_set
-
S_i
missing_S_i_union_i
=
total_steps_set
-
S_i_union_i
# Code Explanation below: Please do not remove. Convert to sorted tuples to match keys in v_S
missing_S_i_sorted
=
tuple
(
sorted
(
missing_S_i
))
missing_S_i_union_i_sorted
=
tuple
(
sorted
(
missing_S_i_union_i
))
v_S_i
=
v_S
.
get
(
missing_S_i_sorted
,
np
.
nan
)
v_S_i_union_i
=
v_S
.
get
(
missing_S_i_union_i_sorted
,
np
.
nan
)
if
np
.
isnan
(
v_S_i
)
or
np
.
isnan
(
v_S_i_union_i
):
...
...
This diff is collapsed.
Click to expand it.
2025/coursework/cw2/cw2.zip
View file @
c6f9c754
No preview for this file type
This diff is collapsed.
Click to expand it.