OJ Sales Simulated

이 데이터 세트는 Dominick의 OJ 데이터 세트에서 파생된 것이며, Azure Machine Learning에서 수천 개의 모델을 동시에 학습시킬 수 있는 시뮬레이션된 추가 데이터를 포함합니다.

참고 항목

Microsoft는 Azure Open Datasets를 “있는 그대로” 제공합니다. Microsoft는 귀하의 데이터 세트 사용과 관련하여 어떠한 명시적이거나 묵시적인 보증, 보장 또는 조건을 제공하지 않습니다. 귀하가 거주하는 지역의 법규가 허용하는 범위 내에서 Microsoft는 귀하의 데이터 세트 사용으로 인해 발생하는 일체의 직접적, 결과적, 특별, 간접적, 부수적 또는 징벌적 손해 또는 손실을 비롯한 모든 손해 또는 손실에 대한 모든 책임을 부인합니다.

이 데이터 세트는 Microsoft가 원본 데이터를 받은 원래 사용 약관에 따라 제공됩니다. 데이터 세트에는 Microsoft가 제공한 데이터가 포함될 수 있습니다.

데이터에는 121주 동안의 오렌지 주스 주간 판매가 포함됩니다. 포함된 상점 수가 3,991개이고 상점당 오렌지 주스 브랜드가 3개이므로 11,973개 모델을 학습시킬 수 있습니다.

원래 데이터 집합 설명을 보거나 데이터 세트를 다운로드합니다.

이름 데이터 형식 고유한 값(샘플) 설명
Advert int 1 해당 주 동안 오렌지 주스에 대한 광고가 없는지 여부를 나타내는 값입니다. 0: 광고 없음 1: 광고
브랜드 string dominicks tropicana 오렌지 주스 브랜드
가격 double 2.6 2.09 오렌지 주스 가격(USD)
수량 int 10939 11638 해당 주에 판매된 오렌지 주스의 수량
매출 double 38438.4 36036.0 해당 주의 오렌지 주스 판매 수익(USD)
저장 int 2658 1396 오렌지 주스가 판매된 상점 번호
WeekStarting timestamp 1990-08-09 00:00:00 1992-02-20 00:00:00 판매가 관련된 주를 나타내는 데이터

미리 보기를

WeekStarting 저장 브랜드 수량 Advert 가격 매출
10/1/1992 12:00:00 AM 3571 minute.maid 13247 1 2.42 32057.74
10/1/1992 12:00:00 AM 2999 minute.maid 18461 1 2.69 49660.09
10/1/1992 12:00:00 AM 1198 minute.maid 13222 1 2.64 34906.08
10/1/1992 12:00:00 AM 3916 minute.maid 12923 1 2.45 31661.35
10/1/1992 12:00:00 AM 1688 minute.maid 9380 1 2.46 23074.8
10/1/1992 12:00:00 AM 1040 minute.maid 18841 1 2.31 43522.71
10/1/1992 12:00:00 AM 1938 minute.maid 14202 1 2.19 31102.38
10/1/1992 12:00:00 AM 2405 minute.maid 16326 1 2.05 33468.3
10/1/1992 12:00:00 AM 1972 minute.maid 16380 1 2.12 34725.6

데이터 액세스

Azure Notebooks

from azureml.core.workspace import Workspace
ws = Workspace.from_config()
datastore = ws.get_default_datastore()
from azureml.opendatasets import OjSalesSimulated

Azure Open Datasets에서 데이터 읽기

# Create a Data Directory in local path
import os

oj_sales_path = "oj_sales_data"

if not os.path.exists(oj_sales_path):
    os.mkdir(oj_sales_path)
# Pull all of the data
oj_sales_files = OjSalesSimulated.get_file_dataset()

# or pull a subset of the data
oj_sales_files = OjSalesSimulated.get_file_dataset(num_files=10)
oj_sales_files.download(oj_sales_path, overwrite=True)

개별 데이터 세트를 Blob Storage에 업로드

Blob에 데이터를 업로드하고 이 csv 파일 폴더에서 FileDataset를 만듭니다.

target_path = 'oj_sales_data'

datastore.upload(src_dir = oj_sales_path,
                target_path = target_path,
                overwrite = True, 
                show_progress = True)

파일 데이터 세트 만들기

FileDataset를 만들려면 데이터의 경로를 정의해야 합니다.

from azureml.core.dataset import Dataset

ds_name = 'oj_data'
path_on_datastore = datastore.path(target_path + '/')

input_ds = Dataset.File.from_files(path=path_on_datastore, validate=False)

작업 영역에 파일 데이터 세트 등록

데이터 세트를 예측을 위해 파이프라인에 입력으로 호출할 수 있도록 작업 영역에 데이터 세트를 등록하려고 합니다.

registered_ds = input_ds.register(ws, ds_name, create_new_version=True)
named_ds = registered_ds.as_named_input(ds_name)

Azure Databricks

# This is a package in preview.
# You need to pip install azureml-opendatasets in Databricks cluster. https://learn.microsoft.com/azure/data-explorer/connect-from-databricks#install-the-python-library-on-your-azure-databricks-cluster
# Download or mount OJ Sales raw files Azure Machine Learning file datasets.
# This works only for Linux based compute. See https://learn.microsoft.com/azure/machine-learning/service/how-to-create-register-datasets to learn more about datasets.

from azureml.opendatasets import OjSalesSimulated

ojss_file = OjSalesSimulated.get_file_dataset()
ojss_file
ojss_file.to_path()
# Download files to local storage
import os
import tempfile

mount_point = tempfile.mkdtemp()
ojss_file.download(mount_point, overwrite=True)
# Mount files. Useful when training job will run on a remote compute.
import gzip
import struct
import pandas as pd
import numpy as np

# load compressed OJ Sales Simulated gz files and return numpy arrays
def load_data(filename, label=False):
    with gzip.open(filename) as gz:
        gz.read(4)
        n_items = struct.unpack('>I', gz.read(4))
        if not label:
            n_rows = struct.unpack('>I', gz.read(4))[0]
            n_cols = struct.unpack('>I', gz.read(4))[0]
            res = np.frombuffer(gz.read(n_items[0] * n_rows * n_cols), dtype=np.uint8)
            res = res.reshape(n_items[0], n_rows * n_cols)
        else:
            res = np.frombuffer(gz.read(n_items[0]), dtype=np.uint8)
            res = res.reshape(n_items[0], 1)
    return pd.DataFrame(res)
import sys
mount_point = tempfile.mkdtemp()
print(mount_point)
print(os.path.exists(mount_point))
print(os.listdir(mount_point))

if sys.platform == 'linux':
  print("start mounting....")
  with ojss_file.mount(mount_point):
    print(os.listdir(mount_point))  
    train_images_df = load_data(os.path.join(mount_point, 'train-tabular-oj-ubyte.gz'))
    print(train_images_df.info())

다음 단계

Open Datasets 카탈로그에서 나머지 데이터 세트를 봅니다.