@@ -1260,7 +1260,7 @@ def calculate_model_statistics(
1260
1260
if not partition :
1261
1261
continue
1262
1262
1263
- data = cls .stat_dataset_to_dataframe (data , target_value )
1263
+ data = cls .stat_dataset_to_dataframe (data , target_value , target_type )
1264
1264
1265
1265
conn .upload (
1266
1266
data ,
@@ -1392,6 +1392,7 @@ def check_for_data(
1392
1392
def stat_dataset_to_dataframe (
1393
1393
data : Union [DataFrame , List [list ], Type ["numpy.array" ]],
1394
1394
target_value : Union [str , int , float ] = None ,
1395
+ target_type : str = 'classification'
1395
1396
) -> DataFrame :
1396
1397
"""
1397
1398
Convert the user supplied statistical dataset from either a pandas DataFrame,
@@ -1439,13 +1440,15 @@ def stat_dataset_to_dataframe(
1439
1440
if isinstance (data , pd .DataFrame ):
1440
1441
if len (data .columns ) == 2 :
1441
1442
data .columns = ["actual" , "predict" ]
1442
- data ["predict_proba" ] = data ["predict" ].gt (target_value ).astype (int )
1443
+ if target_type == 'classification' :
1444
+ data ["predict_proba" ] = data ["predict" ].gt (target_value ).astype (int )
1443
1445
elif len (data .columns ) == 3 :
1444
1446
data .columns = ["actual" , "predict" , "predict_proba" ]
1445
1447
elif isinstance (data , list ):
1446
1448
if len (data ) == 2 :
1447
1449
data = pd .DataFrame ({"actual" : data [0 ], "predict" : data [1 ]})
1448
- data ["predict_proba" ] = data ["predict" ].gt (target_value ).astype (int )
1450
+ if target_type == 'classification' :
1451
+ data ["predict_proba" ] = data ["predict" ].gt (target_value ).astype (int )
1449
1452
elif len (data ) == 3 :
1450
1453
data = pd .DataFrame (
1451
1454
{
@@ -1457,7 +1460,8 @@ def stat_dataset_to_dataframe(
1457
1460
elif isinstance (data , np .ndarray ):
1458
1461
if len (data ) == 2 :
1459
1462
data = pd .DataFrame ({"actual" : data [0 , :], "predict" : data [1 , :]})
1460
- data ["predict_proba" ] = data ["predict" ].gt (target_value ).astype (int )
1463
+ if target_type == 'classification' :
1464
+ data ["predict_proba" ] = data ["predict" ].gt (target_value ).astype (int )
1461
1465
elif len (data ) == 3 :
1462
1466
data = pd .DataFrame (
1463
1467
{"actual" : data [0 ], "predict" : data [1 ], "predict_proba" : data [2 ]}
@@ -2366,7 +2370,8 @@ def generate_model_card(
2366
2370
)
2367
2371
2368
2372
# Generates dmcas_misc.json file
2369
- cls .generate_misc (model_files )
2373
+ if target_type == 'classification' :
2374
+ cls .generate_misc (model_files )
2370
2375
2371
2376
@staticmethod
2372
2377
def upload_training_data (
@@ -2617,7 +2622,7 @@ def generate_variable_importance(
2617
2622
if target_type == "classification" :
2618
2623
method = "DTREE"
2619
2624
treeCrit = "Entropy"
2620
- elif target_type == "interval " :
2625
+ elif target_type == "prediction " :
2621
2626
method = "RTREE"
2622
2627
treeCrit = "RSS"
2623
2628
else :
@@ -2743,14 +2748,14 @@ def generate_misc(cls, model_files: Union[str, Path, dict]):
2743
2748
if isinstance (model_files , dict ):
2744
2749
if ROC not in model_files :
2745
2750
raise RuntimeError (
2746
- "The ModelProperties .json file must be generated before the model card data "
2751
+ "The dmcas_roc .json file must be generated before the model card data "
2747
2752
"can be generated."
2748
2753
)
2749
2754
roc_table = model_files [ROC ]
2750
2755
else :
2751
2756
if not Path .exists (Path (model_files ) / ROC ):
2752
2757
raise RuntimeError (
2753
- "The ModelProperties .json file must be generated before the model card data "
2758
+ "The dmcas_roc .json file must be generated before the model card data "
2754
2759
"can be generated."
2755
2760
)
2756
2761
with open (Path (model_files ) / ROC , "r" ) as roc_file :
0 commit comments