Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • nlu_public/course_materials
1 result
Show changes
Commits on Source (2)
......@@ -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):
......
No preview for this file type