Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError when attempting to register scikit-learn model #200

Open
jyanchuck opened this issue Oct 1, 2024 · 1 comment
Open

ValueError when attempting to register scikit-learn model #200

jyanchuck opened this issue Oct 1, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@jyanchuck
Copy link

Describe the issue
When I attempt to register a scitkit-learn model in Jupyter Lab in Viya Workbench, I experience the following error: "ValueError: Please provide all possible values for the target variable, including a no-event value." Examining the stack trace, the issue is with the target_value property of the object returned when running get_model_info (called within register_models). For a binary classifier model, the register_model expects the target_value property to return 0 (non-event value) and 1 (event value), but it is only returning a 1 (event value). Looking at utils/model_info.py, this is intentional for a binary classifier model for the target_value property to only return the event. However, this is causing the register_model function to complete with errors.

To Reproduce
Python notebook has been attached. Error occurs when register_model function is called.
RiskModelWorkbenchLendingClubFinal-simplified.zip

Expected behavior
I expect the register_model function to complete without errors and successfully register this scikit-learn model in the Model Manager repository in the specified project in the target environment.

Stack Trace
ValueError Traceback (most recent call last)
Cell In[34], line 3
1 model_name="SK_LogisticRegression"
2 project="Test"
----> 3 register_model(model_sklg, model_name, X=X_train, project=project, force=True)

File /workspaces/workspace/.user-python-packages/lib/python3.11/site-packages/sasctl/tasks.py:494, in register_model(model, name, project, repository, X, version, files, force, record_packages, modeler, input)
483 model_obj = _register_sas_model(
484 model,
485 name,
(...)
490 version=version,
491 )
493 elif not isinstance(model, dict):
--> 494 model_obj = _register_open_source_model(
495 model, name, project, X=X, modeler=modeler or current_session().username
496 )
497 else:
498 project = _create_project(project, model, repo_obj)

File /workspaces/workspace/.user-python-packages/lib/python3.11/site-packages/sasctl/tasks.py:221, in _register_open_source_model(model, name, project, X, modeler)
219 output_vars = JSONFiles().write_var_json(info.y, is_input=False)
220 metadata = JSONFiles().write_file_metadata_json(model_prefix=name)
--> 221 properties = JSONFiles().write_model_properties_json(
222 model_name=name,
223 model_desc=info.description,
224 model_algorithm=info.algorithm,
225 modeler=modeler,
226 target_variable=info.target_column,
227 target_values=info.target_values,
228 )
230 # requirements = JSONFiles().create_requirements_json(model)
232 pzmm_files.update(serialized_model)

File /workspaces/workspace/.user-python-packages/lib/python3.11/site-packages/sasctl/pzmm/write_json_files.py:389, in JSONFiles.write_model_properties_json(cls, model_name, target_variable, target_values, json_path, model_desc, model_algorithm, model_function, modeler, train_table, properties)
381 properties.append(
382 {
383 "name": "multiclass_proba_variables",
(...)
386 }
387 )
388 else:
--> 389 raise ValueError(
390 "Please provide all possible values for the target variable, including"
391 " a no-event value."
392 )
394 truncated_properties = []
395 for prop in properties:

ValueError: Please provide all possible values for the target variable, including a no-event value.

Version
sasctl 1.10.6

@jyanchuck jyanchuck added the bug Something isn't working label Oct 1, 2024
@TzufSAS
Copy link

TzufSAS commented Dec 8, 2024

Hey, I am facing the same error.
How did you overcome it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants