Skip to content

Commit

Permalink
Changes from review
Browse files Browse the repository at this point in the history
  • Loading branch information
whohensee committed Oct 15, 2024
1 parent 73a3743 commit 0c426ba
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 35 deletions.
25 changes: 0 additions & 25 deletions models/deepscore.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,31 +120,6 @@ def from_measurements(measurements, provenance=None, **kwargs):

return score

def evaluate_scores(self):
"""Evaluate the ML/DL score for the associated measurement, using the
appropriate algorithm.
"""
# consider doing cases or another solution, for now just if-else block

algo = Provenance.get( self.provenance_id ).parameters['algorithm']

if algo == 'random':
self.score = np.random.default_rng().random()
self.algorithm = algo

elif algo == 'allperfect':
self.score = 1.0
self.algorithm = algo

elif algo in DeepscoreAlgorithmConverter.dict_inverse:
raise NotImplementedError(f"algorithm {algo} isn't yet implemented")

else:
raise ValueError(f"{algo} is not a valid ML algorithm.")

return None


def get_upstreams(self, session=None):
"""Get the measurements that was used to make this deepscore. """
with SmartSession(session) as session:
Expand Down
13 changes: 3 additions & 10 deletions pipeline/data_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -1668,19 +1668,12 @@ def get_scores(self, provenance=None, reload=False, session=None):

# sort the scores so the list order matches measurements
if scores is not None and len(scores) > 0:

if len(scores) != len(self.measurements):
raise RuntimeError(f"get_scores found {len(scores)} scores for {len(self.measurements)} measurements")

m_ids = [str(m.id) for m in self.measurements]
sorted_scores = [None]*len(self.scores)
for score in scores:
idx = m_ids.index(str(score.measurements_id))
sorted_scores[idx] = score

if not all(scores): # check if any None still remain
raise RuntimeError(f"get_scores did not replace all None values when sorting list")

scores = sorted_scores
self.scores = scores # update the order in ds to be sorted too.
scores.sort( key=lambda x: m_ids.index( str(x.measurements_id) ) )

return scores

Expand Down

0 comments on commit 0c426ba

Please sign in to comment.