-
-
Notifications
You must be signed in to change notification settings - Fork 78
Open
Labels
Description
Describe the feature you want to add
Add beauty score to Samila.
Describe your proposed solution
def beauty_score(x_vals, y_vals, bins=100):
if len(x_vals) == 0 or len(y_vals) == 0:
return 0.0
# Basic sanity checks
if np.any(np.isnan(x_vals)) or np.any(np.isnan(y_vals)):
return 0.0
if np.any(np.isinf(x_vals)) or np.any(np.isinf(y_vals)):
return 0.0
# Check spread (avoid too flat)
std_x = np.std(x_vals)
std_y = np.std(y_vals)
if std_x < 1e-3 or std_y < 1e-3:
return 0.0
# Check diversity (avoid identical points)
unique_ratio = len(set(np.round(x_vals, 4))) / len(x_vals)
if unique_ratio < 0.05:
return 0.0
# Check entropy of x and y (avoid regular grids)
hx, _ = np.histogram(x_vals, bins=bins, density=True)
hy, _ = np.histogram(y_vals, bins=bins, density=True)
ent_x = entropy(hx + 1e-9)
ent_y = entropy(hy + 1e-9)
# Normalize entropy to 0–1 (approximate)
max_entropy = np.log(bins)
ent_x /= max_entropy
ent_y /= max_entropy
# Combine all
score = (
0.2 * (std_x + std_y) + # encourage spread
0.3 * unique_ratio + # encourage diversity
0.5 * (ent_x + ent_y) / 2 # encourage organic layout
)
return min(max(score, 0.0), 1.0)Describe alternatives you've considered, if relevant
No response
Additional context
No response
Reactions are currently unavailable