SIENTIAPDE-1273
Refactor data handling in various modules to ensure DataFrame consistency - Replaced direct DataFrame instantiation with `ensure_dataframe` utility in Gates, MLFlow, OPC, and ModelMetrics classes to standardize data handling. - Updated return types in several asynchronous methods to return DataFrames instead of dictionaries for improved usability. - Adjusted data export processes in workflows to convert DataFrames to dictionaries with `to_dict(orient='records')` for compatibility with downstream systems.
This commit is contained in:
@@ -138,7 +138,7 @@ class ModelMetrics(SientiaMonitoring):
|
||||
|
||||
|
||||
@activity.defn(name='calculate_drift')
|
||||
async def calculate_drift(self, input_data: dict[str, Any]) -> dict[Hashable, Any]:
|
||||
async def calculate_drift(self, input_data: dict[str, Any]) -> DataFrame | dict:
|
||||
"""
|
||||
Calculate drift metrics for a model.
|
||||
|
||||
@@ -262,9 +262,9 @@ class ModelMetrics(SientiaMonitoring):
|
||||
self.debug(f'Drift dataframe: Size {drift_df.shape} \n{drift_df.head(5).to_string()}', metadata)
|
||||
|
||||
|
||||
return drift_df.to_dict()
|
||||
return drift_df
|
||||
|
||||
async def calculate_simple_metrics(self, input_data: dict[str, Any]) -> dict[Hashable, Any]:
|
||||
async def calculate_simple_metrics(self, input_data: dict[str, Any]) -> DataFrame:
|
||||
"""
|
||||
Calculate simple metrics for a model. Metrics available are:
|
||||
- rmse
|
||||
@@ -342,6 +342,6 @@ class ModelMetrics(SientiaMonitoring):
|
||||
|
||||
self.debug(f'Simple metrics dataframe: Size {data.shape} \n{data.head(5).to_string()}', metadata)
|
||||
|
||||
return data.to_dict()
|
||||
return data
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user