데이터 관리를 SDK v2로 업그레이드
V1에서 Azure Machine Learning 데이터 세트는 또는 Filedataset
/> Tabulardataset
일 수 있습니다.
V2에서 Azure Machine Learning 데이터 자산 uri_folder
은 , uri_file
또는 mltable
.
개념적으로 , 또는 uri_file
Tabulardataset
에 매핑 Filedataset
할 uri_folder
mltable
수 있습니다.
- URI(
uri_folder
,uri_file
) - Uniform Resource Identifier는 작업에서 데이터에 쉽게 액세스할 수 있도록 로컬 컴퓨터 또는 클라우드의 스토리지 위치에 대한 참조입니다. - MLTable - 테이블 형식 데이터 스키마 정의를 추상화하기 위한 메서드입니다. 해당 데이터의 소비자는 테이블을 Pandas/Dask/Spark 데이터 프레임으로 보다 쉽게 구체화할 수 있습니다.
이 문서에서는 SDK v1 및 SDK v2의 데이터 시나리오를 비교합니다.
데이터 자산의 filedataset
/uri 형식 만들기
SDK v1 -
Filedataset
만들기from azureml.core import Workspace, Datastore, Dataset # create a FileDataset pointing to files in 'animals' folder and its subfolders recursively datastore_paths = [(datastore, 'animals')] animal_ds = Dataset.File.from_files(path=datastore_paths) # create a FileDataset from image and label files behind public web urls web_paths = ['https://azureopendatastorage.blob.core.windows.net/mnist/train-images-idx3-ubyte.gz', 'https://azureopendatastorage.blob.core.windows.net/mnist/train-labels-idx1-ubyte.gz'] mnist_ds = Dataset.File.from_files(path=web_paths)
SDK v2
데이터 자산의
URI_FOLDER
형식 만들기from azure.ai.ml.entities import Data from azure.ai.ml.constants import AssetTypes # Supported paths include: # local: './<path>' # blob: 'https://<account_name>.blob.core.windows.net/<container_name>/<path>' # ADLS gen2: 'abfss://<file_system>@<account_name>.dfs.core.windows.net/<path>/' # Datastore: 'azureml://datastores/<data_store_name>/paths/<path>' my_path = '<path>' my_data = Data( path=my_path, type=AssetTypes.URI_FOLDER, description="<description>", name="<name>", version='<version>' ) ml_client.data.create_or_update(my_data)
데이터 자산의
URI_FILE
형식 만들기from azure.ai.ml.entities import Data from azure.ai.ml.constants import AssetTypes # 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>' my_path = '<path>' my_data = Data( path=my_path, type=AssetTypes.URI_FILE, description="<description>", name="<name>", version="<version>" ) ml_client.data.create_or_update(my_data)
테이블 형식 데이터 세트/데이터 자산 만들기
SDK v1
from azureml.core import Workspace, Datastore, Dataset datastore_name = 'your datastore name' # get existing workspace workspace = Workspace.from_config() # retrieve an existing datastore in the workspace by name datastore = Datastore.get(workspace, datastore_name) # create a TabularDataset from 3 file paths in datastore datastore_paths = [(datastore, 'weather/2018/11.csv'), (datastore, 'weather/2018/12.csv'), (datastore, 'weather/2019/*.csv')] weather_ds = Dataset.Tabular.from_delimited_files(path=datastore_paths)
SDK v2 - yaml 정의를 통해
mltable
데이터 자산 만들기type: mltable paths: - pattern: ./*.txt transformations: - read_delimited: delimiter: , encoding: ascii header: all_files_same_headers
from azure.ai.ml.entities import Data from azure.ai.ml.constants import AssetTypes # my_path must point to folder containing MLTable artifact (MLTable file + data # Supported paths include: # local: './<path>' # blob: 'https://<account_name>.blob.core.windows.net/<container_name>/<path>' # ADLS gen2: 'abfss://<file_system>@<account_name>.dfs.core.windows.net/<path>/' # Datastore: 'azureml://datastores/<data_store_name>/paths/<path>' my_path = '<path>' my_data = Data( path=my_path, type=AssetTypes.MLTABLE, description="<description>", name="<name>", version='<version>' ) ml_client.data.create_or_update(my_data)
실험/작업에서 데이터 사용
SDK v1
from azureml.core import ScriptRunConfig src = ScriptRunConfig(source_directory=script_folder, script='train_titanic.py', # pass dataset as an input with friendly name 'titanic' arguments=['--input-data', titanic_ds.as_named_input('titanic')], compute_target=compute_target, environment=myenv) # Submit the run configuration for your training run run = experiment.submit(src) run.wait_for_completion(show_output=True)
SDK v2
from azure.ai.ml import command from azure.ai.ml.entities import Data from azure.ai.ml import Input, Output from azure.ai.ml.constants import AssetTypes # Possible Asset Types for Data: # AssetTypes.URI_FILE # AssetTypes.URI_FOLDER # AssetTypes.MLTABLE # Possible Paths for Data: # Blob: https://<account_name>.blob.core.windows.net/<container_name>/<folder>/<file> # Datastore: azureml://datastores/paths/<folder>/<file> # Data Asset: azureml:<my_data>:<version> my_job_inputs = { "raw_data": Input(type=AssetTypes.URI_FOLDER, path="<path>") } my_job_outputs = { "prep_data": Output(type=AssetTypes.URI_FOLDER, path="<path>") } job = command( code="./src", # local path where the code is stored command="python process_data.py --raw_data ${{inputs.raw_data}} --prep_data ${{outputs.prep_data}}", inputs=my_job_inputs, outputs=my_job_outputs, environment="<environment_name>:<version>", compute="cpu-cluster", ) # submit the command returned_job = ml_client.create_or_update(job) # get a URL for the status of the job returned_job.services["Studio"].endpoint
SDK v1 및 SDK v2의 주요 기능 매핑
SDK v1의 기능 | SDK v2의 대략적인 매핑 |
---|---|
SDK v1의 메서드/API | SDK v2의 메서드/API |
다음 단계
자세한 내용은 다음 설명서를 참조하세요.