feat: Add ranking in kaggle scenario (#401)

* fix some bugs in rag

* add ranking in kaggle scenario

* fix two mistouches

* fix two bugs

* fix a bug
This commit is contained in:
WinstonLiyt
2024-09-30 04:15:07 +08:00
committed by GitHub
parent 59cdf946a7
commit 8ec00a5120
7 changed files with 45 additions and 15 deletions
@@ -148,6 +148,16 @@ class KGHypothesisExperiment2Feedback(HypothesisExperiment2Feedback):
new_hypothesis = response_json.get("New Hypothesis", "No new hypothesis provided")
reason = response_json.get("Reasoning", "No reasoning provided")
decision = convert2bool(response_json.get("Replace Best Result", "no"))
leaderboard = self.scen.leaderboard
current_score = current_result.iloc[0]
sorted_scores = sorted(leaderboard, reverse=True)
import bisect
if self.scen.evaluation_metric_direction:
insert_position = bisect.bisect_right([-score for score in sorted_scores], -current_score)
else:
insert_position = bisect.bisect_left(sorted_scores, current_score, lo=0, hi=len(sorted_scores))
percentile_ranking = (insert_position) / (len(sorted_scores)) * 100
experiment_feedback = {
"current_competition": self.scen.get_competition_full_desc(),
@@ -158,6 +168,7 @@ class KGHypothesisExperiment2Feedback(HypothesisExperiment2Feedback):
"observations": observations,
"hypothesis_evaluation": hypothesis_evaluation,
"reason": reason,
"percentile_ranking": percentile_ranking,
}
if self.scen.if_using_vector_rag: