Azure ML CLI v2使用MLTable创建数据资产



我将镶木地板文件上传到blobstorage,并通过Azure ML GUI创建了一个数据资产。这些步骤是准确和明确的,结果如所愿。为了将来使用,我想使用CLI来创建数据资产及其新版本。

基本命令将是az ml create data -f <file-name>.yml。文档提供了一个MLTable文件的最小示例,该文件应位于镶木地板文件旁边。

# directory in blobstorage
├── data
│   ├── MLTable
│   ├── file_1.parquet
.
.
.
│   ├── file_n.parquet

我仍然不确定如何正确地指定这些文件,以便创建具有列转换的表格数据集。

我需要在yml文件中指定完整路径或模式吗?

$schema: https://azuremlschemas.azureedge.net/latest/data.schema.json
type: mltable
name: Test data
description: Basic example for parquet files
path: azureml://datastores/workspaceblobstore/paths/*/*.parquet # pattern or path to dir?

我对MLTable文件有更多的困惑:

type: mltable
paths:
- pattern: ./*.parquet
transformations:
- read_parquet:
# what comes here?

例如,我有一列的日期格式为%Y-%m%d %H:%M:%S,应该将其转换为时间戳。(我至少可以在GUI中提供这些信息!(

关于这个主题的任何帮助或文档的隐藏链接都将是非常棒的。

从镶木地板文件转换字符串列的工作MLTable文件如下所示:

--- 
type: mltable
paths: 
- pattern: ./*.parquet
transformations: 
- read_parquet: 
include_path_column: false
- convert_column_types:
- columns: column_a
column_type:
datetime:
formats:
- "%Y-%m-%d %H:%M:%S"
- convert_column_types:
- columns: column_b
column_type:
datetime:
formats:
- "%Y-%m-%d %H:%M:%S"

(顺便说一句,在写这篇文章时,将多列指定为数组不起作用,例如columns: [column_a, column_b](

要执行此操作,我们需要检查实验的安装和要求。我们需要有有效的订阅和工作空间。

安装所需的mltable库。

Azure ML 中有4种不同的支持路径作为参数

•本地计算机路径

•公共服务器上的路径,如HTTP/HTTPS

•azure存储上的路径(在这种情况下类似于blob(

•数据存储上的路径

在作为断言创建的文件夹中创建一个YAML文件文件名可以是任何(Filename.yml(

$schema: https://azuremlschemas.azureedge.net/latest/data.schema.json
type: uri_folder
name: <name_of_data>
description: <description goes here>
path: <path>
to create the data assert using CLI. 
az ml data create -f filename.yml

创建特定文件作为数据资产

$schema: https://azuremlschemas.azureedge.net/latest/data.schema.json
# Supported paths include:
# local: ./<path>/<file>
# blob:  https://<account_name>.blob.core.windows.net/<container_name>/<path>/<file>
# ADLS gen2: abfss://<file_system>@<account_name>.dfs.core.windows.net/<path>/<file>
# Datastore: azureml://datastores/<data_store_name>/paths/<path>/<file>
type: uri_file
name: <name>
description: <description>
path: <uri>

所有路径都需要根据您的工作区凭据进行提及。

创建MLTable文件作为数据资源。

创建一个yml文件,其数据模式如下所示,并使用中的数据

type: mltable
paths:
- pattern: ./*.filetypeextension
transformations:
- read_delimited:
delimiter: ,
encoding: ascii
header: all_files_same_headers

使用下面的python代码来使用MLTable

import mltable
table1 = mltable.load(uri="./data")
df = table1.to_pandas_dataframe()

创建MLTable数据资源。使用以下代码块。

$schema: https://azuremlschemas.azureedge.net/latest/data.schema.json
# path must point to **folder** containing MLTable artifact (MLTable file + data
# Supported paths include:
# blob:  https://<account_name>.blob.core.windows.net/<container_name>/<path>
type: mltable
name: <name_of_data>
description: <description goes here>
path: <path>

Blob是当前需求中的存储机制。

相同的程序用于创建MLTable 的数据资产

az ml data create -f <file-name>.yml

最新更新