@@ -2208,7 +2208,7 @@ def generate_model_card(
2208
2208
algorithm : str ,
2209
2209
train_data : pd .DataFrame ,
2210
2210
train_predictions : Union [pd .Series , list ],
2211
- target_type : str = "Interval " ,
2211
+ target_type : str = "interval " ,
2212
2212
target_value : Union [str , int , float , None ] = None ,
2213
2213
interval_vars : Optional [list ] = [],
2214
2214
class_vars : Optional [list ] = [],
@@ -2237,10 +2237,10 @@ def generate_model_card(
2237
2237
train_predictions : pandas.Series, list
2238
2238
List of predictions made by the model on the training data.
2239
2239
target_type : string
2240
- Type the model is targeting. Currently supports "Classification " and "Interval " types.
2240
+ Type the model is targeting. Currently supports "classification " and "interval " types.
2241
2241
The default value is "Interval".
2242
2242
target_value : string, int, float, optional
2243
- Value the model is targeting for Classification models. This argument is not needed for
2243
+ Value the model is targeting for classification models. This argument is not needed for
2244
2244
Interval models. The default value is None.
2245
2245
interval_vars : list, optional
2246
2246
A list of interval variables. The default value is an empty list.
@@ -2255,14 +2255,14 @@ def generate_model_card(
2255
2255
caslib: str, optional
2256
2256
The caslib the training data will be stored on. The default value is "Public"
2257
2257
"""
2258
- if not target_value and target_type == "Classification " :
2258
+ if not target_value and target_type == "classification " :
2259
2259
raise RuntimeError (
2260
- "For the model card data to be properly generated on a Classification "
2260
+ "For the model card data to be properly generated on a classification "
2261
2261
"model, a target value is required."
2262
2262
)
2263
- if target_type not in ["Classification " , "Interval " ]:
2263
+ if target_type not in ["classification " , "interval " ]:
2264
2264
raise RuntimeError (
2265
- "Only Classification and Interval target types are currently accepted."
2265
+ "Only classification and interval target types are currently accepted."
2266
2266
)
2267
2267
if selection_statistic not in cls .valid_params :
2268
2268
raise RuntimeError (
@@ -2396,10 +2396,10 @@ def generate_outcome_average(
2396
2396
Returns a dictionary with a key value pair that represents the outcome average.
2397
2397
"""
2398
2398
output_var = train_data .drop (input_variables , axis = 1 )
2399
- if target_type == "Classification " :
2399
+ if target_type == "classification " :
2400
2400
value_counts = output_var [output_var .columns [0 ]].value_counts ()
2401
2401
return {'eventPercentage' : value_counts [target_value ]/ sum (value_counts )}
2402
- elif target_type == "Interval " :
2402
+ elif target_type == "interval " :
2403
2403
return {'eventAverage' : sum (value_counts [value_counts .columns [0 ]]) / len (value_counts )}
2404
2404
2405
2405
@staticmethod
@@ -2480,8 +2480,8 @@ def update_model_properties(
2480
2480
"The ModelProperties.json file must be generated before the model card data "
2481
2481
"can be generated."
2482
2482
)
2483
- for key , value in update_dict :
2484
- model_files [PROP ][key ] = value
2483
+ for key in update_dict :
2484
+ model_files [PROP ][key ] = update_dict [ key ]
2485
2485
else :
2486
2486
if not Path .exists (Path (model_files ) / PROP ):
2487
2487
raise RuntimeError (
@@ -2490,8 +2490,8 @@ def update_model_properties(
2490
2490
)
2491
2491
with open (Path (model_files ) / PROP , 'r+' ) as properties_json :
2492
2492
model_properties = json .load (properties_json )
2493
- for key , value in update_dict :
2494
- model_properties [key ] = value
2493
+ for key in update_dict :
2494
+ model_properties [key ] = update_dict [ key ]
2495
2495
properties_json .seek (0 )
2496
2496
properties_json .write (json .dumps (model_properties , indent = 4 , cls = NpEncoder ))
2497
2497
properties_json .truncate ()
@@ -2595,7 +2595,7 @@ def generate_variable_importance(
2595
2595
}
2596
2596
})
2597
2597
var_data = conn .dataPreprocess .transform (
2598
- table = {"name" : "test_data " , "caslib" : caslib },
2598
+ table = {"name" : "train_data " , "caslib" : caslib },
2599
2599
requestPackages = request_packages ,
2600
2600
evaluationStats = True ,
2601
2601
percentileMaxIterations = 10 ,
@@ -2623,7 +2623,10 @@ def generate_variable_importance(
2623
2623
},
2624
2624
"rowNumber" : index + 1
2625
2625
})
2626
- with open ('./dmcas_relativeimportance.json' , 'r' ) as f :
2626
+ json_template_path = (
2627
+ Path (__file__ ).resolve ().parent / f"template_files/{ VARIMPORTANCES } "
2628
+ )
2629
+ with open (json_template_path , 'r' ) as f :
2627
2630
relative_importance_json = json .load (f )
2628
2631
relative_importance_json ['data' ] = relative_importances
2629
2632
@@ -2641,5 +2644,4 @@ def generate_variable_importance(
2641
2644
print (
2642
2645
f"{ VARIMPORTANCES } was successfully written and saved to "
2643
2646
f"{ Path (model_files ) / VARIMPORTANCES } "
2644
-
2645
2647
)
0 commit comments