Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

divide by 2 was incorrect, fixed normalization by num possible #18

Merged
merged 2 commits into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/matbench_genmetrics/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,16 @@ def duplicity_counts(self):
if self.num_test != self.num_gen:
raise ValueError("Test and gen sets should be identical.")
# TODO: assert that test and gen sets are identical
return np.clip(self.match_counts - 1, 0, None) / 2
return np.clip(self.match_counts - 1, 0, None)

@property
def duplicity_count(self):
return np.sum(self.duplicity_counts)

@property
def duplicity_rate(self):
return self.duplicity_count / self.num_test
num_possible = self.num_test**2 - self.num_test
return self.duplicity_count / num_possible


class GenMetrics(object):
Expand Down
3 changes: 2 additions & 1 deletion tests/test_matbench_genmetrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def test_mpts_metrics():

mptm.evaluate_and_record(fold, gen_structures)

# TODO: check that all metrics are between 0 and 1
print(mptm.recorded_metrics)


Expand All @@ -134,7 +135,7 @@ def test_non_verbose():
np.random.seed(10)
dg = DummyGenerator()
dg.fit(train_val_inputs)
gen_structures = dg.gen(n=2)
gen_structures = dg.gen(n=3)

mptm.evaluate_and_record(fold, gen_structures)

Expand Down