|
21 | 21 | },
|
22 | 22 | {
|
23 | 23 | "cell_type": "code",
|
24 |
| - "execution_count": 1, |
| 24 | + "execution_count": null, |
25 | 25 | "metadata": {},
|
26 | 26 | "outputs": [],
|
27 | 27 | "source": [
|
|
48 | 48 | "metadata": {},
|
49 | 49 | "source": [
|
50 | 50 | "### Setup\n",
|
51 |
| - "This example is built to be run after the [PZMM Binary Classification Model Import](/pzmm_binary_classification_model_import.ipynb) example notebook is run." |
| 51 | + "This example is built to be run after the [PZMM Binary Classification Model Import](./pzmm_binary_classification_model_import.ipynb) example notebook is run." |
52 | 52 | ]
|
53 | 53 | },
|
54 | 54 | {
|
55 | 55 | "cell_type": "code",
|
56 |
| - "execution_count": 2, |
| 56 | + "execution_count": null, |
57 | 57 | "metadata": {},
|
58 | 58 | "outputs": [],
|
59 | 59 | "source": [
|
|
73 | 73 | },
|
74 | 74 | {
|
75 | 75 | "cell_type": "code",
|
76 |
| - "execution_count": 3, |
| 76 | + "execution_count": null, |
77 | 77 | "metadata": {},
|
78 | 78 | "outputs": [],
|
79 | 79 | "source": [
|
|
95 | 95 | },
|
96 | 96 | {
|
97 | 97 | "cell_type": "code",
|
98 |
| - "execution_count": 4, |
| 98 | + "execution_count": null, |
99 | 99 | "metadata": {},
|
100 | 100 | "outputs": [],
|
101 | 101 | "source": [
|
|
124 | 124 | },
|
125 | 125 | {
|
126 | 126 | "cell_type": "code",
|
127 |
| - "execution_count": 5, |
| 127 | + "execution_count": null, |
128 | 128 | "metadata": {},
|
129 | 129 | "outputs": [],
|
130 | 130 | "source": [
|
|
146 | 146 | },
|
147 | 147 | {
|
148 | 148 | "cell_type": "code",
|
149 |
| - "execution_count": 6, |
| 149 | + "execution_count": null, |
150 | 150 | "metadata": {},
|
151 | 151 | "outputs": [],
|
152 | 152 | "source": [
|
|
165 | 165 | },
|
166 | 166 | {
|
167 | 167 | "cell_type": "code",
|
168 |
| - "execution_count": 7, |
| 168 | + "execution_count": null, |
169 | 169 | "metadata": {},
|
170 |
| - "outputs": [ |
171 |
| - { |
172 |
| - "name": "stdout", |
173 |
| - "output_type": "stream", |
174 |
| - "text": [ |
175 |
| - "1\n", |
176 |
| - "2\n", |
177 |
| - "3\n", |
178 |
| - "4\n" |
179 |
| - ] |
180 |
| - } |
181 |
| - ], |
| 170 | + "outputs": [], |
182 | 171 | "source": [
|
183 | 172 | "from sasctl._services.cas_management import CASManagement as cas\n",
|
184 | 173 | "\n",
|
|
198 | 187 | },
|
199 | 188 | {
|
200 | 189 | "cell_type": "code",
|
201 |
| - "execution_count": 8, |
| 190 | + "execution_count": null, |
202 | 191 | "metadata": {},
|
203 | 192 | "outputs": [],
|
204 | 193 | "source": [
|
|
209 | 198 | },
|
210 | 199 | {
|
211 | 200 | "cell_type": "code",
|
212 |
| - "execution_count": 9, |
| 201 | + "execution_count": null, |
213 | 202 | "metadata": {},
|
214 | 203 | "outputs": [],
|
215 | 204 | "source": [
|
|
222 | 211 | "cell_type": "markdown",
|
223 | 212 | "metadata": {},
|
224 | 213 | "source": [
|
225 |
| - "Once the performance defintion is run, it is possible to update the hyperparameter json file to include the KPIs that have been generated. This is not a necessary step, but could be helpful when analyzing which hyperparameters lead to better KPIs." |
| 214 | + "Once the performance definition is run, it is possible to update the hyperparameter json file to include the KPIs that have been generated. This is not a necessary step, but could be helpful when analyzing which hyperparameters lead to better KPIs. Note that you need the performance jobs to have created the MM_STD performance table before running the `update_kpis()` method below." |
226 | 215 | ]
|
227 | 216 | },
|
228 | 217 | {
|
229 | 218 | "cell_type": "code",
|
230 |
| - "execution_count": 10, |
231 |
| - "metadata": {}, |
232 |
| - "outputs": [ |
233 |
| - { |
234 |
| - "name": "stderr", |
235 |
| - "output_type": "stream", |
236 |
| - "text": [ |
237 |
| - "~\\sasctl\\pzmm\\model_parameters.py:251: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.\n", |
238 |
| - " if pd.__version__ >= StrictVersion(\"1.0.3\"):\n" |
239 |
| - ] |
240 |
| - }, |
241 |
| - { |
242 |
| - "name": "stdout", |
243 |
| - "output_type": "stream", |
244 |
| - "text": [ |
245 |
| - "No hyperparameter file for current model GradientBoosting. Attempting for next model...\n", |
246 |
| - "No hyperparameter file for current model RandomForest. Attempting for next model...\n" |
247 |
| - ] |
248 |
| - } |
| 219 | + "execution_count": null, |
| 220 | + "outputs": [], |
| 221 | + "source": [ |
| 222 | + "check_perf_job = mm.get(f\"/performanceTasks/{perf_job[0].taskId}/performanceJobs\")\n", |
| 223 | + "for j in check_perf_job:\n", |
| 224 | + " print(f\"{j.model}: {j.state}\")" |
249 | 225 | ],
|
| 226 | + "metadata": { |
| 227 | + "collapsed": false |
| 228 | + } |
| 229 | + }, |
| 230 | + { |
| 231 | + "cell_type": "code", |
| 232 | + "execution_count": null, |
| 233 | + "metadata": {}, |
| 234 | + "outputs": [], |
250 | 235 | "source": [
|
251 | 236 | "mp.update_kpis(\"HMEQModels\")"
|
252 | 237 | ]
|
|
261 | 246 | },
|
262 | 247 | {
|
263 | 248 | "cell_type": "code",
|
264 |
| - "execution_count": 11, |
| 249 | + "execution_count": null, |
265 | 250 | "metadata": {},
|
266 |
| - "outputs": [ |
267 |
| - { |
268 |
| - "name": "stdout", |
269 |
| - "output_type": "stream", |
270 |
| - "text": [ |
271 |
| - "[0.47701149425287354, 0.304921968787515, 0.24622641509433962, 0.21799561082662766]\n", |
272 |
| - "Uploading custom kpis to SAS Viya...\n" |
273 |
| - ] |
274 |
| - }, |
275 |
| - { |
276 |
| - "data": { |
277 |
| - "text/plain": [ |
278 |
| - "[<class 'sasctl.core.RestObj'>(headers={}, data={'name': 'TimeSK', 'value': '4', 'systemKPIFlag': True}), <class 'sasctl.core.RestObj'>(headers={}, data={'name': 'TimeLabel', 'value': 'Q4', 'systemKPIFlag': True}), <class 'sasctl.core.RestObj'>(headers={}, data={'name': 'ProjectUUID', 'value': '7a6dfcc7-8356-4809-92d2-1725569cdab1', 'systemKPIFlag': True}), <class 'sasctl.core.RestObj'>(headers={}, data={'name': 'ModelName', 'value': 'DecisionTreeClassifier', 'systemKPIFlag': True}), <class 'sasctl.core.RestObj'>(headers={}, data={'name': 'ModelUUID', 'value': '4ff0e60b-4177-487c-b1ca-d78ac4812be4', 'systemKPIFlag': True}), <class 'sasctl.core.RestObj'>(headers={}, data={'name': 'ModelFlag', 'value': '-1', 'systemKPIFlag': True}), <class 'sasctl.core.RestObj'>(headers={}, data={'name': '_AUC_', 'value': '0.4123305448', 'systemKPIFlag': True}), <class 'sasctl.core.RestObj'>(headers={}, data={'name': '_F1_', 'value': '0.344488189', 'systemKPIFlag': True}), <class 'sasctl.core.RestObj'>(headers={}, data={'name': '_TPR_', 'value': '1', 'systemKPIFlag': True}), <class 'sasctl.core.RestObj'>(headers={}, data={'name': '_FPR_', 'value': '1', 'systemKPIFlag': True}), <class 'sasctl.core.RestObj'>(headers={}, data={'name': '_MISC_', 'value': '0.6822235434', 'systemKPIFlag': True}), <class 'sasctl.core.RestObj'>(headers={}, data={'name': '_ASE_', 'value': '0.6822235434', 'systemKPIFlag': True}), <class 'sasctl.core.RestObj'>(headers={}, data={'name': '_Cumlift5_', 'value': '0.8091228488', 'systemKPIFlag': True}), <class 'sasctl.core.RestObj'>(headers={}, data={'name': '_Cumlift10_', 'value': '0.8091228488', 'systemKPIFlag': True}), <class 'sasctl.core.RestObj'>(headers={}, data={'name': '_Cumlift15_', 'value': '0.8091228488', 'systemKPIFlag': True}), <class 'sasctl.core.RestObj'>(headers={}, data={'name': '_Cumlift20_', 'value': '0.8091228488', 'systemKPIFlag': True}), <class 'sasctl.core.RestObj'>(headers={}, data={'name': '_Cumlift30_', 'value': '0.8091228488', 'systemKPIFlag': True}), <class 'sasctl.core.RestObj'>(headers={}, data={'name': '_RSquared_', 'value': 'null', 'systemKPIFlag': True}), <class 'sasctl.core.RestObj'>(headers={}, data={'name': 'Datetime', 'value': '03Apr2023:19:05:34', 'systemKPIFlag': True}), <class 'sasctl.core.RestObj'>(headers={}, data={'name': '_MICRO_AVG_F1_', 'value': 'null', 'systemKPIFlag': False}), <class 'sasctl.core.RestObj'>(headers={}, data={'name': '_MACRO_AVG_F1_', 'value': 'null', 'systemKPIFlag': False}), <class 'sasctl.core.RestObj'>(headers={}, data={'name': '_WEIGHTED_AVG_F1_', 'value': 'null', 'systemKPIFlag': False}), <class 'sasctl.core.RestObj'>(headers={}, data={'name': '_GLOBAL_ACCURACY_', 'value': 'null', 'systemKPIFlag': False}), <class 'sasctl.core.RestObj'>(headers={}, data={'name': 'jaccard', 'value': '0.2179956108', 'systemKPIFlag': False})]" |
279 |
| - ] |
280 |
| - }, |
281 |
| - "execution_count": 11, |
282 |
| - "metadata": {}, |
283 |
| - "output_type": "execute_result" |
284 |
| - } |
285 |
| - ], |
| 251 | + "outputs": [], |
286 | 252 | "source": [
|
287 | 253 | "from sklearn.metrics import jaccard_score\n",
|
288 | 254 | "\n",
|
|
306 | 272 | "\n",
|
307 | 273 | "print(jaccard_list)\n",
|
308 | 274 | "\n",
|
309 |
| - "#TODO: allow option to add multiple of same custom KPI\n", |
310 | 275 | "model = mr.get_model(model_name)\n",
|
311 | 276 | "mm.create_custom_kpi(\n",
|
312 | 277 | " model=model.id,\n",
|
|
327 | 292 | },
|
328 | 293 | {
|
329 | 294 | "cell_type": "code",
|
330 |
| - "execution_count": 12, |
| 295 | + "execution_count": null, |
331 | 296 | "metadata": {},
|
332 |
| - "outputs": [ |
333 |
| - { |
334 |
| - "name": "stderr", |
335 |
| - "output_type": "stream", |
336 |
| - "text": [ |
337 |
| - "~\\sasctl\\pzmm\\model_parameters.py:251: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.\n", |
338 |
| - " if pd.__version__ >= StrictVersion(\"1.0.3\"):\n" |
339 |
| - ] |
340 |
| - }, |
341 |
| - { |
342 |
| - "name": "stdout", |
343 |
| - "output_type": "stream", |
344 |
| - "text": [ |
345 |
| - "No hyperparameter file for current model GradientBoosting. Attempting for next model...\n", |
346 |
| - "No hyperparameter file for current model RandomForest. Attempting for next model...\n", |
347 |
| - "[\n", |
348 |
| - " {\n", |
349 |
| - " \"hyperparameters\": {\n", |
350 |
| - " \"ccp_alpha\": 0.0,\n", |
351 |
| - " \"class_weight\": null,\n", |
352 |
| - " \"criterion\": \"gini\",\n", |
353 |
| - " \"max_depth\": null,\n", |
354 |
| - " \"max_features\": null,\n", |
355 |
| - " \"max_leaf_nodes\": null,\n", |
356 |
| - " \"min_impurity_decrease\": 0.0,\n", |
357 |
| - " \"min_impurity_split\": null,\n", |
358 |
| - " \"min_samples_leaf\": 1,\n", |
359 |
| - " \"min_samples_split\": 2,\n", |
360 |
| - " \"min_weight_fraction_leaf\": 0.0,\n", |
361 |
| - " \"presort\": \"deprecated\",\n", |
362 |
| - " \"random_state\": 42,\n", |
363 |
| - " \"splitter\": \"best\",\n", |
364 |
| - " \"example\": 1\n", |
365 |
| - " },\n", |
366 |
| - " \"kpis\": {\n", |
367 |
| - " \"Q1\": {\n", |
368 |
| - " \"TimeSK\": \"1\",\n", |
369 |
| - " \"ProjectUUID\": \"7a6dfcc7-8356-4809-92d2-1725569cdab1\",\n", |
370 |
| - " \"ModelName\": \"DecisionTreeClassifier\",\n", |
371 |
| - " \"ModelFlag\": \"-1\",\n", |
372 |
| - " \"_AUC_\": \"0.1803248068\",\n", |
373 |
| - " \"_F1_\": \"0.1928552243\",\n", |
374 |
| - " \"_TPR_\": \"1\",\n", |
375 |
| - " \"_FPR_\": \"1\",\n", |
376 |
| - " \"_MISC_\": \"0.9188466112\",\n", |
377 |
| - " \"_ASE_\": \"0.9188466112\",\n", |
378 |
| - " \"_Cumlift5_\": \"0.3508315027\",\n", |
379 |
| - " \"_Cumlift10_\": \"0.3508315027\",\n", |
380 |
| - " \"_Cumlift15_\": \"0.3508315027\",\n", |
381 |
| - " \"_Cumlift20_\": \"0.3508315027\",\n", |
382 |
| - " \"_Cumlift30_\": \"0.3508315027\",\n", |
383 |
| - " \"_RSquared_\": null,\n", |
384 |
| - " \"Datetime\": \"03Apr2023:19:05:34\",\n", |
385 |
| - " \"_MICRO_AVG_F1_\": null,\n", |
386 |
| - " \"_MACRO_AVG_F1_\": null,\n", |
387 |
| - " \"_WEIGHTED_AVG_F1_\": null,\n", |
388 |
| - " \"_GLOBAL_ACCURACY_\": null,\n", |
389 |
| - " \"jaccard\": \"0.4770114943\"\n", |
390 |
| - " },\n", |
391 |
| - " \"Q2\": {\n", |
392 |
| - " \"TimeSK\": \"2\",\n", |
393 |
| - " \"ProjectUUID\": \"7a6dfcc7-8356-4809-92d2-1725569cdab1\",\n", |
394 |
| - " \"ModelName\": \"DecisionTreeClassifier\",\n", |
395 |
| - " \"ModelFlag\": \"-1\",\n", |
396 |
| - " \"_AUC_\": \"0.2989680477\",\n", |
397 |
| - " \"_F1_\": \"0.2524675325\",\n", |
398 |
| - " \"_TPR_\": \"1\",\n", |
399 |
| - " \"_FPR_\": \"1\",\n", |
400 |
| - " \"_MISC_\": \"0.8278834721\",\n", |
401 |
| - " \"_ASE_\": \"0.8278834721\",\n", |
402 |
| - " \"_Cumlift5_\": \"0.5839659582\",\n", |
403 |
| - " \"_Cumlift10_\": \"0.5839659582\",\n", |
404 |
| - " \"_Cumlift15_\": \"0.5839659582\",\n", |
405 |
| - " \"_Cumlift20_\": \"0.5839659582\",\n", |
406 |
| - " \"_Cumlift30_\": \"0.5839659582\",\n", |
407 |
| - " \"_RSquared_\": null,\n", |
408 |
| - " \"Datetime\": \"03Apr2023:19:05:34\",\n", |
409 |
| - " \"_MICRO_AVG_F1_\": null,\n", |
410 |
| - " \"_MACRO_AVG_F1_\": null,\n", |
411 |
| - " \"_WEIGHTED_AVG_F1_\": null,\n", |
412 |
| - " \"_GLOBAL_ACCURACY_\": null,\n", |
413 |
| - " \"jaccard\": \"0.3049219688\"\n", |
414 |
| - " },\n", |
415 |
| - " \"Q3\": {\n", |
416 |
| - " \"TimeSK\": \"3\",\n", |
417 |
| - " \"ProjectUUID\": \"7a6dfcc7-8356-4809-92d2-1725569cdab1\",\n", |
418 |
| - " \"ModelName\": \"DecisionTreeClassifier\",\n", |
419 |
| - " \"ModelFlag\": \"-1\",\n", |
420 |
| - " \"_AUC_\": \"0.3563914522\",\n", |
421 |
| - " \"_F1_\": \"0.2858598726\",\n", |
422 |
| - " \"_TPR_\": \"1\",\n", |
423 |
| - " \"_FPR_\": \"1\",\n", |
424 |
| - " \"_MISC_\": \"0.7624851367\",\n", |
425 |
| - " \"_ASE_\": \"0.7624851367\",\n", |
426 |
| - " \"_Cumlift5_\": \"0.6941192899\",\n", |
427 |
| - " \"_Cumlift10_\": \"0.6941192899\",\n", |
428 |
| - " \"_Cumlift15_\": \"0.6941192899\",\n", |
429 |
| - " \"_Cumlift20_\": \"0.6941192899\",\n", |
430 |
| - " \"_Cumlift30_\": \"0.6941192899\",\n", |
431 |
| - " \"_RSquared_\": null,\n", |
432 |
| - " \"Datetime\": \"03Apr2023:19:05:34\",\n", |
433 |
| - " \"_MICRO_AVG_F1_\": null,\n", |
434 |
| - " \"_MACRO_AVG_F1_\": null,\n", |
435 |
| - " \"_WEIGHTED_AVG_F1_\": null,\n", |
436 |
| - " \"_GLOBAL_ACCURACY_\": null,\n", |
437 |
| - " \"jaccard\": \"0.2462264151\"\n", |
438 |
| - " },\n", |
439 |
| - " \"Q4\": {\n", |
440 |
| - " \"TimeSK\": \"4\",\n", |
441 |
| - " \"ProjectUUID\": \"7a6dfcc7-8356-4809-92d2-1725569cdab1\",\n", |
442 |
| - " \"ModelName\": \"DecisionTreeClassifier\",\n", |
443 |
| - " \"ModelFlag\": \"-1\",\n", |
444 |
| - " \"_AUC_\": \"0.4123305448\",\n", |
445 |
| - " \"_F1_\": \"0.344488189\",\n", |
446 |
| - " \"_TPR_\": \"1\",\n", |
447 |
| - " \"_FPR_\": \"1\",\n", |
448 |
| - " \"_MISC_\": \"0.6822235434\",\n", |
449 |
| - " \"_ASE_\": \"0.6822235434\",\n", |
450 |
| - " \"_Cumlift5_\": \"0.8091228488\",\n", |
451 |
| - " \"_Cumlift10_\": \"0.8091228488\",\n", |
452 |
| - " \"_Cumlift15_\": \"0.8091228488\",\n", |
453 |
| - " \"_Cumlift20_\": \"0.8091228488\",\n", |
454 |
| - " \"_Cumlift30_\": \"0.8091228488\",\n", |
455 |
| - " \"_RSquared_\": null,\n", |
456 |
| - " \"Datetime\": \"03Apr2023:19:05:34\",\n", |
457 |
| - " \"_MICRO_AVG_F1_\": null,\n", |
458 |
| - " \"_MACRO_AVG_F1_\": null,\n", |
459 |
| - " \"_WEIGHTED_AVG_F1_\": null,\n", |
460 |
| - " \"_GLOBAL_ACCURACY_\": null,\n", |
461 |
| - " \"jaccard\": \"0.2179956108\"\n", |
462 |
| - " }\n", |
463 |
| - " }\n", |
464 |
| - " },\n", |
465 |
| - " \"DecisionTreeClassifierHyperparameters.json\"\n", |
466 |
| - "]\n" |
467 |
| - ] |
468 |
| - } |
469 |
| - ], |
| 297 | + "outputs": [], |
470 | 298 | "source": [
|
471 | 299 | "import json\n",
|
472 | 300 | "\n",
|
|
476 | 304 | "\n",
|
477 | 305 | "print(json.dumps(hyperparameters, indent=4))"
|
478 | 306 | ]
|
479 |
| - }, |
480 |
| - { |
481 |
| - "cell_type": "code", |
482 |
| - "execution_count": null, |
483 |
| - "metadata": {}, |
484 |
| - "outputs": [], |
485 |
| - "source": [] |
486 | 307 | }
|
487 | 308 | ],
|
488 | 309 | "metadata": {
|
|
0 commit comments