Skip to content

Commit

Permalink
Add star rating to summary file (#11)
Browse files Browse the repository at this point in the history
* Add star rating based on risk-outcome score to summary file for continuous and dichotomous pipelines

* Update ROS bounds to be more interpretable
  • Loading branch information
n-gilbertson authored Feb 15, 2024
1 parent ff61da8 commit d03a0ae
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
19 changes: 17 additions & 2 deletions src/bopforge/continuous_pipeline/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ def get_linear_model_summary(
summary["beta"] = [float(beta_info[0]), float(beta_info[1])]
summary["gamma"] = [float(gamma_info[0]), float(gamma_info[1])]

# compute the score
# compute the score and add star rating
risk = np.linspace(*summary["risk_bounds"], 100)
signal = get_signal(signal_model, risk)
beta_sd = np.sqrt(beta_info[1] ** 2 + gamma_info[0] + 2 * gamma_info[1])
Expand Down Expand Up @@ -412,10 +412,25 @@ def get_linear_model_summary(
sign = np.sign(pred)
if np.any(np.prod(inner_ui[:, index], axis=0) < 0):
summary["score"] = float("nan")
summary["star_rating"] = 0
else:
summary["score"] = float(
score = float(
((sign * burden_of_proof)[:, index].mean(axis=1)).min()
)
summary["score"] = score
#Assign star rating based on ROS
if np.isnan(score):
summary["star_rating"] = 0
elif score > np.log(1 + 0.85):
summary["star_rating"] = 5
elif score > np.log(1 + 0.50):
summary["star_rating"] = 4
elif score > np.log(1 + 0.15):
summary["star_rating"] = 3
elif score > 0:
summary["star_rating"] = 2
else:
summary["star_rating"] = 1

# compute the publication bias
index = df.is_outlier == 0
Expand Down
19 changes: 17 additions & 2 deletions src/bopforge/dichotomous_pipeline/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,16 +235,31 @@ def get_linear_model_summary(
summary["beta"] = [float(beta_info[0]), float(beta_info[1])]
summary["gamma"] = [float(gamma_info[0]), float(gamma_info[1])]

# compute the score
# compute the score and add star rating
beta_sd = np.sqrt(beta_info[1] ** 2 + gamma_info[0] + 2 * gamma_info[1])
sign = np.sign(beta_info[0])
inner_ui = beta_info[0] - sign * 1.96 * beta_info[1]
burden_of_proof = beta_info[0] - sign * 1.645 * beta_sd

if inner_ui * beta_info[0] < 0:
summary["score"] = float("nan")
summary["star_rating"] = 0
else:
summary["score"] = float(0.5 * sign * burden_of_proof)
score = float(0.5 * sign * burden_of_proof)
summary["score"] = score
#Assign star rating based on ROS
if np.isnan(score):
summary["star_rating"] = 0
elif score > np.log(1 + 0.85):
summary["star_rating"] = 5
elif score > np.log(1 + 0.50):
summary["star_rating"] = 4
elif score > np.log(1 + 0.15):
summary["star_rating"] = 3
elif score > 0:
summary["star_rating"] = 2
else:
summary["star_rating"] = 1

# compute the publication bias
index = df.is_outlier == 0
Expand Down

0 comments on commit d03a0ae

Please sign in to comment.