@@ -49,8 +49,8 @@ def _sklearn_to_dict(model):
4949 'RandomForestClassifier' : 'Forest' ,
5050 'DecisionTreeClassifier' : 'Decision tree' ,
5151 'DecisionTreeRegressor' : 'Decision tree' ,
52- 'classifier' : 'Classification ' ,
53- 'regressor' : 'Prediction ' }
52+ 'classifier' : 'classification ' ,
53+ 'regressor' : 'prediction ' }
5454
5555 if hasattr (model , '_final_estimator' ):
5656 estimator = type (model ._final_estimator )
@@ -302,17 +302,27 @@ def get_version(x):
302302 else :
303303 prediction_variable = None
304304
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 ,
306309 variables = vars ,
307310 function = model .get ('function' ),
308311 targetLevel = target_level ,
309312 predictionVariable = prediction_variable )
310313
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 )
316326
317327 model = mr .create_model (model , project )
318328
@@ -506,9 +516,12 @@ def update_model_performance(data, model, label, refresh=True):
506516 "regression and binary classification projects. "
507517 "Received project with '%s' target level. Should be "
508518 "'Interval' or 'Binary'." , project .get ('targetLevel' ))
509- elif project .get ('predictionVariable' , '' ) == '' :
519+ elif project .get ('predictionVariable' , '' ) == '' and project . get ( 'function' , '' ). lower () == 'prediction' :
510520 raise ValueError ("Project '%s' does not have a prediction variable "
511521 "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 )
512525
513526 # Find the performance definition for the model
514527 # As of Viya 3.4, no way to search by model or project
0 commit comments