-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #153 from DARPA-ASKEM/config-model-from-data
Add support for parameterization via datasets
- Loading branch information
Showing
4 changed files
with
101 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/askem_beaker/contexts/model_configuration/procedures/python3/describe_dataset.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import pandas as pd | ||
|
||
def describe_dataframe_structure(df): | ||
# Basic information about the DataFrame | ||
description = f"The DataFrame has {df.shape[0]} rows and {df.shape[1]} columns.\n" | ||
|
||
# Extract column names and types | ||
description += "Column names and types:\n" | ||
for column in df.columns: | ||
description += f"- {column}: {df[column].dtype}\n" | ||
|
||
# Check if the DataFrame has a matrix-like structure | ||
if not df.index.is_integer(): | ||
description += "The DataFrame appears to have a matrix-like structure with row headers.\n" | ||
description += "Row headers:\n" | ||
for idx_name in df.index.names: | ||
description += f"- {idx_name or 'Unnamed index'}: {df.index.get_level_values(idx_name).dtype}\n" | ||
|
||
# Append the head of the DataFrame | ||
description += "\nThe first few rows of the DataFrame (head):\n" | ||
description += df.head().to_string(index=True) | ||
|
||
return description | ||
|
||
describe_dataframe_structure({{ dataset_name }}) |
2 changes: 2 additions & 0 deletions
2
src/askem_beaker/contexts/model_configuration/procedures/python3/load_dataset.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import pandas as pd | ||
{{ var_name }} = pd.read_csv('{{ data_url }}') |