|
24 | 24 | "" |
25 | 25 | ] |
26 | 26 | }, |
| 27 | + { |
| 28 | + "cell_type": "code", |
| 29 | + "execution_count": null, |
| 30 | + "id": "28f2ff57", |
| 31 | + "metadata": {}, |
| 32 | + "outputs": [], |
| 33 | + "source": [ |
| 34 | + "!pip install tqdm" |
| 35 | + ] |
| 36 | + }, |
27 | 37 | { |
28 | 38 | "cell_type": "code", |
29 | 39 | "execution_count": 1, |
|
81 | 91 | "project_name = \"banking-agent\"\n", |
82 | 92 | "project = mlrun.get_or_create_project(\n", |
83 | 93 | " project_name,\n", |
84 | | - " user_project=False,\n", |
| 94 | + " user_project=True,\n", |
85 | 95 | " parameters={\n", |
86 | 96 | " \"build_image\": True, # Disable after running once\n", |
87 | 97 | " },\n", |
|
128 | 138 | }, |
129 | 139 | { |
130 | 140 | "cell_type": "code", |
131 | | - "execution_count": 15, |
| 141 | + "execution_count": null, |
132 | 142 | "id": "4e7060b9-3848-4753-99d8-8c16d3fb2ef3", |
133 | 143 | "metadata": {}, |
134 | 144 | "outputs": [], |
135 | 145 | "source": [ |
136 | | - "from src.model_monitoring_utils import enable_model_monitoring" |
137 | | - ] |
138 | | - }, |
139 | | - { |
140 | | - "cell_type": "code", |
141 | | - "execution_count": 16, |
142 | | - "id": "8516c667-9315-43cd-89a8-1def199ffbcb", |
143 | | - "metadata": {}, |
144 | | - "outputs": [ |
145 | | - { |
146 | | - "name": "stdout", |
147 | | - "output_type": "stream", |
148 | | - "text": [ |
149 | | - "> 2025-09-03 01:17:23,159 [info] Model monitoring credentials were set successfully. Please keep in mind that if you already had model monitoring functions / model monitoring infra / tracked model server deployed on your project, you will need to redeploy them. For redeploying the model monitoring infra, first disable it using `project.disable_model_monitoring()` and then enable it using `project.enable_model_monitoring()`.\n" |
150 | | - ] |
151 | | - }, |
152 | | - { |
153 | | - "data": { |
154 | | - "text/plain": [ |
155 | | - "<mlrun.projects.project.MlrunProject at 0x7feb19efac10>" |
156 | | - ] |
157 | | - }, |
158 | | - "execution_count": 16, |
159 | | - "metadata": {}, |
160 | | - "output_type": "execute_result" |
161 | | - } |
162 | | - ], |
163 | | - "source": [ |
| 146 | + "from src.model_monitoring_utils import enable_model_monitoring\n", |
| 147 | + "\n", |
164 | 148 | "# Enable model monitoring\n", |
165 | 149 | "enable_model_monitoring(project=project, base_period=10, wait_for_deployment=False)" |
166 | 150 | ] |
|
215 | 199 | }, |
216 | 200 | { |
217 | 201 | "cell_type": "code", |
218 | | - "execution_count": 6, |
| 202 | + "execution_count": null, |
219 | 203 | "id": "3ff4f142-5efd-4913-95c1-11e18b501e91", |
220 | 204 | "metadata": {}, |
221 | 205 | "outputs": [], |
222 | 206 | "source": [ |
223 | | - "from config import MainConfig" |
224 | | - ] |
225 | | - }, |
226 | | - { |
227 | | - "cell_type": "code", |
228 | | - "execution_count": 7, |
229 | | - "id": "de252aef-872f-47ca-b039-d2f8e49a9927", |
230 | | - "metadata": {}, |
231 | | - "outputs": [ |
232 | | - { |
233 | | - "data": { |
234 | | - "text/plain": [ |
235 | | - "{'source_url': 'store://datasets/banking-agent/churn#0@6d4ffd11bfe20eab0ea3cb1cf03e1c3458b0408c^40c43a7cc1d445b90203ac2d2cf0a7abd91f8542',\n", |
236 | | - " 'label_column': 'churn',\n", |
237 | | - " 'allow_validation_failure': True,\n", |
238 | | - " 'test_size': 0.2,\n", |
239 | | - " 'model_name': 'churn_model',\n", |
240 | | - " 'sentiment_model': 'cardiffnlp/twitter-roberta-base-sentiment-latest',\n", |
241 | | - " 'text_column': 'chat_log',\n", |
242 | | - " 'sentiment_column': 'sentiment_label',\n", |
243 | | - " 'ordinal_columns': ['international_plan', 'voice_mail_plan'],\n", |
244 | | - " 'drop_columns': ['area_code', 'chat_log', 'state']}" |
245 | | - ] |
246 | | - }, |
247 | | - "execution_count": 7, |
248 | | - "metadata": {}, |
249 | | - "output_type": "execute_result" |
250 | | - } |
251 | | - ], |
252 | | - "source": [ |
| 207 | + "from config import MainConfig\n", |
| 208 | + "\n", |
253 | 209 | "arguments = MainConfig(source_url=dataset.uri).model_dump()\n", |
254 | 210 | "arguments" |
255 | 211 | ] |
|
993 | 949 | }, |
994 | 950 | { |
995 | 951 | "cell_type": "code", |
996 | | - "execution_count": 16, |
| 952 | + "execution_count": null, |
997 | 953 | "id": "292500a1-7c45-45ac-ae8d-e43153ecb55d", |
998 | 954 | "metadata": {}, |
999 | 955 | "outputs": [], |
1000 | 956 | "source": [ |
1001 | | - "data = test_set.drop(\"churn\", axis=1).to_dict(orient=\"split\")[\"data\"]" |
1002 | | - ] |
1003 | | - }, |
1004 | | - { |
1005 | | - "cell_type": "code", |
1006 | | - "execution_count": 17, |
1007 | | - "id": "db4a8bbf-51c7-44de-ad78-39ec5ea65a0c", |
1008 | | - "metadata": {}, |
1009 | | - "outputs": [ |
1010 | | - { |
1011 | | - "data": { |
1012 | | - "text/plain": [ |
1013 | | - "[0.0,\n", |
1014 | | - " 0.0,\n", |
1015 | | - " 1.0,\n", |
1016 | | - " 117,\n", |
1017 | | - " 0,\n", |
1018 | | - " 181.5,\n", |
1019 | | - " 95,\n", |
1020 | | - " 30.86,\n", |
1021 | | - " 205.1,\n", |
1022 | | - " 88,\n", |
1023 | | - " 17.43,\n", |
1024 | | - " 204.0,\n", |
1025 | | - " 82,\n", |
1026 | | - " 9.18,\n", |
1027 | | - " 14.7,\n", |
1028 | | - " 9,\n", |
1029 | | - " 3.97,\n", |
1030 | | - " 2,\n", |
1031 | | - " 0.693109929561615]" |
1032 | | - ] |
1033 | | - }, |
1034 | | - "execution_count": 17, |
1035 | | - "metadata": {}, |
1036 | | - "output_type": "execute_result" |
1037 | | - } |
1038 | | - ], |
1039 | | - "source": [ |
| 957 | + "data = test_set.drop(\"churn\", axis=1).to_dict(orient=\"split\")[\"data\"]\n", |
1040 | 958 | "data[0]" |
1041 | 959 | ] |
1042 | 960 | }, |
1043 | 961 | { |
1044 | 962 | "cell_type": "code", |
1045 | | - "execution_count": 18, |
1046 | | - "id": "a62905db-0d1a-456d-beae-e371c8e92f04", |
| 963 | + "execution_count": null, |
| 964 | + "id": "f6929864-22e3-49f8-a351-fba39f795271", |
1047 | 965 | "metadata": {}, |
1048 | 966 | "outputs": [], |
1049 | 967 | "source": [ |
1050 | 968 | "from random import choice\n", |
1051 | 969 | "from time import sleep\n", |
1052 | | - "from tqdm import tqdm" |
1053 | | - ] |
1054 | | - }, |
1055 | | - { |
1056 | | - "cell_type": "code", |
1057 | | - "execution_count": null, |
1058 | | - "id": "f6929864-22e3-49f8-a351-fba39f795271", |
1059 | | - "metadata": {}, |
1060 | | - "outputs": [ |
1061 | | - { |
1062 | | - "name": "stderr", |
1063 | | - "output_type": "stream", |
1064 | | - "text": [ |
1065 | | - " 13%|█▎ | 127/1000 [00:13<01:31, 9.57it/s]" |
1066 | | - ] |
1067 | | - } |
1068 | | - ], |
1069 | | - "source": [ |
| 970 | + "from tqdm import tqdm\n", |
| 971 | + "\n", |
1070 | 972 | "for i in tqdm(range(1000)):\n", |
1071 | 973 | " data_point = choice(data)\n", |
1072 | 974 | " resp = serving_fn.invoke(\n", |
|
1101 | 1003 | "Once the churn model is deployed and invoked, you will be able to view the model monitoring results in the MLRun UI:\n", |
1102 | 1004 | "" |
1103 | 1005 | ] |
1104 | | - }, |
1105 | | - { |
1106 | | - "cell_type": "markdown", |
1107 | | - "id": "8bc601cb", |
1108 | | - "metadata": {}, |
1109 | | - "source": [] |
1110 | 1006 | } |
1111 | 1007 | ], |
1112 | 1008 | "metadata": { |
1113 | 1009 | "kernelspec": { |
1114 | | - "display_name": "banking-agent", |
| 1010 | + "display_name": "Pyth(myenv)", |
1115 | 1011 | "language": "python", |
1116 | 1012 | "name": "venv" |
1117 | 1013 | }, |
|
0 commit comments