SIENTIAPDE-1273
Enhance MLFlowRepository and Activities classes with new methods and metrics - Added `check_artifact_exists` method to MLFlowRepository for verifying artifact presence in the MLflow Model Registry. - Implemented `get_prediction_data` method in MLFlowRepository to retrieve prediction data from models. - Updated Activities class to integrate ModelMetrics for improved metrics handling. - Enhanced tests for artifact existence checks and prediction data retrieval, ensuring robust coverage for new functionalities. - Updated various workflows to include `transform_table_name` in input data for better data handling.
This commit is contained in:
101
tests.ipynb
101
tests.ipynb
@@ -487,6 +487,107 @@
|
||||
"except Exception as e:\n",
|
||||
" print(e)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"id": "771ab4ee",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<div>\n",
|
||||
"<style scoped>\n",
|
||||
" .dataframe tbody tr th:only-of-type {\n",
|
||||
" vertical-align: middle;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe tbody tr th {\n",
|
||||
" vertical-align: top;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe thead th {\n",
|
||||
" text-align: right;\n",
|
||||
" }\n",
|
||||
"</style>\n",
|
||||
"<table border=\"1\" class=\"dataframe\">\n",
|
||||
" <thead>\n",
|
||||
" <tr style=\"text-align: right;\">\n",
|
||||
" <th></th>\n",
|
||||
" <th>a</th>\n",
|
||||
" <th>b</th>\n",
|
||||
" <th>target</th>\n",
|
||||
" <th>prediction</th>\n",
|
||||
" <th>timestamp</th>\n",
|
||||
" </tr>\n",
|
||||
" </thead>\n",
|
||||
" <tbody>\n",
|
||||
" <tr>\n",
|
||||
" <th>0</th>\n",
|
||||
" <td>1</td>\n",
|
||||
" <td>4</td>\n",
|
||||
" <td>7</td>\n",
|
||||
" <td>1</td>\n",
|
||||
" <td>2025-01-01</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>1</th>\n",
|
||||
" <td>2</td>\n",
|
||||
" <td>5</td>\n",
|
||||
" <td>8</td>\n",
|
||||
" <td>2</td>\n",
|
||||
" <td>2025-01-02</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>2</th>\n",
|
||||
" <td>3</td>\n",
|
||||
" <td>6</td>\n",
|
||||
" <td>9</td>\n",
|
||||
" <td>3</td>\n",
|
||||
" <td>2025-01-03</td>\n",
|
||||
" </tr>\n",
|
||||
" </tbody>\n",
|
||||
"</table>\n",
|
||||
"</div>"
|
||||
],
|
||||
"text/plain": [
|
||||
" a b target prediction timestamp\n",
|
||||
"0 1 4 7 1 2025-01-01\n",
|
||||
"1 2 5 8 2 2025-01-02\n",
|
||||
"2 3 6 9 3 2025-01-03"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from pandas import DataFrame, merge\n",
|
||||
"\n",
|
||||
"retrain_dataset = DataFrame({\n",
|
||||
" 'a': {'2025-01-01': 1, '2025-01-02': 2, '2025-01-03': 3},\n",
|
||||
" 'b': {'2025-01-01': 4, '2025-01-02': 5, '2025-01-03': 6},\n",
|
||||
" 'c': {'2025-01-01': 7, '2025-01-02': 8, '2025-01-03': 9},\n",
|
||||
"})\n",
|
||||
"\n",
|
||||
"prediction_data = DataFrame({\n",
|
||||
" 'prediction': {'1': 1, '2': 2, '3': 3},\n",
|
||||
"})\n",
|
||||
"\n",
|
||||
"prediction_data.index = retrain_dataset.index\n",
|
||||
"\n",
|
||||
"prediction_data = merge(\n",
|
||||
" retrain_dataset, prediction_data, left_index=True, right_index=True, how='left')\n",
|
||||
"\n",
|
||||
"prediction_data.rename(columns={'c': 'target'}, inplace=True)\n",
|
||||
"\n",
|
||||
"prediction_data['timestamp'] = prediction_data.index\n",
|
||||
"\n",
|
||||
"prediction_data.reset_index(drop=True, inplace=True)\n",
|
||||
"\n",
|
||||
"display(prediction_data)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
||||
Reference in New Issue
Block a user