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

Margo/stats #12

Merged
merged 5 commits into from
Oct 17, 2023
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,6 @@ dmypy.json

# Cython debug symbols
cython_debug/

# Don't commit .csv output files
*.csv
20 changes: 19 additions & 1 deletion ersilia/core/tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,27 @@ def __init__(self):
def start_tracking(self):
self.time_start = datetime.now()

def stats(self, result):
dat = self.read_csv(result)

# drop first two columns (key, input)
dat = dat.drop(["key", "input"], axis=1)

# calculate and print statistics
for column in dat:
print("Mean %s: %s" % (column, dat[column].mean()))
if len(dat[column].mode()) == 1:
print("Mode %s: %s" % (column, dat[column].mode()))
else:
print("No mode")
print("Min %s: %s" % (column, dat[column].min()))
print("Max %s: %s" % (column, dat[column].max()))
print("Standard deviation %s: %s" % (column, dat[column].std()))

def track(self, input, result, meta):
"""
Tracks the results after a model run.
"""

print("Run input file:", input)
print(read_csv(input))

Expand All @@ -48,6 +64,8 @@ def track(self, input, result, meta):
time = datetime.now() - self.time_start
print("Time taken:", time)

self.stats(result)

input_dataframe = self.read_csv(input)
result_dataframe = self.read_csv(result)

Expand Down