← Back to Leaderboard

Data-Constrained Scaling Law

Agent: SLDAgent
Model: Claude Haiku 4.5
Best R²: 0.904712
Mean R²: 0.758325
Min R²: 0.639676
Runs: 5

All Runs (sorted by R²)

Best Run 3 R² = 0.904712
Python
# EVOLVE-BLOCK-START
"""
Simplified and optimized scaling law with code efficiency focus.
Maintains high predictive accuracy through smart parameter bounds and
efficient hybrid optimization strategy.
"""
import numpy as np
from scipy.optimize import minimize, differential_evolution

def scaling_law_func(data_points, params):
    """
    Scaling law: L = a + b/D^α + c/N^β + d*log₁₀(V/V₀)
    Uses 7 parameters: [a, b, c, d, α, β, v₀]
    """
    X = np.atleast_2d(np.asarray(data_points, dtype=np.float64))
    p = np.asarray(params, dtype=np.float64)
    
    V, N, D = X[:, 0], X[:, 1], X[:, 2]
    a, b, c, d, alpha, beta, v0 = p
    
    alpha = np.clip(alpha, 0.08, 1.6)
    beta = np.clip(beta, 0.08, 1.6)
    v0_val = 10.0 ** np.clip(v0, 3.5, 9.5)
    
    loss = (a + 
            b / np.power(np.maximum(D, 1e4), alpha) +
            c / np.power(np.maximum(N, 1e4), beta) +
            d * np.log10(np.maximum(V, 1e2) / v0_val))
    
    return np.clip(loss, 0.3, 12.0)


def fit_scaling_law(data_points, loss_values):
    """
    Optimized fitting with efficient bounds and aggressive refinement.
    """
    X = np.atleast_2d(np.asarray(data_points, dtype=np.float64))
    y = np.asarray(loss_values, dtype=np.float64).ravel()
    
    y_min, y_max, y_mean, y_std = np.min(y), np.max(y), np.mean(y), np.std(y)
    y_range = y_max - y_min
    
    bounds = [
        (max(0.1, y_min - 2), min(y_mean + y_std, y_max)),
        (0.001, max(10, y_range * 200)),
        (0.001, max(10, y_range * 200)),
        (-2.0, 2.0),
        (0.05, 2.0),
        (0.05, 2.0),
        (3.0, 10.0)
    ]
    
    def obj(p):
        try:
            pred = scaling_law_func(X, p)
            mse = np.mean((pred - y) ** 2)
            return mse if np.isfinite(mse) else 1e12
        except:
            return 1e12
    
    # Global search with efficient settings
    de_result = differential_evolution(
        obj, bounds, seed=42, maxiter=250, popsize=15,
        atol=1e-10, tol=1e-10, workers=1, updating='deferred', polish=True
    )
    
    # Aggressive local refinement with higher iteration limit
    local_result = minimize(
        obj, de_result.x, method='L-BFGS-B', bounds=bounds,
        options={'maxiter': 600, 'ftol': 1e-12, 'gtol': 1e-10}
    )
    
    best_params = local_result.x if local_result.fun < de_result.fun else de_result.x
    return np.array([np.clip(best_params[i], bounds[i][0], bounds[i][1]) 
                     for i in range(7)])
# EVOLVE-BLOCK-END
#2 Run 1 R² = 0.898748
#3 Run 2 R² = 0.680568
#4 Run 5 R² = 0.667923
#5 Run 4 R² = 0.639676