High-level, single-call evaluation function. This orchestrates the entire process: 1. Infers the task name. 2. Fits the model on training data. 3. Evaluates the fitted model on test data. 4. Returns a dictionary with final metrics and (optionally) fitted parameters. Ar
(program_path: str, verbose: bool = False)
| 227 | return get_failure_result(str(e)) |
| 228 | |
| 229 | def evaluate(program_path: str, verbose: bool = False) -> Dict[str, Any]: |
| 230 | """ |
| 231 | High-level, single-call evaluation function. |
| 232 | |
| 233 | This orchestrates the entire process: |
| 234 | 1. Infers the task name. |
| 235 | 2. Fits the model on training data. |
| 236 | 3. Evaluates the fitted model on test data. |
| 237 | 4. Returns a dictionary with final metrics and (optionally) fitted parameters. |
| 238 | |
| 239 | Args: |
| 240 | program_path: Path to the user's Python script with scaling law functions. |
| 241 | verbose: If True, include fitted parameters and task name in the result. |
| 242 | |
| 243 | Returns: |
| 244 | A dictionary containing the evaluation results. |
| 245 | """ |
| 246 | try: |
| 247 | task_name = resolve_task_name(program_path) |
| 248 | except ValueError as e: |
| 249 | return get_failure_result(str(e)) |
| 250 | |
| 251 | # 1. Fit on training data to get parameters |
| 252 | fit_result = evaluate_core(program_path, task_name, use_test_data=False) |
| 253 | if "fitted_params" not in fit_result: |
| 254 | error = fit_result.get("error", "Unknown fitting error.") |
| 255 | return get_failure_result(f"Fitting failed: {error}") |
| 256 | |
| 257 | fitted_params_map = fit_result["fitted_params"] |
| 258 | |
| 259 | # 2. Evaluate on test data using the fitted parameters |
| 260 | test_result = evaluate_core( |
| 261 | program_path, |
| 262 | task_name, |
| 263 | use_test_data=True, |
| 264 | fitted_params_map=fitted_params_map, |
| 265 | ) |
| 266 | |
| 267 | # 3. Combine results into a comprehensive output |
| 268 | if verbose: |
| 269 | test_result["fitted_params"] = fitted_params_map |
| 270 | test_result["task_name"] = task_name |
| 271 | return test_result |
| 272 | |
| 273 | # --- Script Entrypoint --- |
| 274 |
no test coverage detected