IBM Support

ModuleNotFoundError and message: No module named 'pandas.core.indexes.numeric' error occurred during deploying the model with extension packages

Question & Answer


Question

With the following codes, I could promote a model with extension packages successfully.
# Create package extension with a "pip_zip" package file

meta_prop_pkg_extn = {
    client.package_extensions.ConfigurationMetaNames.NAME: "category_encoders-2.6.0",
    client.package_extensions.ConfigurationMetaNames.DESCRIPTION: "Category Encodder package extension",
    client.package_extensions.ConfigurationMetaNames.TYPE: "pip_zip"
}

pkg_extn_details = client.package_extensions.store(meta_props=meta_prop_pkg_extn, file_path="category_encoders-2.6.0.zip")
pkg_extn_uid = client.package_extensions.get_uid(pkg_extn_details)
pkg_extn_url = client.package_extensions.get_href(pkg_extn_details)

# Add extension package to the runtime environment

base_sw_spec_uid = client.software_specifications.get_uid_by_name("runtime-22.2-py3.10")

meta_prop_sw_spec = {
    client.software_specifications.ConfigurationMetaNames.NAME: "category_encoders-2.6.0",
    client.software_specifications.ConfigurationMetaNames.DESCRIPTION: "Software specification for category_encoders-2.6.0",
    client.software_specifications.ConfigurationMetaNames.BASE_SOFTWARE_SPECIFICATION: {"guid": base_sw_spec_uid}
}

sw_spec_details = client.software_specifications.store(meta_props=meta_prop_sw_spec)
sw_spec_uid = client.software_specifications.get_uid(sw_spec_details)
print(sw_spec_uid)

client.software_specifications.add_package_extension(sw_spec_uid, pkg_extn_uid)

# Promote model to the deployment space

model_metadata = {
            client.repository.ModelMetaNames.NAME: 'DRUG_RandomForestWithCategoryEncoder',
            client.repository.ModelMetaNames.TYPE: 'scikit-learn_1.1',
            client.repository.ModelMetaNames.SOFTWARE_SPEC_UID: sw_spec_uid,
            client.repository.ModelMetaNames.INPUT_DATA_SCHEMA: {'type': 'struct', 'fields': [\
                                     {'nullable': False, 'metadata': {}, 'name': 'Age', 'type': 'integer'}, \
                                     {'nullable': False, 'metadata': {}, 'name': 'Sex', 'type': 'string'}, \
                                     {'nullable': False, 'metadata': {}, 'name': 'BP', 'type': 'string'}, \
                                     {'nullable': False, 'metadata': {}, 'name': 'Cholesterol', 'type': 'string'}, \
                                     {'nullable': False, 'metadata': {}, 'name': 'Na', 'type': 'double'}, \
                                     {'nullable': False, 'metadata': {}, 'name': 'K', 'type': 'double'}],'id': '1'}
}

published_model = client.repository.store_model(model=drug_randomforest_model, meta_props=model_metadata, training_data=X_train, training_target=y_train)
published_model
However, the ModuleNotFoundError and message: No module named 'pandas.core.indexes.numeric' error occurred during deploying the model with extension packages.
# Deploy the model
metadata = {
    client.deployments.ConfigurationMetaNames.NAME: "DRUG_RandomForestWithCategoryEncoderOnline_Deployment",
    client.deployments.ConfigurationMetaNames.ONLINE: {}
}

created_deployment = client.deployments.create(published_model_uid, meta_props=metadata)

### FOLLOWING ERROR OCCURRED ###

# WMLClientError: Deployment creation failed for deployment id: 9ede2602-1cd3-4c6d-b998-6b7c28ab06e2. 
# Errors: [{'code': 'd776f8a7d40a5ce8b42cd365cf562207', 'message': "Model loading 
# through joblib failed with exception: ModuleNotFoundError 
# and message: No module named 'pandas.core.indexes.numeric'. The model object 
# provided for deployment is either invalid or trained using a version of scikit-learn other than: 1.3"}]
How can I solve this problem?

[{"Type":"MASTER","Line of Business":{"code":"LOB10","label":"Data and AI"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSXO5O","label":"IBM Watson Machine Learning for IBM Cloud Pak for Data"},"ARM Category":[{"code":"a8m3p0000006xtiAAA","label":"Services-\u003EData Science Tools-\u003EWatson Machine Learning"}],"ARM Case Number":"TS015059546","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Versions"}]

Log InLog in to view more of this document

This document has the abstract of a technical article that is available to authorized users once you have logged on. Please use Log in button above to access the full document. After log in, if you do not have the right authorization for this document, there will be instructions on what to do next.

Document Information

Modified date:
06 January 2024

UID

ibm17105576