@@ -49,8 +49,8 @@ def _sklearn_to_dict(model):
49
49
'RandomForestClassifier' : 'Forest' ,
50
50
'DecisionTreeClassifier' : 'Decision tree' ,
51
51
'DecisionTreeRegressor' : 'Decision tree' ,
52
- 'classifier' : 'Classification ' ,
53
- 'regressor' : 'Prediction ' }
52
+ 'classifier' : 'classification ' ,
53
+ 'regressor' : 'prediction ' }
54
54
55
55
if hasattr (model , '_final_estimator' ):
56
56
estimator = type (model ._final_estimator )
@@ -302,17 +302,27 @@ def get_version(x):
302
302
else :
303
303
prediction_variable = None
304
304
305
- project = mr .create_project (project , repo_obj ,
305
+ # As of Viya 3.4 the 'predictionVariable' parameter is not set during
306
+ # project creation. Update the project if necessary.
307
+ if model .get ('function' ) == 'prediction' : #Predications require predictionVariable
308
+ project = mr .create_project (project , repo_obj ,
306
309
variables = vars ,
307
310
function = model .get ('function' ),
308
311
targetLevel = target_level ,
309
312
predictionVariable = prediction_variable )
310
313
311
- # As of Viya 3.4 the 'predictionVariable' parameter is not set during
312
- # project creation. Update the project if necessary.
313
- if project .get ('predictionVariable' ) != prediction_variable :
314
- project ['predictionVariable' ] = prediction_variable
315
- mr .update_project (project )
314
+ if project .get ('predictionVariable' ) != prediction_variable :
315
+ project ['predictionVariable' ] = prediction_variable
316
+ mr .update_project (project )
317
+ else : #Classifications require eventProbabilityVariable
318
+ project = mr .create_project (project , repo_obj ,
319
+ variables = vars ,
320
+ function = model .get ('function' ),
321
+ targetLevel = target_level ,
322
+ eventProbabilityVariable = prediction_variable )
323
+ if project .get ('eventProbabilityVariable' ) != prediction_variable :
324
+ project ['eventProbabilityVariable' ] = prediction_variable
325
+ mr .update_project (project )
316
326
317
327
model = mr .create_model (model , project )
318
328
@@ -506,9 +516,12 @@ def update_model_performance(data, model, label, refresh=True):
506
516
"regression and binary classification projects. "
507
517
"Received project with '%s' target level. Should be "
508
518
"'Interval' or 'Binary'." , project .get ('targetLevel' ))
509
- elif project .get ('predictionVariable' , '' ) == '' :
519
+ elif project .get ('predictionVariable' , '' ) == '' and project . get ( 'function' , '' ). lower () == 'prediction' :
510
520
raise ValueError ("Project '%s' does not have a prediction variable "
511
521
"specified." % project )
522
+ elif project .get ('eventProbabilityVariable' , '' ) == '' and project .get ('function' , '' ).lower () == 'classification' :
523
+ raise ValueError ("Project '%s' does not have an Event Probability variable "
524
+ "specified." % project )
512
525
513
526
# Find the performance definition for the model
514
527
# As of Viya 3.4, no way to search by model or project
0 commit comments