Skip to content
1 change: 1 addition & 0 deletions ZBaselines/Common/EntryPoints/core_ep-list.tsv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Data.DataViewReference Pass dataview from memory to experiment Microsoft.ML.Runtime.EntryPoints.InMemoryDataView ImportData Microsoft.ML.Runtime.EntryPoints.InMemoryDataView+Input Microsoft.ML.Runtime.EntryPoints.InMemoryDataView+Output
Data.IDataViewArrayConverter Create and array variable Microsoft.ML.Runtime.EntryPoints.CrossValidationBinaryMacro MakeArray Microsoft.ML.Runtime.EntryPoints.CrossValidationBinaryMacro+ArrayIDataViewInput Microsoft.ML.Runtime.EntryPoints.CrossValidationBinaryMacro+ArrayIDataViewOutput
Data.PredictorModelArrayConverter Create and array variable Microsoft.ML.Runtime.EntryPoints.CrossValidationBinaryMacro MakeArray Microsoft.ML.Runtime.EntryPoints.CrossValidationBinaryMacro+ArrayIPredictorModelInput Microsoft.ML.Runtime.EntryPoints.CrossValidationBinaryMacro+ArrayIPredictorModelOutput
Data.TextLoader Import a dataset from a text file Microsoft.ML.Runtime.EntryPoints.ImportTextData ImportText Microsoft.ML.Runtime.EntryPoints.ImportTextData+Input Microsoft.ML.Runtime.EntryPoints.ImportTextData+Output
Expand Down
26 changes: 26 additions & 0 deletions ZBaselines/Common/EntryPoints/core_manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
{
"EntryPoints": [
{
"Name": "Data.DataViewReference",
"Desc": "Pass dataview from memory to experiment",
"FriendlyName": null,
"ShortName": null,
"Inputs": [
{
"Name": "Data",
"Type": "DataView",
"Desc": "Pointer to IDataView in memory",
"Aliases": [
"data"
],
"Required": true,
"SortOrder": 1.0,
"IsNullable": false
}
],
"Outputs": [
{
"Name": "Data",
"Type": "DataView",
"Desc": "The resulting data view"
}
]
},
{
"Name": "Data.IDataViewArrayConverter",
"Desc": "Create and array variable",
Expand Down
28 changes: 28 additions & 0 deletions src/Microsoft.ML/CSharpApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,22 @@ public Microsoft.ML.Data.TextLoader.Output Add(Microsoft.ML.Data.TextLoader inpu
return output;
}

public Microsoft.ML.Data.DataViewReference.Output Add(Microsoft.ML.Data.DataViewReference input)
{
var output = new Microsoft.ML.Data.DataViewReference.Output();
Add(input, output);
return output;
}

public void Add(Microsoft.ML.Data.TextLoader input, Microsoft.ML.Data.TextLoader.Output output)
{
_jsonNodes.Add(Serialize("Data.TextLoader", input, output));
}

public void Add(Microsoft.ML.Data.DataViewReference input, Microsoft.ML.Data.DataViewReference.Output output)
{
_jsonNodes.Add(Serialize("Data.DataViewReference", input, output));
}
public Microsoft.ML.Models.AnomalyDetectionEvaluator.Output Add(Microsoft.ML.Models.AnomalyDetectionEvaluator input)
{
var output = new Microsoft.ML.Models.AnomalyDetectionEvaluator.Output();
Expand Down Expand Up @@ -1311,6 +1322,23 @@ public sealed partial class TextLoader
public string CustomSchema { get; set; }


public sealed class Output
{
/// <summary>
/// The resulting data view
/// </summary>
public Var<Microsoft.ML.Runtime.Data.IDataView> Data { get; set; } = new Var<Microsoft.ML.Runtime.Data.IDataView>();

}
}

public sealed partial class DataViewReference
{
/// <summary>
/// Location of the input file
/// </summary>
public Var<Microsoft.ML.Runtime.Data.IDataView> Data { get; set; } = new Var<Microsoft.ML.Runtime.Data.IDataView>();

public sealed class Output
{
/// <summary>
Expand Down
95 changes: 95 additions & 0 deletions src/Microsoft.ML/MemoryCollection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// 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.Collections.Generic;
using Microsoft.ML.Runtime;
using Microsoft.ML.Runtime.Api;
using Microsoft.ML.Runtime.Data;
using Microsoft.ML.Runtime.EntryPoints;
using Microsoft.ML.Runtime.Internal.Utilities;

namespace Microsoft.ML

@glebuk glebuk May 10, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.ML [](start = 19, length = 3)

ML.Data #Closed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TextLoader is part of just ML, should I change it as well?


In reply to: 187221578 [](ancestors = 187221578)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good question... seems they both should be in data. the argument went about like this - can a user has out of the box experience with just ML namespace.
I guess we can keep it in ML for now.


In reply to: 187221799 [](ancestors = 187221799,187221578)

@codemzs codemzs May 11, 2018

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move to Data. My PR will move TextLoader to ML.Data. #Resolved

{
public class MemoryCollection

@glebuk glebuk May 10, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MemoryCollection [](start = 17, length = 16)

Is this a static class? Why does it exist at all? Seems like a very strange name for a class #Closed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a helper class, see comment from Tom starting from "Just an observation".


In reply to: 187222326 [](ancestors = 187222326)

@glebuk glebuk May 10, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you have that static method on the MemoryCollectionLoader? If it must be a different class vs the MemoryCollectionLoader then can you define a MemoryCollectionLoader with no generic type arg?


In reply to: 187222607 [](ancestors = 187222607,187222326)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MemoryCollectionLoader is a generic class. Whole point to not type class twice. MemoryCollectionLoader.Create(Listdata) and MemoryCollection.Create(Listdata).


In reply to: 187223070 [](ancestors = 187223070,187222607,187222326)

@glebuk glebuk May 10, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the create method anyway? What's wrong with a good old constructor? Text loader does not have one.


In reply to: 187223445 [](ancestors = 187223445,187223070,187222607,187222326)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For problem with "good old constructor," see earlier comment from the aforementioned Tom on "Just an observation." The more we can rely on the compiler to do the work for the user, the better, I'd say. Especially since this is merely a wrapper anyway, I don't see the point of making the user's job any harder than it has to be.


In reply to: 187226013 [](ancestors = 187226013,187223445,187223070,187222607,187222326)

@glebuk glebuk May 10, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we must, then lest's just create a non-generic class with the same name as the generic class, make it static and have it contain those create methods. No need to pollute namespace with different confusing names.


In reply to: 187230636 [](ancestors = 187230636,187226013,187223445,187223070,187222607,187222326)

@TomFinley TomFinley May 10, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly I'd rather just not expose the implementations at all, have the static create methods return an object of the appropriate interface. I don't think anything is gained by exposing them.


In reply to: 187240158 [](ancestors = 187240158,187230636,187226013,187223445,187223070,187222607,187222326)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather just not expose the implementations at all, have the static create methods return an object of the appropriate interface
Done.


In reply to: 187352180 [](ancestors = 187352180,187240158,187230636,187226013,187223445,187223070,187222607,187222326)

{
/// <summary>
/// Creates memory collection loader.

@glebuk glebuk May 10, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loader [](start = 38, length = 6)

loader from IList #Closed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that not obvious from the parameter type? Perhaps adding a "from ." or somesuch would be fine (added to both), but even that I'd say would be a bit too needlessly verbose.


In reply to: 187221474 [](ancestors = 187221474)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's confusing that it says "Collection Loader" while it takes a List . perhaps we should rename it to a ListLoader. and split away from the StreamingEnumerableLoader


In reply to: 187230849 [](ancestors = 187230849,187221474)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

User no longer see class, it just get interface, is it better?


In reply to: 187238467 [](ancestors = 187238467,187230849,187221474)

/// </summary>
public static ILearningPipelineLoader Create<T>(IList<T> data) where T : class
{
return new MemoryCollectionLoader<T>(data);
}

/// <summary>
/// Creates memory collection loader.

@glebuk glebuk May 10, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loader [](start = 38, length = 6)

loader from IEnumerable. #Closed

/// </summary>
public static ILearningPipelineLoader Create<T>(IEnumerable<T> data) where T : class
{
return new MemoryCollectionLoader<T>(data);
}


/// <summary>
/// Allows you to convert your memory collection into IDataview.
/// </summary>
/// <typeparam name="TInput"></typeparam>
private class MemoryCollectionLoader<TInput> : ILearningPipelineLoader
where TInput : class
{
public ILearningPipelineStep ApplyStep(ILearningPipelineStep previousStep, Experiment experiment)
{

@TomFinley TomFinley May 9, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ctrl-k-d, also, maybe since these are one-liners we can omit these vebose {s. #Closed

Contracts.Assert(previousStep == null);
_dataViewEntryPoint = new Data.DataViewReference();
var importOutput = experiment.Add(_dataViewEntryPoint);
return new MemoryCollectionPipelineStep(importOutput.Data);
}

private readonly IList<TInput> _listCollection;
private readonly IEnumerable<TInput> _enumerableCollection;

private Data.DataViewReference _dataViewEntryPoint;
private IDataView _dataView;

/// <summary>
/// Creates IDataview on top of collection
/// </summary>
public MemoryCollectionLoader(IList<TInput> collection)
{
Contracts.CheckParamValue(Utils.Size(collection) > 0, collection, nameof(collection), "Must be non-empty");
_listCollection = collection;
}

/// <summary>
/// Creates IDataview on top of collection
/// </summary>
public MemoryCollectionLoader(IEnumerable<TInput> collection)
{
Contracts.CheckValue(collection, nameof(collection));
_enumerableCollection = collection;

}

public void SetInput(IHostEnvironment env, Experiment experiment)
{
if (_listCollection != null)
_dataView = ComponentCreation.CreateDataView(env, _listCollection);
if (_enumerableCollection != null)
_dataView = ComponentCreation.CreateStreamingDataView(env, _enumerableCollection);
env.CheckValue(_dataView, nameof(_dataView));
experiment.SetInput(_dataViewEntryPoint.Data, _dataView);
}

private class MemoryCollectionPipelineStep : ILearningPipelineDataStep
{
public MemoryCollectionPipelineStep(Var<IDataView> data)
{
Data = data;
}

public Var<IDataView> Data { get; }
public Var<ITransformModel> Model => null;
}
}
}
}
37 changes: 37 additions & 0 deletions src/Microsoft.ML/Runtime/EntryPoints/InMemoryDataView.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// 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 Microsoft.ML.Runtime;
using Microsoft.ML.Runtime.CommandLine;
using Microsoft.ML.Runtime.Data;
using Microsoft.ML.Runtime.EntryPoints;

[assembly: LoadableClass(typeof(void), typeof(InMemoryDataView), null, typeof(SignatureEntryPointModule), "InMemoryDataView")]
namespace Microsoft.ML.Runtime.EntryPoints
{
public class InMemoryDataView

@glebuk glebuk May 10, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InMemoryDataView [](start = 17, length = 16)

Where is this being used? I don't see any references to this class in code or tests. #Closed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a entrypoint :) Data.DataViewReference it get used in MemoryCollection.cs (At least it entry point wrapper)


In reply to: 187222065 [](ancestors = 187222065)

@glebuk glebuk May 10, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, silly me as looking for "InMemoryDataView" not "Data.DataViewReference"


In reply to: 187222365 [](ancestors = 187222365,187222065)

@glebuk glebuk May 10, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InMemoryDataView [](start = 17, length = 16)

So to clarify, all this entrypoint does it turns input to output? Should we call it as such, something like a data passthrough or something?
Because in reality, does this EP cares what kind of idv is input? #Closed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it doesn't. but I wouldn't call it DataPass entrypoint either, since it allow you pass only dataview from you code to experiment, and DataViewReference is already taken by entrypoint class.
DataViewPasser?


In reply to: 187240561 [](ancestors = 187240561)

@glebuk glebuk May 14, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not DataViewReference or DataViewReferenceEp? Seems like very unrelated class name to the entrypoint name.


In reply to: 187395356 [](ancestors = 187395356,187240561)

{
public sealed class Input
{
[Argument(ArgumentType.Required, ShortName = "data", HelpText = "Pointer to IDataView in memory", SortOrder = 1)]

@TomFinley TomFinley May 11, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ShortName = "data" [](start = 45, length = 18)

Since shortname is same as longname, you can safely omit. #Resolved

public IDataView Data;
}

public sealed class Output
{
[TlcModule.Output(Desc = "The resulting data view", SortOrder = 1)]
public IDataView Data;
}

[TlcModule.EntryPoint(Name = "Data.DataViewReference", Desc = "Pass dataview from memory to experiment")]
public static Output ImportData(IHostEnvironment env, Input input)
{
Contracts.CheckValue(env, nameof(env));
var host = env.Register("DataViewReference");
env.CheckValue(input, nameof(input));
EntryPointUtils.CheckInputArgs(host, input);
return new Output { Data = input.Data };
}
}
}
3 changes: 1 addition & 2 deletions src/Microsoft.ML/TextLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,10 @@ private class TextLoaderPipelineStep : ILearningPipelineDataStep
public TextLoaderPipelineStep(Var<IDataView> data)
{
Data = data;
Model = null;
}

public Var<IDataView> Data { get; }
public Var<ITransformModel> Model { get; }
public Var<ITransformModel> Model => null;
}
}
}
Loading