SIENTIAPDE-1273
Enhance prediction data retrieval in MLFlowRepository by adding predict_flavor parameter - Updated get_prediction_data method to accept a predict_flavor argument, allowing for different prediction model handling. - Adjusted calls to get_prediction_data throughout the codebase to include the new parameter. - Added new test cases to validate behavior for different predict_flavor values, ensuring robust functionality.
This commit is contained in:
@@ -705,14 +705,17 @@ class MLFlowRepository(SientiaMonitoring):
|
||||
"""
|
||||
|
||||
def get_prediction_data(
|
||||
self, prediction_model: Any, retrain_dataset: pd.DataFrame, target_name: str
|
||||
self, prediction_model: Any, retrain_dataset: pd.DataFrame, target_name: str, predict_flavor: str
|
||||
) -> pd.DataFrame:
|
||||
"""
|
||||
Get prediction data from prediction model.
|
||||
"""
|
||||
input_index = retrain_dataset.index
|
||||
|
||||
prediction_data = prediction_model.predict(retrain_dataset)
|
||||
if predict_flavor == 'pyfunc':
|
||||
prediction_data = prediction_model.predict({}, retrain_dataset)
|
||||
else:
|
||||
prediction_data = prediction_model.predict(retrain_dataset)
|
||||
|
||||
if isinstance(prediction_data, pd.DataFrame):
|
||||
prediction_data.columns = pd.Index(['prediction'])
|
||||
@@ -858,7 +861,7 @@ class MLFlowRepository(SientiaMonitoring):
|
||||
prediction_model.fit(retrain_dataset)
|
||||
|
||||
# get prediction data
|
||||
prediction_data = self.get_prediction_data(prediction_model, retrain_dataset, target_name)
|
||||
prediction_data = self.get_prediction_data(prediction_model, retrain_dataset, target_name, predict_flavor)
|
||||
|
||||
self.info(f'Model experiment creation completed successfully for {model_name}', metadata)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user