Changed the regression test to only run models for the output being tested.

This commit is contained in:
Hunter Nichols 2021-06-16 23:50:20 -07:00
parent 4132decd32
commit 131ff8bcef
2 changed files with 8 additions and 3 deletions

View File

@ -167,7 +167,7 @@ class regression_model(simulation):
output_num+=1
def cross_validation(self):
def cross_validation(self, test_only=None):
"""Wrapper for sklean cross validation function for OpenRAM regression models.
Returns the mean accuracy for each model/output."""
@ -183,7 +183,11 @@ class regression_model(simulation):
models = {}
debug.info(1, "Output name, mean_accuracy, std_dev")
model_scores = {}
for o_name in self.output_names:
if test_only != None:
test_outputs = test_only
else:
test_outputs = self.output_names
for o_name in test_outputs:
output_label = labels[:,output_num]
scores = cross_val_score(untrained_model, features, output_label, cv=10)
debug.info(1, "{}, {}, {}".format(o_name, scores.mean(), scores.std()))

View File

@ -52,7 +52,8 @@ class regression_model_test(openram_test):
#m = linear_regression(s.s, tempspice, corner)
m = neural_network(s.s, tempspice, corner)
scores = m.cross_validation()
only_test = ['rise_delay']
scores = m.cross_validation(only_test)
accuracy_requirement = 0.75
self.assertTrue(scores['rise_delay'] >= accuracy_requirement)