Skip to content

Commit

Permalink
Merge branch 'pegasystems:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
yusufuyanik1 authored Oct 17, 2023
2 parents 1d56061 + 552639b commit 5aba71a
Show file tree
Hide file tree
Showing 5 changed files with 592 additions and 223 deletions.
25 changes: 17 additions & 8 deletions examples/datamart/healthcheck.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -221,18 +221,27 @@ configurations it seems that the framework
- Channels with no positive feedback

```{r Channel overview}
channelSummary <- datamart$modeldata[, .(`Responses` = max(ResponseCount),
`Positives` = max(Positives),
`Base rate` = sprintf("%.2f%%", 100*max(Positives)/max(ResponseCount)),
`Supported by Configurations` = paste(sort(unique(ConfigurationName)), collapse = ", "),
N = uniqueN(ConfigurationName)),
by=c("Channel","Direction")][order(Channel)]
# take the max counts per model
channelSummaryMaxByModel <- datamart$modeldata[, .(Responses = max(ResponseCount),
Positives = max(Positives)),
by=c("Direction", "Channel", "ModelID", "ConfigurationName")]
# sum up the response counts per configuration and channel
channelSummaryCountsByConfiguration <- channelSummaryMaxByModel[, .(Responses = sum(Responses),
Positives = sum(Positives)),
by=c("Direction", "Channel", "ConfigurationName")]
# multiple model configurations could be driving one channel, take the max
channelSummary <- channelSummaryCountsByConfiguration[, .(Responses = max(Responses),
Positives = max(Positives),
`Base rate` = sprintf("%.2f%%", 100*max(Positives)/max(Responses)),
`Supported by Configurations` = paste(sort(unique(ConfigurationName)), collapse = ", "),
N = uniqueN(ConfigurationName)), by=c("Direction", "Channel")][order(Channel, Direction)]
channelSummary[, 1:(ncol(channelSummary)-1)] %>%
kbl() %>%
kable_paper(c("striped", "hover"), full_width = F) %>%
column_spec(3, background = ifelse(channelSummary[[3]] > 0 ,"white", "red")) %>%
column_spec(4, background = ifelse(channelSummary[[4]] > 0 ,"white", "red")) %>%
column_spec(3, background = ifelse(channelSummary$Responses > 0 ,"white", "red")) %>%
column_spec(4, background = ifelse(channelSummary$Positives > 0 ,"white", "red")) %>%
column_spec(6, background = ifelse(channelSummary$N <= 2 ,"white", "orange"))
```

Expand Down
4 changes: 3 additions & 1 deletion python/pdstools/plots/plots_plotly.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ def distribution_graph(df, title):
template="none", title=title, xaxis_title="Range", yaxis_title="Responses"
)
fig.update_yaxes(title_text="Propensity", secondary_y=True)
fig.layout.yaxis2.tickformat = ",.2%"
fig.layout.yaxis2.tickformat = ",.3%"
fig.layout.yaxis2.zeroline = False
fig.update_yaxes(showgrid=False)
fig.update_xaxes(type='category')

return fig

Expand Down Expand Up @@ -342,6 +343,7 @@ def PredictorBinning(self, df, facet_val, **kwargs):
name = df.select(["Name"]).row(0)
modelid, predictorname = facet_val
title = f"Model name: {name}<br><sup>Model ID: {modelid}<br>Predictor name: {predictorname}</sup>"
df = df.sort("BinIndex")
fig = self.distribution_graph(df, title)
return self.post_plot(fig, name="Predictor_binning", **kwargs)

Expand Down
Loading

0 comments on commit 5aba71a

Please sign in to comment.