-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
23 lines (15 loc) · 864 Bytes
/
test.py
File metadata and controls
23 lines (15 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from predict_tm_score import predict_tm_score
from feature_matrix import build_feature_matrix
def test_model(pssm_test, pssm_dir, fasta_dir, tm_align_dir):
# Build the feature matrix
feature_matrix = build_feature_matrix(pssm_test, pssm_dir, fasta_dir, tm_align_dir)
# Calculate squared errors
squared_errors = [calc_squared_error(feature) for feature in feature_matrix]
average_error = sum(squared_errors) / len(squared_errors)
print('\nAverage of squared errors on the test set: {}'.format(average_error))
print('Maximum squared error: {}'.format(max(squared_errors)))
print('Minimum squared error: {}'.format(min(squared_errors)))
def calc_squared_error(feature):
actual_tm_score = feature.pop('tm-score', 0.0)
predicted_tm_score = predict_tm_score(feature)
return (actual_tm_score - predicted_tm_score) ** 2