Skip to content

Commit

Permalink
Update pzmm_binary_classification_model_import notebook to include mo…
Browse files Browse the repository at this point in the history
…del card generation
  • Loading branch information
djm21 committed Mar 26, 2024
1 parent fc85adc commit 7b14935
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions examples/pzmm_binary_classification_model_import.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@
],
"source": [
"import getpass\n",
"def write_model_stats(x_train, y_train, test_predict, test_proba, y_test, model, path):\n",
"def write_model_stats(x_train, y_train, test_predict, test_proba, y_test, model, path, prefix):\n",
" # Calculate train predictions\n",
" train_predict = model.predict(x_train)\n",
" train_proba = model.predict_proba(x_train)\n",
Expand All @@ -757,6 +757,20 @@
" test_data=test_data, \n",
" json_path=path\n",
" )\n",
"\n",
" full_training_data = pd.concat([y_train.reset_index(drop=True), x_train.reset_index(drop=True)], axis=1)\n",
"\n",
" pzmm.JSONFiles.generate_model_card(\n",
" model_prefix=prefix,\n",
" model_files = path,\n",
" algorithm = str(type(model).__name__),\n",
" train_data = full_training_data,\n",
" train_predictions=train_predict,\n",
" target_type='classification',\n",
" target_value=1,\n",
" interval_vars=predictor_columns,\n",
" selection_statistic='_RASE_',\n",
" )\n",
" \n",
"username = getpass.getpass()\n",
"password = getpass.getpass()\n",
Expand All @@ -766,8 +780,8 @@
"\n",
"test_predict = [y_dtc_predict, y_rfc_predict, y_gbc_predict]\n",
"test_proba = [y_dtc_proba, y_rfc_proba, y_gbc_proba]\n",
"for (mod, pred, proba, path) in zip(model, test_predict, test_proba, zip_folder):\n",
" write_model_stats(x_train, y_train, pred, proba, y_test, mod, path)"
"for (mod, pred, proba, path, prefix) in zip(model, test_predict, test_proba, zip_folder, model_prefix):\n",
" write_model_stats(x_train, y_train, pred, proba, y_test, mod, path, prefix)"
]
},
{
Expand Down

0 comments on commit 7b14935

Please sign in to comment.