Skip to content

Commit

Permalink
set up model test metrics that can either be pulled from Training or …
Browse files Browse the repository at this point in the history
…from Inference Runs
  • Loading branch information
brifordwylie committed Oct 19, 2023
1 parent 0e96222 commit 076bd43
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
2 changes: 1 addition & 1 deletion applications/aws_dashboard/pages/models/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def models_layout(
dbc.Col(
[
dbc.Row(
html.H3("Model Metrics", id="model_metrics_header"),
html.H3("Model Testing", id="model_metrics_header"),
style={"padding": "30px 0px 10px 0px"},
),
dbc.Row(
Expand Down
13 changes: 13 additions & 0 deletions src/sageworks/artifacts/models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,16 @@ def regression_predictions(self) -> Union[pd.DataFrame, None]:
df = self._pull_s3_model_artifacts(s3_path)
return df

def _pull_inference_metadata(self) -> Union[dict, None]:
"""Internal: Retrieve the inference metadata for this model
Returns:
dict: Dictionary of the inference metadata (might be None)
Notes:
Basically when the inference was run, name of the dataset, the MD5, etc
"""
s3_path = f"{self.model_inference_path}/{self.model_name}/inference_meta.csv"
return wr.s3.read_json(s3_path)

def _pull_inference_metrics(self) -> Union[pd.DataFrame, None]:
"""Internal: Retrieve the inference model metrics for this model
Returns:
Expand Down Expand Up @@ -230,6 +240,9 @@ def details(self, recompute=False) -> dict:
details["confusion_matrix"] = self.confusion_matrix()
details["regression_predictions"] = self.regression_predictions()

# Grab the inference metadata
details["inference_meta"] = self._pull_inference_metadata()

# Cache the details
self.data_storage.set(storage_key, details)

Expand Down
25 changes: 17 additions & 8 deletions src/sageworks/web_components/model_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def generate_markdown(self, model_details: dict) -> str:
# Create simple markdown by iterating through the model_details dictionary

# Excluded keys from the model_details dictionary (and any keys that end with '_arn')
exclude = ["size", "uuid"]
exclude = ["size", "uuid", "inference_meta"]
top_level_details = {
key: value for key, value in model_details.items() if key not in exclude and not key.endswith("_arn")
}
Expand All @@ -51,14 +51,23 @@ def generate_markdown(self, model_details: dict) -> str:
# Add to markdown string
markdown += f"**{key}:** {value_str} \n"

# Model Metrics
markdown += "### Model Metrics \n"
if model_details["uuid"] == "abalone-regression":
markdown += "**Test Data:** Abalone_Regression_Test_2023_10_11 \n"
markdown += "**Test Data Hash:** ebea16fbc63574fe91dcac35a0b2432f \n"
# Model Test Metrics
markdown += "### Model Test Metrics \n"
if model_details.get("inference_meta"):
test_data = model_details["inference_meta"].get("test_data", " - ")
test_data_hash = model_details["inference_meta"].get("test_data_hash", " - ")
test_rows = model_details["inference_meta"].get("test_rows", " - ")
description = model_details["inference_meta"].get("description", " - ")
else:
markdown += "**Test Data:** Wine_Classification_Test_2023_09_03 \n"
markdown += "**Test Data Hash:** cac35a0b2432febea16fbc63574fe91d \n"
test_data = "AWS Training Capture"
test_data_hash = " N/A "
test_rows = " - "
description = " - "

markdown += f"**Test Data:** {test_data} \n"
markdown += f"**Data Hash:** {test_data_hash} \n"
markdown += f"**Test Rows:** {test_rows} \n"
markdown += f"**Description:** {description} \n"

# Grab the Metrics from the model details
metrics = model_details.get("model_metrics")
Expand Down

0 comments on commit 076bd43

Please sign in to comment.