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

added sampling df function #9

Merged
merged 1 commit into from
Oct 17, 2023
Merged
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
19 changes: 13 additions & 6 deletions ersilia/core/tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
import pandas as pd


def read_csv(file):
# reads csv file and returns Pandas dataframe
return pd.read_csv(file)


class RunTracker:
"""
This class will be responsible for tracking model runs. It calculates the desired metadata based on a model's
Expand All @@ -11,27 +16,29 @@ class RunTracker:
NOTE: Currently, the Splunk connection is not set up. For now, we will print tracking results to the console.
"""

def sample_df(self, df, num_rows, num_cols):
"""
Returns a sample of the dataframe, with the specified number of rows and columns.
"""
return df.sample(num_rows, axis=0).sample(num_cols, axis=1)

def __init__(self):
self.time_start = None

# function to be called before model is run
def start_tracking(self):
self.time_start = datetime.now()

def read_csv(self, file):
# reads csv file and returns Pandas dataframe
return pd.read_csv(file)

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

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

print("Run output file:", result)
print(self.read_csv(result))
print(read_csv(result))

print("Model metadata:", meta)

Expand Down