Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Score code update branch merge #182

Merged
merged 7 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ Unreleased
- Add `model_info` class to better capture model information.
- Test `/examples` Jupyter notebooks within normal test suite.

v1.10.1 (2023-08-24)
----------
**Improvements**
- Introduced ability to specify the target index of a binary model when creating score code.
- index can be specified in `pzmm.import_model.ImportModel.import_model()`
- Relevant examples updated to include target_index.

**Bugfixes**
- Reworked `write_score_code.py` to allow for proper execution of single line scoring.
- Added template files for `assess_model_bias.py` to allow for proper execution

v1.10 (2023-08-31)
----------
**Improvements**
Expand Down
3 changes: 2 additions & 1 deletion examples/pzmm_binary_classification_model_import.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,8 @@
" predict_method=[dtc.predict_proba, [int, int]], # What is the predict method and what does it return?\n",
" score_metrics=score_metrics, # What are the output variables?\n",
" overwrite_model=True, # Overwrite the model if it already exists?\n",
" target_values=[\"1\", \"0\"], # What are the expected values of the target variable?\n",
" target_values=[\"0\", \"1\"], # What are the expected values of the target variable?\n",
" target_index=1, # What is the index of the target value in target_values?\n",
" model_file_name=prefix + \".pickle\", # How was the model file serialized?\n",
" missing_values=True # Does the data include missing values?\n",
" )\n",
Expand Down
2,160 changes: 2,096 additions & 64 deletions examples/pzmm_h2o_model_import.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/pzmm_tensorflow_keras_model_import.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@
" input_data=x, # What does example input data look like?\n",
" predict_method=[model.predict, [int, int]], # What is the predict method and what does it return?\n",
" overwrite_model=True, # Overwrite model if it arleady exists\n",
" target_values=[\"1\", \"0\"], # What are the expecte values of the target variable?\n",
" target_values=[\"0\", \"1\"], # What are the expecte values of the target variable?\n",
" score_metrics=score_metrics, # What are the output variables?\n",
" model_file_name = model_prefix + \".h5\", # How was the model file serialized?\n",
" missing_values = True, # Does the data include missing values?\n",
Expand Down
11 changes: 10 additions & 1 deletion src/sasctl/pzmm/import_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ def import_model(
predict_threshold: Optional[float] = None,
target_values: Optional[List[str]] = None,
overwrite_project_properties: Optional[bool] = False,
target_index: Optional[int] = None,
**kwargs,
) -> Tuple[RestObj, Union[dict, str, Path]]:
"""
Expand Down Expand Up @@ -275,10 +276,16 @@ def import_model(
target_values : list of strings, optional
A list of target values for the target variable. This argument and the
score_metrics argument dictate the handling of the predicted values from
the prediction method. The default value is None.
the prediction method. The order of the target values should reflect the
order of the related probabilities in the model. The default value is None.
overwrite_project_properties : bool, optional
Set whether the project properties should be overwritten when attempting to
import the model. The default value is False.
target_index : int, optional
Sets the index of success for a binary model. If target_values are given, this
index should match the index of the target outcome in target_values. If target_values
are not given, this index should indicate whether the the target probability variable
is the first or second variable returned by the model. The default value is 1.
kwargs : dict, optional
Other keyword arguments are passed to the following function:
* sasctl.pzmm.ScoreCode.write_score_code(...,
Expand Down Expand Up @@ -352,6 +359,7 @@ def import_model(
target_values=target_values,
missing_values=missing_values,
score_cas=score_cas,
target_index=target_index,
**kwargs,
)
if score_code_dict:
Expand Down Expand Up @@ -451,6 +459,7 @@ def import_model(
target_values=target_values,
missing_values=missing_values,
score_cas=score_cas,
target_index=target_index,
**kwargs,
)
if score_code_dict:
Expand Down
Loading