BinaryLoaderSaverCatalog.LoadFromBinary 메서드

정의

오버로드

LoadFromBinary(DataOperationsCatalog, IMultiStreamSource)

IDataView 이진 파일에서 IMultiStreamSource 로드합니다. IDataView'는 지연되므로 여기서는 실제 로드가 발생하지 않고 스키마 유효성 검사만 수행합니다.

LoadFromBinary(DataOperationsCatalog, String)

IDataView 이진 파일에서 로드합니다. IDataView'는 지연되므로 여기서는 실제 로드가 발생하지 않고 스키마 유효성 검사만 수행합니다.

LoadFromBinary(DataOperationsCatalog, IMultiStreamSource)

IDataView 이진 파일에서 IMultiStreamSource 로드합니다. IDataView'는 지연되므로 여기서는 실제 로드가 발생하지 않고 스키마 유효성 검사만 수행합니다.

public static Microsoft.ML.IDataView LoadFromBinary (this Microsoft.ML.DataOperationsCatalog catalog, Microsoft.ML.Data.IMultiStreamSource fileSource);
static member LoadFromBinary : Microsoft.ML.DataOperationsCatalog * Microsoft.ML.Data.IMultiStreamSource -> Microsoft.ML.IDataView
<Extension()>
Public Function LoadFromBinary (catalog As DataOperationsCatalog, fileSource As IMultiStreamSource) As IDataView

매개 변수

catalog
DataOperationsCatalog

카탈로그입니다.

fileSource
IMultiStreamSource

로드할 파일 원본입니다. 예를 들어 이 작업은 다음과 MultiFileSource같습니다.

반환

적용 대상

LoadFromBinary(DataOperationsCatalog, String)

IDataView 이진 파일에서 로드합니다. IDataView'는 지연되므로 여기서는 실제 로드가 발생하지 않고 스키마 유효성 검사만 수행합니다.

public static Microsoft.ML.IDataView LoadFromBinary (this Microsoft.ML.DataOperationsCatalog catalog, string path);
static member LoadFromBinary : Microsoft.ML.DataOperationsCatalog * string -> Microsoft.ML.IDataView
<Extension()>
Public Function LoadFromBinary (catalog As DataOperationsCatalog, path As String) As IDataView

매개 변수

catalog
DataOperationsCatalog

카탈로그입니다.

path
String

로드할 파일의 경로입니다.

반환

예제

using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.ML;

namespace Samples.Dynamic
{
    public static class SaveAndLoadFromBinary
    {
        public static void Example()
        {
            // Create a new context for ML.NET operations. It can be used for
            // exception tracking and logging, as a catalog of available operations
            // and as the source of randomness. Setting the seed to a fixed number
            // in this example to make outputs deterministic.
            var mlContext = new MLContext(seed: 0);

            // Create a list of training data points.
            var dataPoints = new List<DataPoint>()
            {
                new DataPoint(){ Label = 0, Features = 4},
                new DataPoint(){ Label = 0, Features = 5},
                new DataPoint(){ Label = 0, Features = 6},
                new DataPoint(){ Label = 1, Features = 8},
                new DataPoint(){ Label = 1, Features = 9},
            };

            // Convert the list of data points to an IDataView object, which is
            // consumable by ML.NET API.
            IDataView data = mlContext.Data.LoadFromEnumerable(dataPoints);

            // Create a FileStream object and write the IDataView to it as a binary
            // IDV file. 
            using (FileStream stream = new FileStream("data.idv", FileMode.Create))
                mlContext.Data.SaveAsBinary(data, stream);

            // Create an IDataView object by loading the binary IDV file.
            IDataView loadedData = mlContext.Data.LoadFromBinary("data.idv");

            // Inspect the data that is loaded from the previously saved binary file
            var loadedDataEnumerable = mlContext.Data
                .CreateEnumerable<DataPoint>(loadedData, reuseRowObject: false);

            foreach (DataPoint row in loadedDataEnumerable)
                Console.WriteLine($"{row.Label}, {row.Features}");

            // Preview of the loaded data.
            // 0, 4
            // 0, 5
            // 0, 6
            // 1, 8
            // 1, 9
        }

        // Example with label and feature values. A data set is a collection of such
        // examples.
        private class DataPoint
        {
            public float Label { get; set; }

            public float Features { get; set; }
        }
    }
}

적용 대상