FileDatasetFactory 類別

包含建立 Azure Machine Learning 檔案資料集的方法。

FileDataset會從 from_files 這個類別中定義的 方法建立 。

如需使用檔案資料集的詳細資訊,請參閱筆記本 https://aka.ms/filedataset-samplenotebook

繼承
builtins.object
FileDatasetFactory

建構函式

FileDatasetFactory()

方法

from_files

建立 FileDataset 來代表檔案資料流程。

upload_directory

從來原始目錄建立資料集。

from_files

建立 FileDataset 來代表檔案資料流程。

static from_files(path, validate=True, partition_format=None, is_file=False)

參數

path
Union[str, list[str], DataPath, list[DataPath], (Datastore, str), list[(Datastore, str)]]
必要

原始程式檔的路徑,可以是單一值或 url 字串清單, (HTTP[s]|abfs[s]|wasb[s]) 、 DataPath 物件或 tuple Datastore 和相對路徑。 請注意,路徑清單不能同時包含 URL 和資料存放區。

validate
bool
必要

指出是否要驗證是否可以從傳回的資料集載入資料。 預設值為 True。 驗證要求資料來源可從目前的計算存取。

partition_format
str
必要

指定路徑的資料分割格式。 預設為 [無]。 每個路徑的資料分割資訊都會根據指定的格式擷取到資料行中。 格式部分 '{column_name}' 會建立字串資料行,而 '{column_name:yyyy/MM/dd/HH/mm/ss}' 會建立 datetime 資料行,其中 'yyyy'、'MM'、'dd'、'HH'、'mm' 和 'ss' 用來擷取日期時間類型的年、月、日、小時、分鐘和秒。 格式應該從第一個分割區索引鍵的位置開始,直到檔案路徑的結尾為止。 例如,假設路徑為 '.。/Accounts/2019/01/01/data.jsonl',其中分割區是依部門名稱和時間, partition_format='/{Department}/{PartitionDate:yyyy/MM/dd}/data.jsonl' 會建立值為 'Accounts' 的字串資料行 'Department',而 datetime 資料行 'PartitionDate' 值為 '2019-01-01'。

is_file
bool
必要

指出所有輸入路徑是否指向檔案。 根據預設,資料集引擎會嘗試檢查輸入路徑是否指向檔案。 當所有輸入路徑都是 [檔案] 以加速建立資料集時,請將此旗標設定為 True。

傳回

FileDataset 物件。

傳回類型

備註

from_files 會建立 類別的物件 FileDataset ,該物件會定義從提供的路徑載入檔案資料流程的作業。

若要讓 Azure Machine Learning 存取的資料,所 path 指定的檔案必須位於 Datastore 中,或是可透過 Blob、ADLS Gen1 和 ADLS Gen2 的公用 Web URL 或 URL 來存取。

如果使用者的 AAD 權杖直接呼叫下列其中一個函式,則會在 Notebook 或本機 Python 程式中使用:FileDataset.mount FileDataset.download FileDataset.to_path TabularDataset.to_pandas_dataframe TabularDataset.to_dask_dataframe TabularDataset.to_spark_dataframe TabularDataset.to_parquet_files TabularDataset.to_csv_files Experiment.submit 針對資料存取驗證提交的工作中,將會使用計算目標的身分識別。 深入了解:https://aka.ms/data-access


   from azureml.core import Dataset, Datastore

   # create file dataset from a single file in datastore
   datastore = Datastore.get(workspace, 'workspaceblobstore')
   file_dataset_1 = Dataset.File.from_files(path=(datastore,'image/dog.jpg'))

   # create file dataset from a single directory in datastore
   file_dataset_2 = Dataset.File.from_files(path=(datastore, 'image/'))

   # create file dataset from all jpeg files in the directory
   file_dataset_3 = Dataset.File.from_files(path=(datastore,'image/**/*.jpg'))

   # create filedataset from multiple paths
   data_paths = [(datastore, 'image/dog.jpg'), (datastore, 'image/cat.jpg')]
   file_dataset_4 = Dataset.File.from_files(path=data_paths)

   # create file dataset from url
   file_dataset_5 = Dataset.File.from_files(path='https://url/image/cat.jpg')

upload_directory

從來原始目錄建立資料集。

static upload_directory(src_dir, target, pattern=None, overwrite=False, show_progress=True)

參數

src_dir
str
必要

要上傳的本機目錄。

target
Union[DataPath, Datastore, tuple(Datastore, str)]
必要

必要資料存放區路徑,檔案將會上傳至其中。

pattern
str
必要

選擇性的 If provided, will filter all the path names matching the given pattern, similar to Python glob package, supporting '*', '?', and character ranges expresseds with []。

show_progress
bool
必要

選擇性,指出是否要在主控台中顯示上傳的進度。 預設值為 True。

傳回

已註冊的資料集。

傳回類型