簡體   English   中英

Azure 機器學習筆記本上的錯誤:DataFrame 的真值不明確

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

我正在使用他們的筆記本在 Azure 上部署機器學習 model,但我遇到了錯誤。 我正在按照本教程進行 Power BI 集成。

執行此代碼時:

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)

我遇到了以下錯誤:

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

X 的 sample_input_dataset 是我的 Pandas DataFrame,y 的 sample_output_dataset 是 Pandas 系列,我也嘗試為此使用 Numpy Arrays。

解決方案是轉換TabularDataset中的 X 和 y。

唯一的方法是在 AML 工作區中注冊 dataframe 並下載它。 也許有更聰明的方法。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM