Skip to content

Commit

Permalink
vimp dropna fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vnijs committed Nov 27, 2024
1 parent 3544448 commit dbb4356
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pyrsm/model/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ def vimp_plot_sm(fitted, data, rep=10, ax=None, ret=False):

rvar = extract_rvar(model, data.columns)
evars = extract_evars(model, data.columns)
data = data[[rvar] + evars].copy().reset_index(drop=True).dropna()
data = data[[rvar] + evars].copy().dropna().reset_index(drop=True)

if len(model.endog) != data.shape[0]:
raise Exception(
Expand Down Expand Up @@ -578,6 +578,7 @@ def imp_calc_logit(base, pred):
importance_values = {k: [v / rep] for k, v in importance_values.items()}
sorted_idx = pd.DataFrame(importance_values).transpose()
sorted_idx = sorted_idx.sort_values(0, ascending=True)
print(importance_values)
fig = sorted_idx.plot.barh(
color="slateblue",
legend=None,
Expand Down

0 comments on commit dbb4356

Please sign in to comment.