Skip to content

Commit e32ab59

Browse files
authored
Merge pull request #182 from sassoftware/score-code-update
Score code update branch merge
2 parents a010b45 + bb40fa0 commit e32ab59

File tree

7 files changed

+2331
-236
lines changed

7 files changed

+2331
-236
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ Unreleased
55
- Add `model_info` class to better capture model information.
66
- Test `/examples` Jupyter notebooks within normal test suite.
77

8+
v1.10.1 (2023-08-24)
9+
----------
10+
**Improvements**
11+
- Introduced ability to specify the target index of a binary model when creating score code.
12+
- index can be specified in `pzmm.import_model.ImportModel.import_model()`
13+
- Relevant examples updated to include target_index.
14+
15+
**Bugfixes**
16+
- Reworked `write_score_code.py` to allow for proper execution of single line scoring.
17+
- Added template files for `assess_model_bias.py` to allow for proper execution
18+
819
v1.10 (2023-08-31)
920
----------
1021
**Improvements**

examples/pzmm_binary_classification_model_import.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,8 @@
814814
" predict_method=[dtc.predict_proba, [int, int]], # What is the predict method and what does it return?\n",
815815
" score_metrics=score_metrics, # What are the output variables?\n",
816816
" overwrite_model=True, # Overwrite the model if it already exists?\n",
817-
" target_values=[\"1\", \"0\"], # What are the expected values of the target variable?\n",
817+
" target_values=[\"0\", \"1\"], # What are the expected values of the target variable?\n",
818+
" target_index=1, # What is the index of the target value in target_values?\n",
818819
" model_file_name=prefix + \".pickle\", # How was the model file serialized?\n",
819820
" missing_values=True # Does the data include missing values?\n",
820821
" )\n",

examples/pzmm_h2o_model_import.ipynb

Lines changed: 2096 additions & 64 deletions
Large diffs are not rendered by default.

examples/pzmm_tensorflow_keras_model_import.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@
753753
" input_data=x, # What does example input data look like?\n",
754754
" predict_method=[model.predict, [int, int]], # What is the predict method and what does it return?\n",
755755
" overwrite_model=True, # Overwrite model if it arleady exists\n",
756-
" target_values=[\"1\", \"0\"], # What are the expecte values of the target variable?\n",
756+
" target_values=[\"0\", \"1\"], # What are the expecte values of the target variable?\n",
757757
" score_metrics=score_metrics, # What are the output variables?\n",
758758
" model_file_name = model_prefix + \".h5\", # How was the model file serialized?\n",
759759
" missing_values = True, # Does the data include missing values?\n",

src/sasctl/pzmm/import_model.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ def import_model(
198198
predict_threshold: Optional[float] = None,
199199
target_values: Optional[List[str]] = None,
200200
overwrite_project_properties: Optional[bool] = False,
201+
target_index: Optional[int] = None,
201202
**kwargs,
202203
) -> Tuple[RestObj, Union[dict, str, Path]]:
203204
"""
@@ -275,10 +276,16 @@ def import_model(
275276
target_values : list of strings, optional
276277
A list of target values for the target variable. This argument and the
277278
score_metrics argument dictate the handling of the predicted values from
278-
the prediction method. The default value is None.
279+
the prediction method. The order of the target values should reflect the
280+
order of the related probabilities in the model. The default value is None.
279281
overwrite_project_properties : bool, optional
280282
Set whether the project properties should be overwritten when attempting to
281283
import the model. The default value is False.
284+
target_index : int, optional
285+
Sets the index of success for a binary model. If target_values are given, this
286+
index should match the index of the target outcome in target_values. If target_values
287+
are not given, this index should indicate whether the the target probability variable
288+
is the first or second variable returned by the model. The default value is 1.
282289
kwargs : dict, optional
283290
Other keyword arguments are passed to the following function:
284291
* sasctl.pzmm.ScoreCode.write_score_code(...,
@@ -352,6 +359,7 @@ def import_model(
352359
target_values=target_values,
353360
missing_values=missing_values,
354361
score_cas=score_cas,
362+
target_index=target_index,
355363
**kwargs,
356364
)
357365
if score_code_dict:
@@ -451,6 +459,7 @@ def import_model(
451459
target_values=target_values,
452460
missing_values=missing_values,
453461
score_cas=score_cas,
462+
target_index=target_index,
454463
**kwargs,
455464
)
456465
if score_code_dict:

0 commit comments

Comments
 (0)