Skip to content

Commit

Permalink
get Model.hash
Browse files Browse the repository at this point in the history
  • Loading branch information
dilpath committed Jan 6, 2025
1 parent 24cccc9 commit c9d0673
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions petab_select/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,21 +181,19 @@ def get_relative_criterion_values(


def get_weights(
models: list[Model], criterion: Criterion
models: list[Model],
criterion: Criterion,
) -> dict[ModelHash, float]:
"""Calculate weights for a model based on different criteria.
Parameters
----------
model:
The calibrated petab-select model.
criterion:
Criterion to calculate weights of.
Returns
-------
dict:
Dictionary with model hashes as keys and weights as values.
Args:
model:
The calibrated petab-select model.
criterion:
Criterion to calculate weights of.
Returns:
Keys are model hashes, values are weights.
"""
weights = {}
criterion_values = [model.get_criterion(criterion) for model in models]
Expand All @@ -210,6 +208,6 @@ def get_weights(
weight = np.exp(
-0.5 * (criterion_values[i] - np.min(criterion_values))
) / np.sum(np.exp(-0.5 * delta_criterion_values))
weights[model.get_hash()] = weight
weights[model.hash] = weight

return weights

0 comments on commit c9d0673

Please sign in to comment.