简体   繁体   中英

Errors on Azure Machine Learning notebooks: The truth value of a DataFrame is ambiguous

I'm working on deploying a machine learning model on Azure while using their notebooks and I ran into an error. I'm following this tutorial for a Power BI integration.

When this code got executed:

import sklearn

from azureml.core import Workspace
from azureml.core import Model
from azureml.core.resource_configuration import ResourceConfiguration

ws = Workspace.from_config()
model = Model.register(workspace=ws,
                       model_name='POC',                # Name of the registered model in your workspace.
                       model_path='./final_model.pkl',  # Local file to upload and register as a model.
                       model_framework=Model.Framework.SCIKITLEARN,  # Framework used to create the model.
                       model_framework_version=sklearn.__version__,  # Version of scikit-learn used to create the model.
                       sample_input_dataset=X,
                       sample_output_dataset=y,
                       resource_configuration=ResourceConfiguration(cpu=2, memory_in_gb=4),
                       description='RandomForestClassifier.',
                       tags={'area': 'finance', 'type': 'classification'})

print('Name:', model.name)
print('Version:', model.version)

I ran into the following error:

ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Menu Uitvoer
Registering model POC
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-65-d8fe09fe9514> in <module>
     15                        resource_configuration=ResourceConfiguration(cpu=2, memory_in_gb=4),
     16                        description='RandomForestClassifier.',
---> 17                        tags={'area': 'finance', 'type': 'classification'})
     18 
     19 print('Name:', model.name)

/anaconda/envs/azureml_py36/lib/python3.6/site-packages/azureml/core/model.py in register(workspace, model_path, model_name, tags, properties, description, datasets, model_framework, model_framework_version, child_paths, sample_input_dataset, sample_output_dataset, resource_configuration)
    593                                            sample_input_dataset=sample_input_dataset,
    594                                            sample_output_dataset=sample_output_dataset,
--> 595                                            resource_configuration=resource_configuration)
    596 
    597         return model

My sample_input_dataset for X is my Pandas DataFrame and my sample_output_dataset for y is a Pandas Series and I also tried to use Numpy Arrays for this.

The solution is to convert X and y in TabularDataset .

The only way to do this is to register the dataframe in AML workspace and download it. Maybe there is a smarter way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM