MCPcopy Create free account
hub / github.com/InternScience/InternAgent / evaluate_model

Function evaluate_model

tasks/AutoDebug/code/experiment.py:87–103  ·  view source on GitHub ↗

Evaluate model and return metrics

(model, X_test, y_test, device='cpu')

Source from the content-addressed store, hash-verified

85
86
87def evaluate_model(model, X_test, y_test, device='cpu'):
88 """Evaluate model and return metrics"""
89 model.eval()
90 X_tensor = torch.FloatTensor(X_test).to(device)
91
92 with torch.no_grad():
93 predictions = model(X_tensor).cpu().numpy()
94
95 mse = mean_squared_error(y_test, predictions)
96 r2 = r2_score(y_test, predictions)
97 mae = mean_absolute_error(y_test, predictions)
98
99 return {
100 'mse': float(mse),
101 'r2': float(r2),
102 'mae': float(mae)
103 }
104
105
106def run_experiment(config=None):

Callers 1

run_experimentFunction · 0.85

Calls 1

toMethod · 0.45

Tested by

no test coverage detected