forked from dotnet/machinelearning
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIDataLoader.cs
More file actions
105 lines (90 loc) · 3.76 KB
/
Copy pathIDataLoader.cs
File metadata and controls
105 lines (90 loc) · 3.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.IO;
using Microsoft.ML.Model;
namespace Microsoft.ML.Data
{
/// <summary>
/// An interface for exposing some number of items that can be opened for reading.
/// REVIEW: Reconcile this with the functionality exposed by IHostEnvironment. For example,
/// we could simply replace this with an array of IFileHandle.
/// </summary>
public interface IMultiStreamSource
{
/// <summary>
/// Gets the number of items.
/// </summary>
int Count { get; }
/// <summary>
/// Return a string representing the "path" to the index'th stream. May return null.
/// </summary>
string GetPathOrNull(int index);
/// <summary>
/// Opens the indicated item and returns a readable stream on it.
/// </summary>
Stream Open(int index);
/// <summary>
/// Opens the indicated item and returns a text stream reader on it.
/// REVIEW: Consider making this an extension method.
/// </summary>
TextReader OpenTextReader(int index);
}
/// <summary>
/// Signature for creating an <see cref="IDataLoader"/>.
/// </summary>
public delegate void SignatureDataLoader(IMultiStreamSource data);
/// <summary>
/// Signature for loading an <see cref="IDataLoader"/>.
/// </summary>
public delegate void SignatureLoadDataLoader(ModelLoadContext ctx, IMultiStreamSource data);
/// <summary>
/// Interface for a data loader. An <see cref="IDataLoader"/> can save its model information
/// and is instantiatable from arguments and an <see cref="IMultiStreamSource"/> .
/// </summary>
public interface IDataLoader : IDataView, ICanSaveModel
{
}
public delegate void SignatureDataSaver();
public interface IDataSaver
{
/// <summary>
/// Check if the column can be saved.
/// </summary>
/// <returns>True if the column is savable.</returns>
bool IsColumnSavable(ColumnType type);
/// <summary>
/// Save the data into the given stream. The stream should be kept open.
/// </summary>
/// <param name="stream">The stream that the data will be written.</param>
/// <param name="data">The data to be saved.</param>
/// <param name="cols">The list of column indices to be saved.</param>
void SaveData(Stream stream, IDataView data, params int[] cols);
}
/// <summary>
/// Signature for creating an <see cref="IDataTransform"/>.
/// </summary>
public delegate void SignatureDataTransform(IDataView input);
/// <summary>
/// Signature for loading an <see cref="IDataTransform"/>.
/// </summary>
public delegate void SignatureLoadDataTransform(ModelLoadContext ctx, IDataView input);
/// <summary>
/// Interface for a data transform. An <see cref="IDataTransform"/> can save its model information
/// and is instantiatable from arguments and an input <see cref="IDataView"/>.
/// </summary>
public interface IDataTransform : IDataView, ICanSaveModel
{
IDataView Source { get; }
}
/// <summary>
/// Data transforms need to be able to apply themselves to a different input IDataView.
/// This interface allows them to implement custom rebinding logic.
/// </summary>
public interface ITransformTemplate : IDataTransform
{
// REVIEW: re-apply operation should support shallow schema modification,
// like renaming source and destination columns.
IDataTransform ApplyToData(IHostEnvironment env, IDataView newSource);
}
}