Spaces:
Runtime error
Runtime error
update
Browse files
src/similarity_model/feature_similarity.py
CHANGED
|
@@ -143,17 +143,15 @@ def compute_feature_similarity(
|
|
| 143 |
matched_a.add(i)
|
| 144 |
matched_b.add(j)
|
| 145 |
|
| 146 |
-
# Final Metrics
|
| 147 |
import numpy as np
|
| 148 |
shared_scores = [m["score"] for m in matches]
|
| 149 |
mean_similarity = float(np.mean(shared_scores)) if shared_scores else 0.0
|
| 150 |
|
| 151 |
-
|
| 152 |
-
coverage = len(matches) /
|
| 153 |
|
| 154 |
-
|
| 155 |
-
if
|
| 156 |
-
final_score = 0.0
|
| 157 |
|
| 158 |
final_score = min(final_score, 1.0)
|
| 159 |
|
|
|
|
| 143 |
matched_a.add(i)
|
| 144 |
matched_b.add(j)
|
| 145 |
|
|
|
|
| 146 |
import numpy as np
|
| 147 |
shared_scores = [m["score"] for m in matches]
|
| 148 |
mean_similarity = float(np.mean(shared_scores)) if shared_scores else 0.0
|
| 149 |
|
| 150 |
+
max_len = max(len(fa), len(fb))
|
| 151 |
+
coverage = len(matches) / max_len if max_len > 0 else 0.0
|
| 152 |
|
| 153 |
+
sum_similarity = sum(shared_scores)
|
| 154 |
+
final_score = sum_similarity / max_len if max_len > 0 else 0.0
|
|
|
|
| 155 |
|
| 156 |
final_score = min(final_score, 1.0)
|
| 157 |
|
src/similarity_model/hybrid_ranker.py
CHANGED
|
@@ -135,25 +135,14 @@ def compute_originality(
|
|
| 135 |
"""
|
| 136 |
Originality Score (0-100)
|
| 137 |
|
| 138 |
-
- Driven
|
| 139 |
-
- Boosted by the uniqueness of the features.
|
| 140 |
"""
|
| 141 |
|
| 142 |
hybrid_score = clamp(hybrid_score)
|
| 143 |
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
else 1.0
|
| 148 |
-
)
|
| 149 |
-
|
| 150 |
-
# Non-linear penalty: 50% similarity drops originality slightly,
|
| 151 |
-
# but 90% similarity drops it massively.
|
| 152 |
-
similarity_penalty = hybrid_score ** 2
|
| 153 |
-
base_originality = 1.0 - similarity_penalty
|
| 154 |
-
|
| 155 |
-
# Blend uniqueness and base originality
|
| 156 |
-
originality = (0.40 * uniqueness_ratio) + (0.60 * base_originality)
|
| 157 |
|
| 158 |
return round(
|
| 159 |
max(0.0, min(100.0, originality * 100)),
|
|
|
|
| 135 |
"""
|
| 136 |
Originality Score (0-100)
|
| 137 |
|
| 138 |
+
- Driven strictly by inverse of hybrid similarity (non-linear).
|
|
|
|
| 139 |
"""
|
| 140 |
|
| 141 |
hybrid_score = clamp(hybrid_score)
|
| 142 |
|
| 143 |
+
# Non-linear penalty: 50% similarity drops originality slightly (to 75%),
|
| 144 |
+
# but 90% similarity drops it massively (to 19%).
|
| 145 |
+
originality = 1.0 - (hybrid_score ** 2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
|
| 147 |
return round(
|
| 148 |
max(0.0, min(100.0, originality * 100)),
|