Skip to content

Commit 1cbbdc0

Browse files
committed
2 parents 2e59904 + ff30240 commit 1cbbdc0

File tree

3 files changed

+24
-22
lines changed

3 files changed

+24
-22
lines changed

examples/pzmm_generate_requirements_json.ipynb

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
},
5858
{
5959
"cell_type": "code",
60-
"execution_count": 2,
60+
"execution_count": null,
6161
"id": "1df8e5d3-c62e-4c35-993c-765a48d25444",
6262
"metadata": {},
6363
"outputs": [],
@@ -86,16 +86,16 @@
8686
"text": [
8787
"[\n",
8888
" {\n",
89-
" \"command\": \"pip install sklearn\",\n",
89+
" \"command\": \"pip install pandas==1.5.3\",\n",
90+
" \"step\": \"install pandas\"\n",
91+
" },\n",
92+
" {\n",
93+
" \"command\": \"pip install sklearn==0.23.1\",\n",
9094
" \"step\": \"install sklearn\"\n",
9195
" },\n",
9296
" {\n",
9397
" \"command\": \"pip install numpy==1.23.5\",\n",
9498
" \"step\": \"install numpy\"\n",
95-
" },\n",
96-
" {\n",
97-
" \"command\": \"pip install pandas==1.5.3\",\n",
98-
" \"step\": \"install pandas\"\n",
9999
" }\n",
100100
"]\n"
101101
]
@@ -118,7 +118,7 @@
118118
},
119119
{
120120
"cell_type": "code",
121-
"execution_count": 4,
121+
"execution_count": 6,
122122
"id": "49721dc9-38e2-4d63-86e1-6555b364f4d6",
123123
"metadata": {},
124124
"outputs": [
@@ -128,27 +128,27 @@
128128
"text": [
129129
"[\n",
130130
" {\n",
131-
" \"command\": \"pip install scikit-learn==1.2.0\",\n",
131+
" \"command\": \"pip install pandas==1.5.3\",\n",
132+
" \"step\": \"install pandas\"\n",
133+
" },\n",
134+
" {\n",
135+
" \"command\": \"pip install scikit-learn==0.23.1\",\n",
132136
" \"step\": \"install scikit-learn\"\n",
133137
" },\n",
134138
" {\n",
135139
" \"command\": \"pip install numpy==1.23.5\",\n",
136140
" \"step\": \"install numpy\"\n",
137-
" },\n",
138-
" {\n",
139-
" \"command\": \"pip install pandas==1.5.3\",\n",
140-
" \"step\": \"install pandas\"\n",
141141
" }\n",
142142
"]\n"
143143
]
144144
}
145145
],
146146
"source": [
147-
"scikit_learn_install = {\n",
148-
" \"command\": \"pip install scikit-learn==1.2.0\",\n",
149-
" \"step\": \"install scikit-learn\"\n",
150-
"}\n",
151-
"requirements_json[0].update(scikit_learn_install)\n",
147+
"for requirement in requirements_json:\n",
148+
" if 'sklearn' in requirement['step']:\n",
149+
" requirement['command'] = requirement[\"command\"].replace('sklearn', 'scikit-learn')\n",
150+
" requirement['step'] = requirement['step'].replace('sklearn', 'scikit-learn')\n",
151+
"\n",
152152
"print(json.dumps(requirements_json, sort_keys=True, indent=4))"
153153
]
154154
},
@@ -174,9 +174,9 @@
174174
],
175175
"metadata": {
176176
"kernelspec": {
177-
"display_name": "dev-py38",
177+
"display_name": "yeehaw",
178178
"language": "python",
179-
"name": "dev-py38"
179+
"name": "python3"
180180
},
181181
"language_info": {
182182
"codemirror_mode": {

src/sasctl/pzmm/write_json_files.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1639,7 +1639,7 @@ def create_requirements_json(
16391639
) as file:
16401640
file.write(json.dumps(json_dicts, indent=4))
16411641
else:
1642-
return {"requirements.json": json.dumps(json_dicts)}
1642+
return json_dicts
16431643

16441644
@staticmethod
16451645
def get_local_package_version(package_list: List[str]) -> List[List[str]]:

src/sasctl/pzmm/write_score_code.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -721,10 +721,10 @@ def impute_missing_values(data):
721721
"""
722722
impute_values = \\\n + {"var1": 0, "var2": "", "var3": 125.3}
723723
"""
724-
cls.score_code += f"\n{'':4}return data.fillna(impute_values)\n"
724+
cls.score_code += f"\n{'':4}return data.replace(' .', np.nan).fillna(impute_values).apply(pd.to_numeric, errors='ignore')\n"
725725
"""
726726
727-
return data.fillna(impute_values)
727+
return data.replace(' .', np.nan).fillna(impute_values).apply(pd.to_numeric, errors='ignore')
728728
"""
729729

730730
# TODO: Needs unit test
@@ -1121,6 +1121,8 @@ def _predictions_to_metrics(
11211121
are not given, this index should indicate whether the the target probability variable
11221122
is the first or second variable returned by the model. The default value is 1.
11231123
"""
1124+
if not target_index:
1125+
target_index = 1
11241126
if len(metrics) == 1 and isinstance(metrics, list):
11251127
# Flatten single valued list
11261128
metrics = metrics[0]

0 commit comments

Comments
 (0)