【问题标题】:azure machine learning- Azure Blob Storage天蓝色机器学习 - Azure Blob 存储
【发布时间】:2015-12-04 10:29:44
【问题描述】:

如何使用 Azure 机器学习工作室“一次”从存储在 Azure Blob 存储中的多个文件中读取数据?

我尝试使用 Reader 模块,它对一个文件工作得很好,它对多个文件有用吗,还是我必须寻找其他解决方案?

感谢您的帮助!

【问题讨论】:

    标签: azure module machine-learning azure-blob-storage reader


    【解决方案1】:

    如果没有那么多 blob,您可以将每个地图的多个阅读器添加到您的输入 blob 之一。然后使用“Data Transformation”->“Manipulation”下的模块来执行“Add Rows”或“Join”之类的操作。

    【讨论】:

      【解决方案2】:

      使用大量读取器从不同的 blob 中读取,然后将它们连接到元数据编辑器。

      【讨论】:

        【解决方案3】:

        虽然使用多个Reader 模块的方法会奏效,但当输入很多或输入的数量不同时,它会变得非常困难。

        相反,您可以使用 Execute Python Script 模块直接访问 Blob 存储。但是,如果您以前从未这样做过,那么这样做会非常痛苦。以下是问题:

        1. 默认情况下,azure.storage.blob Python 包不会加载到 Azure ML 中。但是,可以手动创建,也可以从下面的链接下载(截至 2016 年 2 月 11 日的正确版本)。
        2. azure.storage.blob.BlobService 的默认用法使用 HTTPS,Azure ML Blob 存储访问目前不支持此功能。为此,您可以在 BlobService 创建期间传入protocol='http' 以强制使用HTTP:client = BlobService(STORAGE_ACCOUNT, STORAGE_KEY, protocol="http")

        以下是让它工作的步骤:

        1. 下载azure.zip,它提供了所需的azure.storage.*库:https://azuremlpackagesupport.blob.core.windows.net/python/azure.zip
        2. 将它们作为数据集上传到 Azure ML Studio
        3. 将它们连接到Execute Python Script 模块上的 Zip 输入,这是第三个输入。
        4. 像往常一样编写脚本,确保使用protocol='http' 创建BlobService 对象
        5. 运行实验 - 您现在应该能够读取和写入 Blob 存储。

        一些示例代码可以在这里找到:https://gist.github.com/drdarshan/92fff2a12ad9946892df

        这是使其适用于单个文件的代码。这可以通过访问容器和过滤扩展为处理大量文件,但这取决于您的业务逻辑。

        from azure.storage.blob import BlobService
        
        def azureml_main(dataframe1 = None, dataframe2 = None):
            account_name = 'mystorageaccount'
            account_key='p8kSy3FACx...redacted...ebz3plQ=='
            container_name = "upload"
        
            blob_service = BlobService(account_name, account_key, protocol='http')
        
            file = blob_service.get_blob_to_text(container_name,'myfile.txt')
            # You can also get_blob_to_(bytes|file|path), if you need to do so.
        
            # Do stuff with your file here
            #   Logic, logic, logic
        
            # Execute Python Script requires that a dataframe is returned. It can be null.
            # Return value must be of a sequence of pandas.DataFrame
            return dataframe1,
        

        有关限制、为什么使用 HTTP 和其他说明的更多信息,请参阅Access Azure blog storage from within an Azure ML experiment

        【讨论】:

          猜你喜欢
          • 2022-07-08
          • 1970-01-01
          • 2022-01-08
          • 2015-09-09
          • 2018-02-01
          • 1970-01-01
          • 1970-01-01
          • 2019-08-11
          • 2019-02-24
          相关资源
          最近更新 更多