MCPcopy Create free account
hub / github.com/algorithmicsuperintelligence/openevolve / evaluate

Function evaluate

examples/sldbench/evaluator.py:229–271  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

227 return get_failure_result(str(e))
228
229def 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

Callers 1

evaluator.pyFile · 0.70

Calls 4

resolve_task_nameFunction · 0.85
get_failure_resultFunction · 0.85
evaluate_coreFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected