CollectionDataSource (train on top of memory collection instead of loading data from file) - #106

Merged
Ivanidzo4ka merged 16 commits into
dotnet:masterfrom
Ivanidzo4ka:ivanidze/in_memory_loader
May 15, 2018
Merged

CollectionDataSource (train on top of memory collection instead of loading data from file)#106
Ivanidzo4ka merged 16 commits into
dotnet:masterfrom
Ivanidzo4ka:ivanidze/in_memory_loader

Conversation

@Ivanidzo4ka

@Ivanidzo4kaIvanidzo4ka commented May 9, 2018

Copy link
Copy Markdown
Contributor

First iteration which allows user to create IDataview on top of IList or Enumerable and infrastructure to add it in pipeline.
address #10 issue

@Ivanidzo4ka

Ivanidzo4ka commented May 9, 2018

Copy link
Copy Markdown
ContributorAuthor

@GalOshri@glebuk I would appreciate your contribution regarding class names. #Resolved

@Ivanidzo4kaIvanidzo4ka self-assigned this May 9, 2018
@Ivanidzo4kaIvanidzo4ka added the enhancement New feature or request label May 9, 2018
Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
public void SetInput(IHostEnvironment env, Experiment experiment)
{
if (_listCollection!=null)
{

@TomFinleyTomFinleyMay 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

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated

public MemoryCollection(IList<TInput> collection)
{
//need validation at some point

@TomFinleyTomFinleyMay 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.

//need validation at some point [](start = 12, length = 31)

How about we at least validate to ensure that these aren't null, with a Contracts.CheckParamValue? Here and in the other constructor. #Closed

@shauheenshauheen added this to the 0518 milestone May 9, 2018
/// A helper class to create data views based on the user-provided types.
/// </summary>
internal static class DataViewConstructionUtils
public static class DataViewConstructionUtils

@TomFinleyTomFinleyMay 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.

public static class DataViewConstructionUtils [](start = 4, length = 45)

This makes me nervous... If you make this public rather than internal, then it is no longer appropriate to have what are currently Asserts on the public methods. They'll have to be Checks, with suitably verbose error messages, properly called in the context of env, and so on, and so on. This is more work than I think you want to have right now.

Do you need all of the functions in this class? This was originally a supporting utility class for the pre-ML.NET API. You don't need all of it... in fact I think you only need a couple of them. I might choose to either (1) introduce another public class with the methods you need being accessible through that or (2) change this class so that it remains public but everything in it has its access member changed to internal, except the one or two facilities you actually need. #Closed

@Ivanidzo4kaIvanidzo4kaMay 9, 2018

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Oh, I miss these blobs of text so much. (I'm serious right now) #Closed

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Someone already did that for me. All I had to do is to look for method reference :)


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

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.

Thanks Ivan, it's nice to be appreciated. :D :D


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

@TomFinley
TomFinley requested a review from eerhardtMay 9, 2018 23:24
/// An internal class that holds the (already validated) mapping between a custom type and an IDataView schema.
/// </summary>
internal sealed class InternalSchemaDefinition
public sealed class InternalSchemaDefinition

@TomFinleyTomFinleyMay 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.

public sealed class InternalSchemaDefinition [](start = 4, length = 44)

I have similar concerns about this class being public. If we can avoid it, possibly by moving some of the logic current in MemoryCollection.cs to this assembly, then calling that from the Microsoft.ML project, I'd be delighted. #Closed

@Ivanidzo4ka

Ivanidzo4ka commented May 9, 2018

Copy link
Copy Markdown
ContributorAuthor

using Microsoft.ML.Data;

need header #Resolved


Refers to: src/Microsoft.ML/Runtime/EntryPoints/DataViewReference.cs:1 in b166f05. [](commit_id = b166f05, deletion_comment = False)

@Ivanidzo4ka

Ivanidzo4ka commented May 9, 2018

Copy link
Copy Markdown
ContributorAuthor

using System;

need header #Resolved


Refers to: src/Microsoft.ML/MemoryCollection.cs:1 in b166f05. [](commit_id = b166f05, deletion_comment = False)

Experiment experiment = environment.CreateExperiment();
ILearningPipelineDataStep output = collection.ApplyStep(null, experiment) as ILearningPipelineDataStep;

Assert.NotNull(output.Data);

@TomFinleyTomFinleyMay 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.

Assert.NotNull(output.Data); [](start = 16, length = 28)

If you really meant the as above, you should first Assert.NonNull on output. If you didn't mean the as above, then you should do a direct () style cast to ILearningPipelineDataStep. The only reason to use an as style cast is if you are entertaining the possibility that it might not implement that interface, in which case, given that this is a test, you should test that. (And if it wasn't a test, you would Contracts.Check* it.) #Closed

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
private Data.DataViewReference _dataViewEntryPoint;
private IDataView _dataView;

public MemoryCollection(IList<TInput> collection)

@Ivanidzo4kaIvanidzo4kaMay 9, 2018

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

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

public constructor required comments. #Resolved

internal static class DataViewConstructionUtils
public static class DataViewConstructionUtils
{
public static IDataView CreateFromList<TRow>(IHostEnvironment env, IList<TRow> data,

@Ivanidzo4kaIvanidzo4kaMay 9, 2018

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

IList [](start = 75, length = 5)

Since we in this file, @tfinley@gmail.com do you have any opinion about IList?
I would personally convert it to List. #Resolved

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 there a reason why you would prefer List here?

So the reason I would prefer a specific implementer of an interface rather than the interface itself is to avoid having to go through the virtual function table. (Which is why it's often better to write Foo<TBar>(TBar biz) where TBar : IBar vs. Foo(IBar biz).) In this specific case though, I don't think it's worth it. You're ultimately going to be dealing with an IEnumerator<TRow>anyway for most operations on this structure, and there it's unfortunately unavoidable, so I care a bit less. But perhaps there's something to this I'm not appreciating.


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

@Ivanidzo4kaIvanidzo4kaMay 10, 2018

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I guess its just personal. I just don't like IList. In same time, IList allow you to pass Arrays, so this solve problem with Array support.


In reply to: 187207615 [](ancestors = 187207615,187205023)

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated

public MemoryCollection(IEnumerable<TInput> collection)
{
Contracts.CheckParamValue(collection != null, collection, nameof(collection), "Must be non-null");

@TomFinleyTomFinleyMay 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.

CheckParamValue(collection != null, collection [](start = 22, length = 46)

I'm sorry, I'm silly... I didn't mean CheckParamValue, I meant CheckValue. That'll simplify this a bit. #Closed

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
public MemoryCollectionPipelineStep(Var<IDataView> data)
{
Data = data;
Model = null;

@TomFinleyTomFinleyMay 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.

Unnecessary, the default value is null.

That's fine, but I'd go one step further... What I'd do is change the public Var<ITransformModel> Model { get; } below to public Var<ITransformModel> Model => null;, that way you avoid having any backing field whatsoever. (Plus you save three characters, which totally makes it worth it. :D ) #Closed

[Fact]
public void CanSuccessfullyApplyATransform()
{
var collection = new MemoryCollection<Input>(new List<Input>() { new Input { Number1 = 1, String1 = "1" } });

@TomFinleyTomFinleyMay 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.

MemoryCollection [](start = 33, length = 23)

Just an observation... if we had instead structured this as a static utility method somewhere, then we could avoid having the double-specification of the Input class, as it would have been inferred by the compiler.

So: if we had a input type MyAwesomeInputType, then instead of MemoryCollection<MyAwesomeInputType>(new MyAwesomeInputType[] {...}), we would have MemoryCollection.Create(new MyAwesomeInputType[] {...}) since the compiler could have done the work of inferring the type and whatnot. #Closed

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
public class MemoryCollection
{
/// <summary>
/// Creates memory collection loader.

@glebukglebukMay 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
ContributorAuthor

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)

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
}

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

@glebukglebukMay 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

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
using Microsoft.ML.Runtime.EntryPoints;
using Microsoft.ML.Runtime.Internal.Utilities;

namespace Microsoft.ML

@glebukglebukMay 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
ContributorAuthor

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)

@codemzscodemzsMay 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

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

@glebukglebukMay 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
ContributorAuthor

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)

@glebukglebukMay 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 commented May 11, 2018

Copy link
Copy Markdown
Contributor

Sorry, indeed I meant to add a different Eric!


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


namespace Microsoft.ML.Data
{
public class CollectionLoader

@TomFinleyTomFinleyMay 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.

public class [](start = 4, length = 12)

Static class #Closed

@Ivanidzo4kaIvanidzo4ka changed the title In memory loader (train on top of memory collection instead of loading data from file)CollectionDataSource (train on top of memory collection instead of loading data from file)May 11, 2018
@Ivanidzo4ka

Ivanidzo4ka commented May 11, 2018

Copy link
Copy Markdown
ContributorAuthor

@dotnet-bot test Windows_NT Release please

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

@TomFinleyTomFinleyMay 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

@TomFinleyTomFinley left a comment

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.

:shipit:

new IrisData { SepalLength = 1f, SepalWidth = 1f ,PetalLength=0.3f, PetalWidth=5.1f, Label=1},
new IrisData { SepalLength = 1.2f, SepalWidth = 0.5f ,PetalLength=0.3f, PetalWidth=5.1f, Label=0}
};
var collection = CollectionDataSource.Create(data);

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.

Would we address the inconsistency in naming/usage between CollectionDataSource and TextLoader in a separate PR? We want it to be clearer these are the two (current) approaches to bringing data into a LearningPipeline.

@shauheenshauheen removed this from the 0518 milestone May 14, 2018
@Ivanidzo4ka

Ivanidzo4ka commented May 14, 2018

Copy link
Copy Markdown
ContributorAuthor

@glebuk is this review still in blocking state? If yes, what should be process of API review? #Closed

@glebuk

Copy link
Copy Markdown
Contributor

let me review it. Just give me 20 minutes.


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


namespace Microsoft.ML.Data
{
public static class CollectionDataSource

@glebukglebukMay 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.

CollectionDataSource [](start = 24, length = 20)

Please add a top level XML help - what is this class, where does it use, what's the purpose for its existance? #Closed

@glebuk

Copy link
Copy Markdown
Contributor

done. please look at 2 new comments


In reply to: 388992391 [](ancestors = 388992391,388913155)

@glebukglebuk left a comment

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.

:shipit:

@Ivanidzo4ka

Copy link
Copy Markdown
ContributorAuthor

@dotnet-bot test OSX10.13 Debug please

@glebukglebuk left a comment

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.

:shipit:

@Ivanidzo4ka
Ivanidzo4ka merged commit 6d5a41d into dotnet:masterMay 15, 2018
@Ivanidzo4ka
Ivanidzo4ka deleted the ivanidze/in_memory_loader branch May 15, 2018 00:26
@ntaherkhani

Copy link
Copy Markdown

"CollectionDataSource" is not recognized in my project.
"The name 'CollectionDataSource' does not exist in the current context" .
may somebody help me please.
Also, May please put some samples for other types of data loading except using "TextLoader". I need some samples to add data to pipeline from "DataTable".
Thanks.

@Ivanidzo4ka

Ivanidzo4ka commented May 23, 2018

Copy link
Copy Markdown
ContributorAuthor

@ntaherkhani Changes in this PR would be part of 0.2 release. Currently on nuget.org you can find only 0.1 release. You can consume nuget with current master branch from myget: https://dotnet.myget.org/F/dotnet-core/api/v3/index.json
Check "Include prerelease" in VS and search for Microsoft.ML package.

eerhardt pushed a commit to eerhardt/machinelearning that referenced this pull request Jul 27, 2018
…ading data from file) (dotnet#106)
* in memory loader
* add test file for memory collection
* even in afterlife EntryPointCatalog will chase me down.
* Address some comments.
* update tests
* address more comments.
* remove empty param description
* hide collectionloader
* refactor classes a little.
* pesky new lines!
* slightly better comments. but only slighty
* rename it
* make class static
* not a loader
* remove alias in entrypoint
* address comments
@ghostghost locked as resolved and limited conversation to collaborators Mar 31, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancementNew feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

@Ivanidzo4ka@glebuk@erier@ntaherkhani@codemzs@GalOshri@eerhardt@TomFinley@shauheen
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

CollectionDataSource (train on top of memory collection instead of loading data from file) - #106

Merged
Ivanidzo4ka merged 16 commits into
dotnet:masterfrom
Ivanidzo4ka:ivanidze/in_memory_loader
May 15, 2018
Merged

CollectionDataSource (train on top of memory collection instead of loading data from file)#106
Ivanidzo4ka merged 16 commits into
dotnet:masterfrom
Ivanidzo4ka:ivanidze/in_memory_loader

Conversation

@Ivanidzo4ka

@Ivanidzo4kaIvanidzo4ka commented May 9, 2018

Copy link
Copy Markdown
Contributor

First iteration which allows user to create IDataview on top of IList or Enumerable and infrastructure to add it in pipeline.
address #10 issue

@Ivanidzo4ka

Ivanidzo4ka commented May 9, 2018

Copy link
Copy Markdown
ContributorAuthor

@GalOshri@glebuk I would appreciate your contribution regarding class names. #Resolved

@Ivanidzo4kaIvanidzo4ka self-assigned this May 9, 2018
@Ivanidzo4kaIvanidzo4ka added the enhancement New feature or request label May 9, 2018
Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
public void SetInput(IHostEnvironment env, Experiment experiment)
{
if (_listCollection!=null)
{

@TomFinleyTomFinleyMay 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

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated

public MemoryCollection(IList<TInput> collection)
{
//need validation at some point

@TomFinleyTomFinleyMay 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.

//need validation at some point [](start = 12, length = 31)

How about we at least validate to ensure that these aren't null, with a Contracts.CheckParamValue? Here and in the other constructor. #Closed

@shauheenshauheen added this to the 0518 milestone May 9, 2018
/// A helper class to create data views based on the user-provided types.
/// </summary>
internal static class DataViewConstructionUtils
public static class DataViewConstructionUtils

@TomFinleyTomFinleyMay 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.

public static class DataViewConstructionUtils [](start = 4, length = 45)

This makes me nervous... If you make this public rather than internal, then it is no longer appropriate to have what are currently Asserts on the public methods. They'll have to be Checks, with suitably verbose error messages, properly called in the context of env, and so on, and so on. This is more work than I think you want to have right now.

Do you need all of the functions in this class? This was originally a supporting utility class for the pre-ML.NET API. You don't need all of it... in fact I think you only need a couple of them. I might choose to either (1) introduce another public class with the methods you need being accessible through that or (2) change this class so that it remains public but everything in it has its access member changed to internal, except the one or two facilities you actually need. #Closed

@Ivanidzo4kaIvanidzo4kaMay 9, 2018

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Oh, I miss these blobs of text so much. (I'm serious right now) #Closed

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Someone already did that for me. All I had to do is to look for method reference :)


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

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.

Thanks Ivan, it's nice to be appreciated. :D :D


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

@TomFinley
TomFinley requested a review from eerhardtMay 9, 2018 23:24
/// An internal class that holds the (already validated) mapping between a custom type and an IDataView schema.
/// </summary>
internal sealed class InternalSchemaDefinition
public sealed class InternalSchemaDefinition

@TomFinleyTomFinleyMay 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.

public sealed class InternalSchemaDefinition [](start = 4, length = 44)

I have similar concerns about this class being public. If we can avoid it, possibly by moving some of the logic current in MemoryCollection.cs to this assembly, then calling that from the Microsoft.ML project, I'd be delighted. #Closed

@Ivanidzo4ka

Ivanidzo4ka commented May 9, 2018

Copy link
Copy Markdown
ContributorAuthor

using Microsoft.ML.Data;

need header #Resolved


Refers to: src/Microsoft.ML/Runtime/EntryPoints/DataViewReference.cs:1 in b166f05. [](commit_id = b166f05, deletion_comment = False)

@Ivanidzo4ka

Ivanidzo4ka commented May 9, 2018

Copy link
Copy Markdown
ContributorAuthor

using System;

need header #Resolved


Refers to: src/Microsoft.ML/MemoryCollection.cs:1 in b166f05. [](commit_id = b166f05, deletion_comment = False)

Experiment experiment = environment.CreateExperiment();
ILearningPipelineDataStep output = collection.ApplyStep(null, experiment) as ILearningPipelineDataStep;

Assert.NotNull(output.Data);

@TomFinleyTomFinleyMay 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.

Assert.NotNull(output.Data); [](start = 16, length = 28)

If you really meant the as above, you should first Assert.NonNull on output. If you didn't mean the as above, then you should do a direct () style cast to ILearningPipelineDataStep. The only reason to use an as style cast is if you are entertaining the possibility that it might not implement that interface, in which case, given that this is a test, you should test that. (And if it wasn't a test, you would Contracts.Check* it.) #Closed

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
private Data.DataViewReference _dataViewEntryPoint;
private IDataView _dataView;

public MemoryCollection(IList<TInput> collection)

@Ivanidzo4kaIvanidzo4kaMay 9, 2018

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

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

public constructor required comments. #Resolved

internal static class DataViewConstructionUtils
public static class DataViewConstructionUtils
{
public static IDataView CreateFromList<TRow>(IHostEnvironment env, IList<TRow> data,

@Ivanidzo4kaIvanidzo4kaMay 9, 2018

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

IList [](start = 75, length = 5)

Since we in this file, @tfinley@gmail.com do you have any opinion about IList?
I would personally convert it to List. #Resolved

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 there a reason why you would prefer List here?

So the reason I would prefer a specific implementer of an interface rather than the interface itself is to avoid having to go through the virtual function table. (Which is why it's often better to write Foo<TBar>(TBar biz) where TBar : IBar vs. Foo(IBar biz).) In this specific case though, I don't think it's worth it. You're ultimately going to be dealing with an IEnumerator<TRow>anyway for most operations on this structure, and there it's unfortunately unavoidable, so I care a bit less. But perhaps there's something to this I'm not appreciating.


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

@Ivanidzo4kaIvanidzo4kaMay 10, 2018

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I guess its just personal. I just don't like IList. In same time, IList allow you to pass Arrays, so this solve problem with Array support.


In reply to: 187207615 [](ancestors = 187207615,187205023)

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated

public MemoryCollection(IEnumerable<TInput> collection)
{
Contracts.CheckParamValue(collection != null, collection, nameof(collection), "Must be non-null");

@TomFinleyTomFinleyMay 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.

CheckParamValue(collection != null, collection [](start = 22, length = 46)

I'm sorry, I'm silly... I didn't mean CheckParamValue, I meant CheckValue. That'll simplify this a bit. #Closed

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
public MemoryCollectionPipelineStep(Var<IDataView> data)
{
Data = data;
Model = null;

@TomFinleyTomFinleyMay 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.

Unnecessary, the default value is null.

That's fine, but I'd go one step further... What I'd do is change the public Var<ITransformModel> Model { get; } below to public Var<ITransformModel> Model => null;, that way you avoid having any backing field whatsoever. (Plus you save three characters, which totally makes it worth it. :D ) #Closed

[Fact]
public void CanSuccessfullyApplyATransform()
{
var collection = new MemoryCollection<Input>(new List<Input>() { new Input { Number1 = 1, String1 = "1" } });

@TomFinleyTomFinleyMay 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.

MemoryCollection [](start = 33, length = 23)

Just an observation... if we had instead structured this as a static utility method somewhere, then we could avoid having the double-specification of the Input class, as it would have been inferred by the compiler.

So: if we had a input type MyAwesomeInputType, then instead of MemoryCollection<MyAwesomeInputType>(new MyAwesomeInputType[] {...}), we would have MemoryCollection.Create(new MyAwesomeInputType[] {...}) since the compiler could have done the work of inferring the type and whatnot. #Closed

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
public class MemoryCollection
{
/// <summary>
/// Creates memory collection loader.

@glebukglebukMay 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
ContributorAuthor

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)

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
}

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

@glebukglebukMay 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

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
using Microsoft.ML.Runtime.EntryPoints;
using Microsoft.ML.Runtime.Internal.Utilities;

namespace Microsoft.ML

@glebukglebukMay 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
ContributorAuthor

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)

@codemzscodemzsMay 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

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

@glebukglebukMay 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
ContributorAuthor

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)

@glebukglebukMay 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 commented May 11, 2018

Copy link
Copy Markdown
Contributor

Sorry, indeed I meant to add a different Eric!


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


namespace Microsoft.ML.Data
{
public class CollectionLoader

@TomFinleyTomFinleyMay 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.

public class [](start = 4, length = 12)

Static class #Closed

@Ivanidzo4kaIvanidzo4ka changed the title In memory loader (train on top of memory collection instead of loading data from file)CollectionDataSource (train on top of memory collection instead of loading data from file)May 11, 2018
@Ivanidzo4ka

Ivanidzo4ka commented May 11, 2018

Copy link
Copy Markdown
ContributorAuthor

@dotnet-bot test Windows_NT Release please

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

@TomFinleyTomFinleyMay 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

@TomFinleyTomFinley left a comment

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.

:shipit:

new IrisData { SepalLength = 1f, SepalWidth = 1f ,PetalLength=0.3f, PetalWidth=5.1f, Label=1},
new IrisData { SepalLength = 1.2f, SepalWidth = 0.5f ,PetalLength=0.3f, PetalWidth=5.1f, Label=0}
};
var collection = CollectionDataSource.Create(data);

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.

Would we address the inconsistency in naming/usage between CollectionDataSource and TextLoader in a separate PR? We want it to be clearer these are the two (current) approaches to bringing data into a LearningPipeline.

@shauheenshauheen removed this from the 0518 milestone May 14, 2018
@Ivanidzo4ka

Ivanidzo4ka commented May 14, 2018

Copy link
Copy Markdown
ContributorAuthor

@glebuk is this review still in blocking state? If yes, what should be process of API review? #Closed

@glebuk

Copy link
Copy Markdown
Contributor

let me review it. Just give me 20 minutes.


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


namespace Microsoft.ML.Data
{
public static class CollectionDataSource

@glebukglebukMay 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.

CollectionDataSource [](start = 24, length = 20)

Please add a top level XML help - what is this class, where does it use, what's the purpose for its existance? #Closed

@glebuk

Copy link
Copy Markdown
Contributor

done. please look at 2 new comments


In reply to: 388992391 [](ancestors = 388992391,388913155)

@glebukglebuk left a comment

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.

:shipit:

@Ivanidzo4ka

Copy link
Copy Markdown
ContributorAuthor

@dotnet-bot test OSX10.13 Debug please

@glebukglebuk left a comment

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.

:shipit:

@Ivanidzo4ka
Ivanidzo4ka merged commit 6d5a41d into dotnet:masterMay 15, 2018
@Ivanidzo4ka
Ivanidzo4ka deleted the ivanidze/in_memory_loader branch May 15, 2018 00:26
@ntaherkhani

Copy link
Copy Markdown

"CollectionDataSource" is not recognized in my project.
"The name 'CollectionDataSource' does not exist in the current context" .
may somebody help me please.
Also, May please put some samples for other types of data loading except using "TextLoader". I need some samples to add data to pipeline from "DataTable".
Thanks.

@Ivanidzo4ka

Ivanidzo4ka commented May 23, 2018

Copy link
Copy Markdown
ContributorAuthor

@ntaherkhani Changes in this PR would be part of 0.2 release. Currently on nuget.org you can find only 0.1 release. You can consume nuget with current master branch from myget: https://dotnet.myget.org/F/dotnet-core/api/v3/index.json
Check "Include prerelease" in VS and search for Microsoft.ML package.

eerhardt pushed a commit to eerhardt/machinelearning that referenced this pull request Jul 27, 2018
…ading data from file) (dotnet#106)
* in memory loader
* add test file for memory collection
* even in afterlife EntryPointCatalog will chase me down.
* Address some comments.
* update tests
* address more comments.
* remove empty param description
* hide collectionloader
* refactor classes a little.
* pesky new lines!
* slightly better comments. but only slighty
* rename it
* make class static
* not a loader
* remove alias in entrypoint
* address comments
@ghostghost locked as resolved and limited conversation to collaborators Mar 31, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancementNew feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

@Ivanidzo4ka@glebuk@erier@ntaherkhani@codemzs@GalOshri@eerhardt@TomFinley@shauheen
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

CollectionDataSource (train on top of memory collection instead of loading data from file) - #106

Merged
Ivanidzo4ka merged 16 commits into
dotnet:masterfrom
Ivanidzo4ka:ivanidze/in_memory_loader
May 15, 2018
Merged

CollectionDataSource (train on top of memory collection instead of loading data from file)#106
Ivanidzo4ka merged 16 commits into
dotnet:masterfrom
Ivanidzo4ka:ivanidze/in_memory_loader

Conversation

@Ivanidzo4ka

@Ivanidzo4kaIvanidzo4ka commented May 9, 2018

Copy link
Copy Markdown
Contributor

First iteration which allows user to create IDataview on top of IList or Enumerable and infrastructure to add it in pipeline.
address #10 issue

@Ivanidzo4ka

Ivanidzo4ka commented May 9, 2018

Copy link
Copy Markdown
ContributorAuthor

@GalOshri@glebuk I would appreciate your contribution regarding class names. #Resolved

@Ivanidzo4kaIvanidzo4ka self-assigned this May 9, 2018
@Ivanidzo4kaIvanidzo4ka added the enhancement New feature or request label May 9, 2018
Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
public void SetInput(IHostEnvironment env, Experiment experiment)
{
if (_listCollection!=null)
{

@TomFinleyTomFinleyMay 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

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated

public MemoryCollection(IList<TInput> collection)
{
//need validation at some point

@TomFinleyTomFinleyMay 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.

//need validation at some point [](start = 12, length = 31)

How about we at least validate to ensure that these aren't null, with a Contracts.CheckParamValue? Here and in the other constructor. #Closed

@shauheenshauheen added this to the 0518 milestone May 9, 2018
/// A helper class to create data views based on the user-provided types.
/// </summary>
internal static class DataViewConstructionUtils
public static class DataViewConstructionUtils

@TomFinleyTomFinleyMay 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.

public static class DataViewConstructionUtils [](start = 4, length = 45)

This makes me nervous... If you make this public rather than internal, then it is no longer appropriate to have what are currently Asserts on the public methods. They'll have to be Checks, with suitably verbose error messages, properly called in the context of env, and so on, and so on. This is more work than I think you want to have right now.

Do you need all of the functions in this class? This was originally a supporting utility class for the pre-ML.NET API. You don't need all of it... in fact I think you only need a couple of them. I might choose to either (1) introduce another public class with the methods you need being accessible through that or (2) change this class so that it remains public but everything in it has its access member changed to internal, except the one or two facilities you actually need. #Closed

@Ivanidzo4kaIvanidzo4kaMay 9, 2018

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Oh, I miss these blobs of text so much. (I'm serious right now) #Closed

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Someone already did that for me. All I had to do is to look for method reference :)


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

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.

Thanks Ivan, it's nice to be appreciated. :D :D


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

@TomFinley
TomFinley requested a review from eerhardtMay 9, 2018 23:24
/// An internal class that holds the (already validated) mapping between a custom type and an IDataView schema.
/// </summary>
internal sealed class InternalSchemaDefinition
public sealed class InternalSchemaDefinition

@TomFinleyTomFinleyMay 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.

public sealed class InternalSchemaDefinition [](start = 4, length = 44)

I have similar concerns about this class being public. If we can avoid it, possibly by moving some of the logic current in MemoryCollection.cs to this assembly, then calling that from the Microsoft.ML project, I'd be delighted. #Closed

@Ivanidzo4ka

Ivanidzo4ka commented May 9, 2018

Copy link
Copy Markdown
ContributorAuthor

using Microsoft.ML.Data;

need header #Resolved


Refers to: src/Microsoft.ML/Runtime/EntryPoints/DataViewReference.cs:1 in b166f05. [](commit_id = b166f05, deletion_comment = False)

@Ivanidzo4ka

Ivanidzo4ka commented May 9, 2018

Copy link
Copy Markdown
ContributorAuthor

using System;

need header #Resolved


Refers to: src/Microsoft.ML/MemoryCollection.cs:1 in b166f05. [](commit_id = b166f05, deletion_comment = False)

Experiment experiment = environment.CreateExperiment();
ILearningPipelineDataStep output = collection.ApplyStep(null, experiment) as ILearningPipelineDataStep;

Assert.NotNull(output.Data);

@TomFinleyTomFinleyMay 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.

Assert.NotNull(output.Data); [](start = 16, length = 28)

If you really meant the as above, you should first Assert.NonNull on output. If you didn't mean the as above, then you should do a direct () style cast to ILearningPipelineDataStep. The only reason to use an as style cast is if you are entertaining the possibility that it might not implement that interface, in which case, given that this is a test, you should test that. (And if it wasn't a test, you would Contracts.Check* it.) #Closed

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
private Data.DataViewReference _dataViewEntryPoint;
private IDataView _dataView;

public MemoryCollection(IList<TInput> collection)

@Ivanidzo4kaIvanidzo4kaMay 9, 2018

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

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

public constructor required comments. #Resolved

internal static class DataViewConstructionUtils
public static class DataViewConstructionUtils
{
public static IDataView CreateFromList<TRow>(IHostEnvironment env, IList<TRow> data,

@Ivanidzo4kaIvanidzo4kaMay 9, 2018

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

IList [](start = 75, length = 5)

Since we in this file, @tfinley@gmail.com do you have any opinion about IList?
I would personally convert it to List. #Resolved

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 there a reason why you would prefer List here?

So the reason I would prefer a specific implementer of an interface rather than the interface itself is to avoid having to go through the virtual function table. (Which is why it's often better to write Foo<TBar>(TBar biz) where TBar : IBar vs. Foo(IBar biz).) In this specific case though, I don't think it's worth it. You're ultimately going to be dealing with an IEnumerator<TRow>anyway for most operations on this structure, and there it's unfortunately unavoidable, so I care a bit less. But perhaps there's something to this I'm not appreciating.


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

@Ivanidzo4kaIvanidzo4kaMay 10, 2018

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I guess its just personal. I just don't like IList. In same time, IList allow you to pass Arrays, so this solve problem with Array support.


In reply to: 187207615 [](ancestors = 187207615,187205023)

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated

public MemoryCollection(IEnumerable<TInput> collection)
{
Contracts.CheckParamValue(collection != null, collection, nameof(collection), "Must be non-null");

@TomFinleyTomFinleyMay 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.

CheckParamValue(collection != null, collection [](start = 22, length = 46)

I'm sorry, I'm silly... I didn't mean CheckParamValue, I meant CheckValue. That'll simplify this a bit. #Closed

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
public MemoryCollectionPipelineStep(Var<IDataView> data)
{
Data = data;
Model = null;

@TomFinleyTomFinleyMay 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.

Unnecessary, the default value is null.

That's fine, but I'd go one step further... What I'd do is change the public Var<ITransformModel> Model { get; } below to public Var<ITransformModel> Model => null;, that way you avoid having any backing field whatsoever. (Plus you save three characters, which totally makes it worth it. :D ) #Closed

[Fact]
public void CanSuccessfullyApplyATransform()
{
var collection = new MemoryCollection<Input>(new List<Input>() { new Input { Number1 = 1, String1 = "1" } });

@TomFinleyTomFinleyMay 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.

MemoryCollection [](start = 33, length = 23)

Just an observation... if we had instead structured this as a static utility method somewhere, then we could avoid having the double-specification of the Input class, as it would have been inferred by the compiler.

So: if we had a input type MyAwesomeInputType, then instead of MemoryCollection<MyAwesomeInputType>(new MyAwesomeInputType[] {...}), we would have MemoryCollection.Create(new MyAwesomeInputType[] {...}) since the compiler could have done the work of inferring the type and whatnot. #Closed

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
public class MemoryCollection
{
/// <summary>
/// Creates memory collection loader.

@glebukglebukMay 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
ContributorAuthor

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)

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
}

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

@glebukglebukMay 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

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
using Microsoft.ML.Runtime.EntryPoints;
using Microsoft.ML.Runtime.Internal.Utilities;

namespace Microsoft.ML

@glebukglebukMay 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
ContributorAuthor

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)

@codemzscodemzsMay 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

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

@glebukglebukMay 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
ContributorAuthor

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)

@glebukglebukMay 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 commented May 11, 2018

Copy link
Copy Markdown
Contributor

Sorry, indeed I meant to add a different Eric!


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


namespace Microsoft.ML.Data
{
public class CollectionLoader

@TomFinleyTomFinleyMay 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.

public class [](start = 4, length = 12)

Static class #Closed

@Ivanidzo4kaIvanidzo4ka changed the title In memory loader (train on top of memory collection instead of loading data from file)CollectionDataSource (train on top of memory collection instead of loading data from file)May 11, 2018
@Ivanidzo4ka

Ivanidzo4ka commented May 11, 2018

Copy link
Copy Markdown
ContributorAuthor

@dotnet-bot test Windows_NT Release please

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

@TomFinleyTomFinleyMay 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

@TomFinleyTomFinley left a comment

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.

:shipit:

new IrisData { SepalLength = 1f, SepalWidth = 1f ,PetalLength=0.3f, PetalWidth=5.1f, Label=1},
new IrisData { SepalLength = 1.2f, SepalWidth = 0.5f ,PetalLength=0.3f, PetalWidth=5.1f, Label=0}
};
var collection = CollectionDataSource.Create(data);

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.

Would we address the inconsistency in naming/usage between CollectionDataSource and TextLoader in a separate PR? We want it to be clearer these are the two (current) approaches to bringing data into a LearningPipeline.

@shauheenshauheen removed this from the 0518 milestone May 14, 2018
@Ivanidzo4ka

Ivanidzo4ka commented May 14, 2018

Copy link
Copy Markdown
ContributorAuthor

@glebuk is this review still in blocking state? If yes, what should be process of API review? #Closed

@glebuk

Copy link
Copy Markdown
Contributor

let me review it. Just give me 20 minutes.


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


namespace Microsoft.ML.Data
{
public static class CollectionDataSource

@glebukglebukMay 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.

CollectionDataSource [](start = 24, length = 20)

Please add a top level XML help - what is this class, where does it use, what's the purpose for its existance? #Closed

@glebuk

Copy link
Copy Markdown
Contributor

done. please look at 2 new comments


In reply to: 388992391 [](ancestors = 388992391,388913155)

@glebukglebuk left a comment

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.

:shipit:

@Ivanidzo4ka

Copy link
Copy Markdown
ContributorAuthor

@dotnet-bot test OSX10.13 Debug please

@glebukglebuk left a comment

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.

:shipit:

@Ivanidzo4ka
Ivanidzo4ka merged commit 6d5a41d into dotnet:masterMay 15, 2018
@Ivanidzo4ka
Ivanidzo4ka deleted the ivanidze/in_memory_loader branch May 15, 2018 00:26
@ntaherkhani

Copy link
Copy Markdown

"CollectionDataSource" is not recognized in my project.
"The name 'CollectionDataSource' does not exist in the current context" .
may somebody help me please.
Also, May please put some samples for other types of data loading except using "TextLoader". I need some samples to add data to pipeline from "DataTable".
Thanks.

@Ivanidzo4ka

Ivanidzo4ka commented May 23, 2018

Copy link
Copy Markdown
ContributorAuthor

@ntaherkhani Changes in this PR would be part of 0.2 release. Currently on nuget.org you can find only 0.1 release. You can consume nuget with current master branch from myget: https://dotnet.myget.org/F/dotnet-core/api/v3/index.json
Check "Include prerelease" in VS and search for Microsoft.ML package.

eerhardt pushed a commit to eerhardt/machinelearning that referenced this pull request Jul 27, 2018
…ading data from file) (dotnet#106)
* in memory loader
* add test file for memory collection
* even in afterlife EntryPointCatalog will chase me down.
* Address some comments.
* update tests
* address more comments.
* remove empty param description
* hide collectionloader
* refactor classes a little.
* pesky new lines!
* slightly better comments. but only slighty
* rename it
* make class static
* not a loader
* remove alias in entrypoint
* address comments
@ghostghost locked as resolved and limited conversation to collaborators Mar 31, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancementNew feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

@Ivanidzo4ka@glebuk@erier@ntaherkhani@codemzs@GalOshri@eerhardt@TomFinley@shauheen
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

CollectionDataSource (train on top of memory collection instead of loading data from file) - #106

Merged
Ivanidzo4ka merged 16 commits into
dotnet:masterfrom
Ivanidzo4ka:ivanidze/in_memory_loader
May 15, 2018
Merged

CollectionDataSource (train on top of memory collection instead of loading data from file)#106
Ivanidzo4ka merged 16 commits into
dotnet:masterfrom
Ivanidzo4ka:ivanidze/in_memory_loader

Conversation

@Ivanidzo4ka

@Ivanidzo4kaIvanidzo4ka commented May 9, 2018

Copy link
Copy Markdown
Contributor

First iteration which allows user to create IDataview on top of IList or Enumerable and infrastructure to add it in pipeline.
address #10 issue

@Ivanidzo4ka

Ivanidzo4ka commented May 9, 2018

Copy link
Copy Markdown
ContributorAuthor

@GalOshri@glebuk I would appreciate your contribution regarding class names. #Resolved

@Ivanidzo4kaIvanidzo4ka self-assigned this May 9, 2018
@Ivanidzo4kaIvanidzo4ka added the enhancement New feature or request label May 9, 2018
Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
public void SetInput(IHostEnvironment env, Experiment experiment)
{
if (_listCollection!=null)
{

@TomFinleyTomFinleyMay 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

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated

public MemoryCollection(IList<TInput> collection)
{
//need validation at some point

@TomFinleyTomFinleyMay 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.

//need validation at some point [](start = 12, length = 31)

How about we at least validate to ensure that these aren't null, with a Contracts.CheckParamValue? Here and in the other constructor. #Closed

@shauheenshauheen added this to the 0518 milestone May 9, 2018
/// A helper class to create data views based on the user-provided types.
/// </summary>
internal static class DataViewConstructionUtils
public static class DataViewConstructionUtils

@TomFinleyTomFinleyMay 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.

public static class DataViewConstructionUtils [](start = 4, length = 45)

This makes me nervous... If you make this public rather than internal, then it is no longer appropriate to have what are currently Asserts on the public methods. They'll have to be Checks, with suitably verbose error messages, properly called in the context of env, and so on, and so on. This is more work than I think you want to have right now.

Do you need all of the functions in this class? This was originally a supporting utility class for the pre-ML.NET API. You don't need all of it... in fact I think you only need a couple of them. I might choose to either (1) introduce another public class with the methods you need being accessible through that or (2) change this class so that it remains public but everything in it has its access member changed to internal, except the one or two facilities you actually need. #Closed

@Ivanidzo4kaIvanidzo4kaMay 9, 2018

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Oh, I miss these blobs of text so much. (I'm serious right now) #Closed

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Someone already did that for me. All I had to do is to look for method reference :)


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

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.

Thanks Ivan, it's nice to be appreciated. :D :D


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

@TomFinley
TomFinley requested a review from eerhardtMay 9, 2018 23:24
/// An internal class that holds the (already validated) mapping between a custom type and an IDataView schema.
/// </summary>
internal sealed class InternalSchemaDefinition
public sealed class InternalSchemaDefinition

@TomFinleyTomFinleyMay 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.

public sealed class InternalSchemaDefinition [](start = 4, length = 44)

I have similar concerns about this class being public. If we can avoid it, possibly by moving some of the logic current in MemoryCollection.cs to this assembly, then calling that from the Microsoft.ML project, I'd be delighted. #Closed

@Ivanidzo4ka

Ivanidzo4ka commented May 9, 2018

Copy link
Copy Markdown
ContributorAuthor

using Microsoft.ML.Data;

need header #Resolved


Refers to: src/Microsoft.ML/Runtime/EntryPoints/DataViewReference.cs:1 in b166f05. [](commit_id = b166f05, deletion_comment = False)

@Ivanidzo4ka

Ivanidzo4ka commented May 9, 2018

Copy link
Copy Markdown
ContributorAuthor

using System;

need header #Resolved


Refers to: src/Microsoft.ML/MemoryCollection.cs:1 in b166f05. [](commit_id = b166f05, deletion_comment = False)

Experiment experiment = environment.CreateExperiment();
ILearningPipelineDataStep output = collection.ApplyStep(null, experiment) as ILearningPipelineDataStep;

Assert.NotNull(output.Data);

@TomFinleyTomFinleyMay 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.

Assert.NotNull(output.Data); [](start = 16, length = 28)

If you really meant the as above, you should first Assert.NonNull on output. If you didn't mean the as above, then you should do a direct () style cast to ILearningPipelineDataStep. The only reason to use an as style cast is if you are entertaining the possibility that it might not implement that interface, in which case, given that this is a test, you should test that. (And if it wasn't a test, you would Contracts.Check* it.) #Closed

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
private Data.DataViewReference _dataViewEntryPoint;
private IDataView _dataView;

public MemoryCollection(IList<TInput> collection)

@Ivanidzo4kaIvanidzo4kaMay 9, 2018

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

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

public constructor required comments. #Resolved

internal static class DataViewConstructionUtils
public static class DataViewConstructionUtils
{
public static IDataView CreateFromList<TRow>(IHostEnvironment env, IList<TRow> data,

@Ivanidzo4kaIvanidzo4kaMay 9, 2018

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

IList [](start = 75, length = 5)

Since we in this file, @tfinley@gmail.com do you have any opinion about IList?
I would personally convert it to List. #Resolved

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 there a reason why you would prefer List here?

So the reason I would prefer a specific implementer of an interface rather than the interface itself is to avoid having to go through the virtual function table. (Which is why it's often better to write Foo<TBar>(TBar biz) where TBar : IBar vs. Foo(IBar biz).) In this specific case though, I don't think it's worth it. You're ultimately going to be dealing with an IEnumerator<TRow>anyway for most operations on this structure, and there it's unfortunately unavoidable, so I care a bit less. But perhaps there's something to this I'm not appreciating.


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

@Ivanidzo4kaIvanidzo4kaMay 10, 2018

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I guess its just personal. I just don't like IList. In same time, IList allow you to pass Arrays, so this solve problem with Array support.


In reply to: 187207615 [](ancestors = 187207615,187205023)

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated

public MemoryCollection(IEnumerable<TInput> collection)
{
Contracts.CheckParamValue(collection != null, collection, nameof(collection), "Must be non-null");

@TomFinleyTomFinleyMay 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.

CheckParamValue(collection != null, collection [](start = 22, length = 46)

I'm sorry, I'm silly... I didn't mean CheckParamValue, I meant CheckValue. That'll simplify this a bit. #Closed

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
public MemoryCollectionPipelineStep(Var<IDataView> data)
{
Data = data;
Model = null;

@TomFinleyTomFinleyMay 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.

Unnecessary, the default value is null.

That's fine, but I'd go one step further... What I'd do is change the public Var<ITransformModel> Model { get; } below to public Var<ITransformModel> Model => null;, that way you avoid having any backing field whatsoever. (Plus you save three characters, which totally makes it worth it. :D ) #Closed

[Fact]
public void CanSuccessfullyApplyATransform()
{
var collection = new MemoryCollection<Input>(new List<Input>() { new Input { Number1 = 1, String1 = "1" } });

@TomFinleyTomFinleyMay 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.

MemoryCollection [](start = 33, length = 23)

Just an observation... if we had instead structured this as a static utility method somewhere, then we could avoid having the double-specification of the Input class, as it would have been inferred by the compiler.

So: if we had a input type MyAwesomeInputType, then instead of MemoryCollection<MyAwesomeInputType>(new MyAwesomeInputType[] {...}), we would have MemoryCollection.Create(new MyAwesomeInputType[] {...}) since the compiler could have done the work of inferring the type and whatnot. #Closed

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
public class MemoryCollection
{
/// <summary>
/// Creates memory collection loader.

@glebukglebukMay 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
ContributorAuthor

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)

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
}

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

@glebukglebukMay 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

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
using Microsoft.ML.Runtime.EntryPoints;
using Microsoft.ML.Runtime.Internal.Utilities;

namespace Microsoft.ML

@glebukglebukMay 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
ContributorAuthor

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)

@codemzscodemzsMay 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

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

@glebukglebukMay 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
ContributorAuthor

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)

@glebukglebukMay 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 commented May 11, 2018

Copy link
Copy Markdown
Contributor

Sorry, indeed I meant to add a different Eric!


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


namespace Microsoft.ML.Data
{
public class CollectionLoader

@TomFinleyTomFinleyMay 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.

public class [](start = 4, length = 12)

Static class #Closed

@Ivanidzo4kaIvanidzo4ka changed the title In memory loader (train on top of memory collection instead of loading data from file)CollectionDataSource (train on top of memory collection instead of loading data from file)May 11, 2018
@Ivanidzo4ka

Ivanidzo4ka commented May 11, 2018

Copy link
Copy Markdown
ContributorAuthor

@dotnet-bot test Windows_NT Release please

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

@TomFinleyTomFinleyMay 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

@TomFinleyTomFinley left a comment

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.

:shipit:

new IrisData { SepalLength = 1f, SepalWidth = 1f ,PetalLength=0.3f, PetalWidth=5.1f, Label=1},
new IrisData { SepalLength = 1.2f, SepalWidth = 0.5f ,PetalLength=0.3f, PetalWidth=5.1f, Label=0}
};
var collection = CollectionDataSource.Create(data);

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.

Would we address the inconsistency in naming/usage between CollectionDataSource and TextLoader in a separate PR? We want it to be clearer these are the two (current) approaches to bringing data into a LearningPipeline.

@shauheenshauheen removed this from the 0518 milestone May 14, 2018
@Ivanidzo4ka

Ivanidzo4ka commented May 14, 2018

Copy link
Copy Markdown
ContributorAuthor

@glebuk is this review still in blocking state? If yes, what should be process of API review? #Closed

@glebuk

Copy link
Copy Markdown
Contributor

let me review it. Just give me 20 minutes.


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


namespace Microsoft.ML.Data
{
public static class CollectionDataSource

@glebukglebukMay 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.

CollectionDataSource [](start = 24, length = 20)

Please add a top level XML help - what is this class, where does it use, what's the purpose for its existance? #Closed

@glebuk

Copy link
Copy Markdown
Contributor

done. please look at 2 new comments


In reply to: 388992391 [](ancestors = 388992391,388913155)

@glebukglebuk left a comment

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.

:shipit:

@Ivanidzo4ka

Copy link
Copy Markdown
ContributorAuthor

@dotnet-bot test OSX10.13 Debug please

@glebukglebuk left a comment

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.

:shipit:

@Ivanidzo4ka
Ivanidzo4ka merged commit 6d5a41d into dotnet:masterMay 15, 2018
@Ivanidzo4ka
Ivanidzo4ka deleted the ivanidze/in_memory_loader branch May 15, 2018 00:26
@ntaherkhani

Copy link
Copy Markdown

"CollectionDataSource" is not recognized in my project.
"The name 'CollectionDataSource' does not exist in the current context" .
may somebody help me please.
Also, May please put some samples for other types of data loading except using "TextLoader". I need some samples to add data to pipeline from "DataTable".
Thanks.

@Ivanidzo4ka

Ivanidzo4ka commented May 23, 2018

Copy link
Copy Markdown
ContributorAuthor

@ntaherkhani Changes in this PR would be part of 0.2 release. Currently on nuget.org you can find only 0.1 release. You can consume nuget with current master branch from myget: https://dotnet.myget.org/F/dotnet-core/api/v3/index.json
Check "Include prerelease" in VS and search for Microsoft.ML package.

eerhardt pushed a commit to eerhardt/machinelearning that referenced this pull request Jul 27, 2018
…ading data from file) (dotnet#106)
* in memory loader
* add test file for memory collection
* even in afterlife EntryPointCatalog will chase me down.
* Address some comments.
* update tests
* address more comments.
* remove empty param description
* hide collectionloader
* refactor classes a little.
* pesky new lines!
* slightly better comments. but only slighty
* rename it
* make class static
* not a loader
* remove alias in entrypoint
* address comments
@ghostghost locked as resolved and limited conversation to collaborators Mar 31, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancementNew feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

@Ivanidzo4ka@glebuk@erier@ntaherkhani@codemzs@GalOshri@eerhardt@TomFinley@shauheen
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

CollectionDataSource (train on top of memory collection instead of loading data from file) - #106

Merged
Ivanidzo4ka merged 16 commits into
dotnet:masterfrom
Ivanidzo4ka:ivanidze/in_memory_loader
May 15, 2018
Merged

CollectionDataSource (train on top of memory collection instead of loading data from file)#106
Ivanidzo4ka merged 16 commits into
dotnet:masterfrom
Ivanidzo4ka:ivanidze/in_memory_loader

Conversation

@Ivanidzo4ka

@Ivanidzo4kaIvanidzo4ka commented May 9, 2018

Copy link
Copy Markdown
Contributor

First iteration which allows user to create IDataview on top of IList or Enumerable and infrastructure to add it in pipeline.
address #10 issue

@Ivanidzo4ka

Ivanidzo4ka commented May 9, 2018

Copy link
Copy Markdown
ContributorAuthor

@GalOshri@glebuk I would appreciate your contribution regarding class names. #Resolved

@Ivanidzo4kaIvanidzo4ka self-assigned this May 9, 2018
@Ivanidzo4kaIvanidzo4ka added the enhancement New feature or request label May 9, 2018
Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
public void SetInput(IHostEnvironment env, Experiment experiment)
{
if (_listCollection!=null)
{

@TomFinleyTomFinleyMay 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

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated

public MemoryCollection(IList<TInput> collection)
{
//need validation at some point

@TomFinleyTomFinleyMay 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.

//need validation at some point [](start = 12, length = 31)

How about we at least validate to ensure that these aren't null, with a Contracts.CheckParamValue? Here and in the other constructor. #Closed

@shauheenshauheen added this to the 0518 milestone May 9, 2018
/// A helper class to create data views based on the user-provided types.
/// </summary>
internal static class DataViewConstructionUtils
public static class DataViewConstructionUtils

@TomFinleyTomFinleyMay 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.

public static class DataViewConstructionUtils [](start = 4, length = 45)

This makes me nervous... If you make this public rather than internal, then it is no longer appropriate to have what are currently Asserts on the public methods. They'll have to be Checks, with suitably verbose error messages, properly called in the context of env, and so on, and so on. This is more work than I think you want to have right now.

Do you need all of the functions in this class? This was originally a supporting utility class for the pre-ML.NET API. You don't need all of it... in fact I think you only need a couple of them. I might choose to either (1) introduce another public class with the methods you need being accessible through that or (2) change this class so that it remains public but everything in it has its access member changed to internal, except the one or two facilities you actually need. #Closed

@Ivanidzo4kaIvanidzo4kaMay 9, 2018

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Oh, I miss these blobs of text so much. (I'm serious right now) #Closed

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Someone already did that for me. All I had to do is to look for method reference :)


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

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.

Thanks Ivan, it's nice to be appreciated. :D :D


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

@TomFinley
TomFinley requested a review from eerhardtMay 9, 2018 23:24
/// An internal class that holds the (already validated) mapping between a custom type and an IDataView schema.
/// </summary>
internal sealed class InternalSchemaDefinition
public sealed class InternalSchemaDefinition

@TomFinleyTomFinleyMay 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.

public sealed class InternalSchemaDefinition [](start = 4, length = 44)

I have similar concerns about this class being public. If we can avoid it, possibly by moving some of the logic current in MemoryCollection.cs to this assembly, then calling that from the Microsoft.ML project, I'd be delighted. #Closed

@Ivanidzo4ka

Ivanidzo4ka commented May 9, 2018

Copy link
Copy Markdown
ContributorAuthor

using Microsoft.ML.Data;

need header #Resolved


Refers to: src/Microsoft.ML/Runtime/EntryPoints/DataViewReference.cs:1 in b166f05. [](commit_id = b166f05, deletion_comment = False)

@Ivanidzo4ka

Ivanidzo4ka commented May 9, 2018

Copy link
Copy Markdown
ContributorAuthor

using System;

need header #Resolved


Refers to: src/Microsoft.ML/MemoryCollection.cs:1 in b166f05. [](commit_id = b166f05, deletion_comment = False)

Experiment experiment = environment.CreateExperiment();
ILearningPipelineDataStep output = collection.ApplyStep(null, experiment) as ILearningPipelineDataStep;

Assert.NotNull(output.Data);

@TomFinleyTomFinleyMay 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.

Assert.NotNull(output.Data); [](start = 16, length = 28)

If you really meant the as above, you should first Assert.NonNull on output. If you didn't mean the as above, then you should do a direct () style cast to ILearningPipelineDataStep. The only reason to use an as style cast is if you are entertaining the possibility that it might not implement that interface, in which case, given that this is a test, you should test that. (And if it wasn't a test, you would Contracts.Check* it.) #Closed

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
private Data.DataViewReference _dataViewEntryPoint;
private IDataView _dataView;

public MemoryCollection(IList<TInput> collection)

@Ivanidzo4kaIvanidzo4kaMay 9, 2018

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

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

public constructor required comments. #Resolved

internal static class DataViewConstructionUtils
public static class DataViewConstructionUtils
{
public static IDataView CreateFromList<TRow>(IHostEnvironment env, IList<TRow> data,

@Ivanidzo4kaIvanidzo4kaMay 9, 2018

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

IList [](start = 75, length = 5)

Since we in this file, @tfinley@gmail.com do you have any opinion about IList?
I would personally convert it to List. #Resolved

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 there a reason why you would prefer List here?

So the reason I would prefer a specific implementer of an interface rather than the interface itself is to avoid having to go through the virtual function table. (Which is why it's often better to write Foo<TBar>(TBar biz) where TBar : IBar vs. Foo(IBar biz).) In this specific case though, I don't think it's worth it. You're ultimately going to be dealing with an IEnumerator<TRow>anyway for most operations on this structure, and there it's unfortunately unavoidable, so I care a bit less. But perhaps there's something to this I'm not appreciating.


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

@Ivanidzo4kaIvanidzo4kaMay 10, 2018

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I guess its just personal. I just don't like IList. In same time, IList allow you to pass Arrays, so this solve problem with Array support.


In reply to: 187207615 [](ancestors = 187207615,187205023)

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated

public MemoryCollection(IEnumerable<TInput> collection)
{
Contracts.CheckParamValue(collection != null, collection, nameof(collection), "Must be non-null");

@TomFinleyTomFinleyMay 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.

CheckParamValue(collection != null, collection [](start = 22, length = 46)

I'm sorry, I'm silly... I didn't mean CheckParamValue, I meant CheckValue. That'll simplify this a bit. #Closed

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
public MemoryCollectionPipelineStep(Var<IDataView> data)
{
Data = data;
Model = null;

@TomFinleyTomFinleyMay 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.

Unnecessary, the default value is null.

That's fine, but I'd go one step further... What I'd do is change the public Var<ITransformModel> Model { get; } below to public Var<ITransformModel> Model => null;, that way you avoid having any backing field whatsoever. (Plus you save three characters, which totally makes it worth it. :D ) #Closed

[Fact]
public void CanSuccessfullyApplyATransform()
{
var collection = new MemoryCollection<Input>(new List<Input>() { new Input { Number1 = 1, String1 = "1" } });

@TomFinleyTomFinleyMay 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.

MemoryCollection [](start = 33, length = 23)

Just an observation... if we had instead structured this as a static utility method somewhere, then we could avoid having the double-specification of the Input class, as it would have been inferred by the compiler.

So: if we had a input type MyAwesomeInputType, then instead of MemoryCollection<MyAwesomeInputType>(new MyAwesomeInputType[] {...}), we would have MemoryCollection.Create(new MyAwesomeInputType[] {...}) since the compiler could have done the work of inferring the type and whatnot. #Closed

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
public class MemoryCollection
{
/// <summary>
/// Creates memory collection loader.

@glebukglebukMay 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
ContributorAuthor

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)

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
}

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

@glebukglebukMay 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

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
using Microsoft.ML.Runtime.EntryPoints;
using Microsoft.ML.Runtime.Internal.Utilities;

namespace Microsoft.ML

@glebukglebukMay 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
ContributorAuthor

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)

@codemzscodemzsMay 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

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

@glebukglebukMay 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
ContributorAuthor

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)

@glebukglebukMay 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 commented May 11, 2018

Copy link
Copy Markdown
Contributor

Sorry, indeed I meant to add a different Eric!


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


namespace Microsoft.ML.Data
{
public class CollectionLoader

@TomFinleyTomFinleyMay 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.

public class [](start = 4, length = 12)

Static class #Closed

@Ivanidzo4kaIvanidzo4ka changed the title In memory loader (train on top of memory collection instead of loading data from file)CollectionDataSource (train on top of memory collection instead of loading data from file)May 11, 2018
@Ivanidzo4ka

Ivanidzo4ka commented May 11, 2018

Copy link
Copy Markdown
ContributorAuthor

@dotnet-bot test Windows_NT Release please

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

@TomFinleyTomFinleyMay 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

@TomFinleyTomFinley left a comment

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.

:shipit:

new IrisData { SepalLength = 1f, SepalWidth = 1f ,PetalLength=0.3f, PetalWidth=5.1f, Label=1},
new IrisData { SepalLength = 1.2f, SepalWidth = 0.5f ,PetalLength=0.3f, PetalWidth=5.1f, Label=0}
};
var collection = CollectionDataSource.Create(data);

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.

Would we address the inconsistency in naming/usage between CollectionDataSource and TextLoader in a separate PR? We want it to be clearer these are the two (current) approaches to bringing data into a LearningPipeline.

@shauheenshauheen removed this from the 0518 milestone May 14, 2018
@Ivanidzo4ka

Ivanidzo4ka commented May 14, 2018

Copy link
Copy Markdown
ContributorAuthor

@glebuk is this review still in blocking state? If yes, what should be process of API review? #Closed

@glebuk

Copy link
Copy Markdown
Contributor

let me review it. Just give me 20 minutes.


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


namespace Microsoft.ML.Data
{
public static class CollectionDataSource

@glebukglebukMay 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.

CollectionDataSource [](start = 24, length = 20)

Please add a top level XML help - what is this class, where does it use, what's the purpose for its existance? #Closed

@glebuk

Copy link
Copy Markdown
Contributor

done. please look at 2 new comments


In reply to: 388992391 [](ancestors = 388992391,388913155)

@glebukglebuk left a comment

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.

:shipit:

@Ivanidzo4ka

Copy link
Copy Markdown
ContributorAuthor

@dotnet-bot test OSX10.13 Debug please

@glebukglebuk left a comment

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.

:shipit:

@Ivanidzo4ka
Ivanidzo4ka merged commit 6d5a41d into dotnet:masterMay 15, 2018
@Ivanidzo4ka
Ivanidzo4ka deleted the ivanidze/in_memory_loader branch May 15, 2018 00:26
@ntaherkhani

Copy link
Copy Markdown

"CollectionDataSource" is not recognized in my project.
"The name 'CollectionDataSource' does not exist in the current context" .
may somebody help me please.
Also, May please put some samples for other types of data loading except using "TextLoader". I need some samples to add data to pipeline from "DataTable".
Thanks.

@Ivanidzo4ka

Ivanidzo4ka commented May 23, 2018

Copy link
Copy Markdown
ContributorAuthor

@ntaherkhani Changes in this PR would be part of 0.2 release. Currently on nuget.org you can find only 0.1 release. You can consume nuget with current master branch from myget: https://dotnet.myget.org/F/dotnet-core/api/v3/index.json
Check "Include prerelease" in VS and search for Microsoft.ML package.

eerhardt pushed a commit to eerhardt/machinelearning that referenced this pull request Jul 27, 2018
…ading data from file) (dotnet#106)
* in memory loader
* add test file for memory collection
* even in afterlife EntryPointCatalog will chase me down.
* Address some comments.
* update tests
* address more comments.
* remove empty param description
* hide collectionloader
* refactor classes a little.
* pesky new lines!
* slightly better comments. but only slighty
* rename it
* make class static
* not a loader
* remove alias in entrypoint
* address comments
@ghostghost locked as resolved and limited conversation to collaborators Mar 31, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancementNew feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

@Ivanidzo4ka@glebuk@erier@ntaherkhani@codemzs@GalOshri@eerhardt@TomFinley@shauheen
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

CollectionDataSource (train on top of memory collection instead of loading data from file) - #106

Merged
Ivanidzo4ka merged 16 commits into
dotnet:masterfrom
Ivanidzo4ka:ivanidze/in_memory_loader
May 15, 2018
Merged

CollectionDataSource (train on top of memory collection instead of loading data from file)#106
Ivanidzo4ka merged 16 commits into
dotnet:masterfrom
Ivanidzo4ka:ivanidze/in_memory_loader

Conversation

@Ivanidzo4ka

@Ivanidzo4kaIvanidzo4ka commented May 9, 2018

Copy link
Copy Markdown
Contributor

First iteration which allows user to create IDataview on top of IList or Enumerable and infrastructure to add it in pipeline.
address #10 issue

@Ivanidzo4ka

Ivanidzo4ka commented May 9, 2018

Copy link
Copy Markdown
ContributorAuthor

@GalOshri@glebuk I would appreciate your contribution regarding class names. #Resolved

@Ivanidzo4kaIvanidzo4ka self-assigned this May 9, 2018
@Ivanidzo4kaIvanidzo4ka added the enhancement New feature or request label May 9, 2018
Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
public void SetInput(IHostEnvironment env, Experiment experiment)
{
if (_listCollection!=null)
{

@TomFinleyTomFinleyMay 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

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated

public MemoryCollection(IList<TInput> collection)
{
//need validation at some point

@TomFinleyTomFinleyMay 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.

//need validation at some point [](start = 12, length = 31)

How about we at least validate to ensure that these aren't null, with a Contracts.CheckParamValue? Here and in the other constructor. #Closed

@shauheenshauheen added this to the 0518 milestone May 9, 2018
/// A helper class to create data views based on the user-provided types.
/// </summary>
internal static class DataViewConstructionUtils
public static class DataViewConstructionUtils

@TomFinleyTomFinleyMay 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.

public static class DataViewConstructionUtils [](start = 4, length = 45)

This makes me nervous... If you make this public rather than internal, then it is no longer appropriate to have what are currently Asserts on the public methods. They'll have to be Checks, with suitably verbose error messages, properly called in the context of env, and so on, and so on. This is more work than I think you want to have right now.

Do you need all of the functions in this class? This was originally a supporting utility class for the pre-ML.NET API. You don't need all of it... in fact I think you only need a couple of them. I might choose to either (1) introduce another public class with the methods you need being accessible through that or (2) change this class so that it remains public but everything in it has its access member changed to internal, except the one or two facilities you actually need. #Closed

@Ivanidzo4kaIvanidzo4kaMay 9, 2018

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Oh, I miss these blobs of text so much. (I'm serious right now) #Closed

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Someone already did that for me. All I had to do is to look for method reference :)


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

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.

Thanks Ivan, it's nice to be appreciated. :D :D


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

@TomFinley
TomFinley requested a review from eerhardtMay 9, 2018 23:24
/// An internal class that holds the (already validated) mapping between a custom type and an IDataView schema.
/// </summary>
internal sealed class InternalSchemaDefinition
public sealed class InternalSchemaDefinition

@TomFinleyTomFinleyMay 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.

public sealed class InternalSchemaDefinition [](start = 4, length = 44)

I have similar concerns about this class being public. If we can avoid it, possibly by moving some of the logic current in MemoryCollection.cs to this assembly, then calling that from the Microsoft.ML project, I'd be delighted. #Closed

@Ivanidzo4ka

Ivanidzo4ka commented May 9, 2018

Copy link
Copy Markdown
ContributorAuthor

using Microsoft.ML.Data;

need header #Resolved


Refers to: src/Microsoft.ML/Runtime/EntryPoints/DataViewReference.cs:1 in b166f05. [](commit_id = b166f05, deletion_comment = False)

@Ivanidzo4ka

Ivanidzo4ka commented May 9, 2018

Copy link
Copy Markdown
ContributorAuthor

using System;

need header #Resolved


Refers to: src/Microsoft.ML/MemoryCollection.cs:1 in b166f05. [](commit_id = b166f05, deletion_comment = False)

Experiment experiment = environment.CreateExperiment();
ILearningPipelineDataStep output = collection.ApplyStep(null, experiment) as ILearningPipelineDataStep;

Assert.NotNull(output.Data);

@TomFinleyTomFinleyMay 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.

Assert.NotNull(output.Data); [](start = 16, length = 28)

If you really meant the as above, you should first Assert.NonNull on output. If you didn't mean the as above, then you should do a direct () style cast to ILearningPipelineDataStep. The only reason to use an as style cast is if you are entertaining the possibility that it might not implement that interface, in which case, given that this is a test, you should test that. (And if it wasn't a test, you would Contracts.Check* it.) #Closed

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
private Data.DataViewReference _dataViewEntryPoint;
private IDataView _dataView;

public MemoryCollection(IList<TInput> collection)

@Ivanidzo4kaIvanidzo4kaMay 9, 2018

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

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

public constructor required comments. #Resolved

internal static class DataViewConstructionUtils
public static class DataViewConstructionUtils
{
public static IDataView CreateFromList<TRow>(IHostEnvironment env, IList<TRow> data,

@Ivanidzo4kaIvanidzo4kaMay 9, 2018

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

IList [](start = 75, length = 5)

Since we in this file, @tfinley@gmail.com do you have any opinion about IList?
I would personally convert it to List. #Resolved

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 there a reason why you would prefer List here?

So the reason I would prefer a specific implementer of an interface rather than the interface itself is to avoid having to go through the virtual function table. (Which is why it's often better to write Foo<TBar>(TBar biz) where TBar : IBar vs. Foo(IBar biz).) In this specific case though, I don't think it's worth it. You're ultimately going to be dealing with an IEnumerator<TRow>anyway for most operations on this structure, and there it's unfortunately unavoidable, so I care a bit less. But perhaps there's something to this I'm not appreciating.


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

@Ivanidzo4kaIvanidzo4kaMay 10, 2018

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I guess its just personal. I just don't like IList. In same time, IList allow you to pass Arrays, so this solve problem with Array support.


In reply to: 187207615 [](ancestors = 187207615,187205023)

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated

public MemoryCollection(IEnumerable<TInput> collection)
{
Contracts.CheckParamValue(collection != null, collection, nameof(collection), "Must be non-null");

@TomFinleyTomFinleyMay 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.

CheckParamValue(collection != null, collection [](start = 22, length = 46)

I'm sorry, I'm silly... I didn't mean CheckParamValue, I meant CheckValue. That'll simplify this a bit. #Closed

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
public MemoryCollectionPipelineStep(Var<IDataView> data)
{
Data = data;
Model = null;

@TomFinleyTomFinleyMay 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.

Unnecessary, the default value is null.

That's fine, but I'd go one step further... What I'd do is change the public Var<ITransformModel> Model { get; } below to public Var<ITransformModel> Model => null;, that way you avoid having any backing field whatsoever. (Plus you save three characters, which totally makes it worth it. :D ) #Closed

[Fact]
public void CanSuccessfullyApplyATransform()
{
var collection = new MemoryCollection<Input>(new List<Input>() { new Input { Number1 = 1, String1 = "1" } });

@TomFinleyTomFinleyMay 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.

MemoryCollection [](start = 33, length = 23)

Just an observation... if we had instead structured this as a static utility method somewhere, then we could avoid having the double-specification of the Input class, as it would have been inferred by the compiler.

So: if we had a input type MyAwesomeInputType, then instead of MemoryCollection<MyAwesomeInputType>(new MyAwesomeInputType[] {...}), we would have MemoryCollection.Create(new MyAwesomeInputType[] {...}) since the compiler could have done the work of inferring the type and whatnot. #Closed

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
public class MemoryCollection
{
/// <summary>
/// Creates memory collection loader.

@glebukglebukMay 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
ContributorAuthor

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)

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
}

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

@glebukglebukMay 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

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
using Microsoft.ML.Runtime.EntryPoints;
using Microsoft.ML.Runtime.Internal.Utilities;

namespace Microsoft.ML

@glebukglebukMay 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
ContributorAuthor

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)

@codemzscodemzsMay 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

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

@glebukglebukMay 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
ContributorAuthor

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)

@glebukglebukMay 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 commented May 11, 2018

Copy link
Copy Markdown
Contributor

Sorry, indeed I meant to add a different Eric!


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


namespace Microsoft.ML.Data
{
public class CollectionLoader

@TomFinleyTomFinleyMay 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.

public class [](start = 4, length = 12)

Static class #Closed

@Ivanidzo4kaIvanidzo4ka changed the title In memory loader (train on top of memory collection instead of loading data from file)CollectionDataSource (train on top of memory collection instead of loading data from file)May 11, 2018
@Ivanidzo4ka

Ivanidzo4ka commented May 11, 2018

Copy link
Copy Markdown
ContributorAuthor

@dotnet-bot test Windows_NT Release please

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

@TomFinleyTomFinleyMay 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

@TomFinleyTomFinley left a comment

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.

:shipit:

new IrisData { SepalLength = 1f, SepalWidth = 1f ,PetalLength=0.3f, PetalWidth=5.1f, Label=1},
new IrisData { SepalLength = 1.2f, SepalWidth = 0.5f ,PetalLength=0.3f, PetalWidth=5.1f, Label=0}
};
var collection = CollectionDataSource.Create(data);

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.

Would we address the inconsistency in naming/usage between CollectionDataSource and TextLoader in a separate PR? We want it to be clearer these are the two (current) approaches to bringing data into a LearningPipeline.

@shauheenshauheen removed this from the 0518 milestone May 14, 2018
@Ivanidzo4ka

Ivanidzo4ka commented May 14, 2018

Copy link
Copy Markdown
ContributorAuthor

@glebuk is this review still in blocking state? If yes, what should be process of API review? #Closed

@glebuk

Copy link
Copy Markdown
Contributor

let me review it. Just give me 20 minutes.


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


namespace Microsoft.ML.Data
{
public static class CollectionDataSource

@glebukglebukMay 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.

CollectionDataSource [](start = 24, length = 20)

Please add a top level XML help - what is this class, where does it use, what's the purpose for its existance? #Closed

@glebuk

Copy link
Copy Markdown
Contributor

done. please look at 2 new comments


In reply to: 388992391 [](ancestors = 388992391,388913155)

@glebukglebuk left a comment

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.

:shipit:

@Ivanidzo4ka

Copy link
Copy Markdown
ContributorAuthor

@dotnet-bot test OSX10.13 Debug please

@glebukglebuk left a comment

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.

:shipit:

@Ivanidzo4ka
Ivanidzo4ka merged commit 6d5a41d into dotnet:masterMay 15, 2018
@Ivanidzo4ka
Ivanidzo4ka deleted the ivanidze/in_memory_loader branch May 15, 2018 00:26
@ntaherkhani

Copy link
Copy Markdown

"CollectionDataSource" is not recognized in my project.
"The name 'CollectionDataSource' does not exist in the current context" .
may somebody help me please.
Also, May please put some samples for other types of data loading except using "TextLoader". I need some samples to add data to pipeline from "DataTable".
Thanks.

@Ivanidzo4ka

Ivanidzo4ka commented May 23, 2018

Copy link
Copy Markdown
ContributorAuthor

@ntaherkhani Changes in this PR would be part of 0.2 release. Currently on nuget.org you can find only 0.1 release. You can consume nuget with current master branch from myget: https://dotnet.myget.org/F/dotnet-core/api/v3/index.json
Check "Include prerelease" in VS and search for Microsoft.ML package.

eerhardt pushed a commit to eerhardt/machinelearning that referenced this pull request Jul 27, 2018
…ading data from file) (dotnet#106)
* in memory loader
* add test file for memory collection
* even in afterlife EntryPointCatalog will chase me down.
* Address some comments.
* update tests
* address more comments.
* remove empty param description
* hide collectionloader
* refactor classes a little.
* pesky new lines!
* slightly better comments. but only slighty
* rename it
* make class static
* not a loader
* remove alias in entrypoint
* address comments
@ghostghost locked as resolved and limited conversation to collaborators Mar 31, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancementNew feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

@Ivanidzo4ka@glebuk@erier@ntaherkhani@codemzs@GalOshri@eerhardt@TomFinley@shauheen
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

CollectionDataSource (train on top of memory collection instead of loading data from file) - #106

Merged
Ivanidzo4ka merged 16 commits into
dotnet:masterfrom
Ivanidzo4ka:ivanidze/in_memory_loader
May 15, 2018
Merged

CollectionDataSource (train on top of memory collection instead of loading data from file)#106
Ivanidzo4ka merged 16 commits into
dotnet:masterfrom
Ivanidzo4ka:ivanidze/in_memory_loader

Conversation

@Ivanidzo4ka

@Ivanidzo4kaIvanidzo4ka commented May 9, 2018

Copy link
Copy Markdown
Contributor

First iteration which allows user to create IDataview on top of IList or Enumerable and infrastructure to add it in pipeline.
address #10 issue

@Ivanidzo4ka

Ivanidzo4ka commented May 9, 2018

Copy link
Copy Markdown
ContributorAuthor

@GalOshri@glebuk I would appreciate your contribution regarding class names. #Resolved

@Ivanidzo4kaIvanidzo4ka self-assigned this May 9, 2018
@Ivanidzo4kaIvanidzo4ka added the enhancement New feature or request label May 9, 2018
Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
public void SetInput(IHostEnvironment env, Experiment experiment)
{
if (_listCollection!=null)
{

@TomFinleyTomFinleyMay 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

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated

public MemoryCollection(IList<TInput> collection)
{
//need validation at some point

@TomFinleyTomFinleyMay 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.

//need validation at some point [](start = 12, length = 31)

How about we at least validate to ensure that these aren't null, with a Contracts.CheckParamValue? Here and in the other constructor. #Closed

@shauheenshauheen added this to the 0518 milestone May 9, 2018
/// A helper class to create data views based on the user-provided types.
/// </summary>
internal static class DataViewConstructionUtils
public static class DataViewConstructionUtils

@TomFinleyTomFinleyMay 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.

public static class DataViewConstructionUtils [](start = 4, length = 45)

This makes me nervous... If you make this public rather than internal, then it is no longer appropriate to have what are currently Asserts on the public methods. They'll have to be Checks, with suitably verbose error messages, properly called in the context of env, and so on, and so on. This is more work than I think you want to have right now.

Do you need all of the functions in this class? This was originally a supporting utility class for the pre-ML.NET API. You don't need all of it... in fact I think you only need a couple of them. I might choose to either (1) introduce another public class with the methods you need being accessible through that or (2) change this class so that it remains public but everything in it has its access member changed to internal, except the one or two facilities you actually need. #Closed

@Ivanidzo4kaIvanidzo4kaMay 9, 2018

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Oh, I miss these blobs of text so much. (I'm serious right now) #Closed

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Someone already did that for me. All I had to do is to look for method reference :)


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

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.

Thanks Ivan, it's nice to be appreciated. :D :D


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

@TomFinley
TomFinley requested a review from eerhardtMay 9, 2018 23:24
/// An internal class that holds the (already validated) mapping between a custom type and an IDataView schema.
/// </summary>
internal sealed class InternalSchemaDefinition
public sealed class InternalSchemaDefinition

@TomFinleyTomFinleyMay 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.

public sealed class InternalSchemaDefinition [](start = 4, length = 44)

I have similar concerns about this class being public. If we can avoid it, possibly by moving some of the logic current in MemoryCollection.cs to this assembly, then calling that from the Microsoft.ML project, I'd be delighted. #Closed

@Ivanidzo4ka

Ivanidzo4ka commented May 9, 2018

Copy link
Copy Markdown
ContributorAuthor

using Microsoft.ML.Data;

need header #Resolved


Refers to: src/Microsoft.ML/Runtime/EntryPoints/DataViewReference.cs:1 in b166f05. [](commit_id = b166f05, deletion_comment = False)

@Ivanidzo4ka

Ivanidzo4ka commented May 9, 2018

Copy link
Copy Markdown
ContributorAuthor

using System;

need header #Resolved


Refers to: src/Microsoft.ML/MemoryCollection.cs:1 in b166f05. [](commit_id = b166f05, deletion_comment = False)

Experiment experiment = environment.CreateExperiment();
ILearningPipelineDataStep output = collection.ApplyStep(null, experiment) as ILearningPipelineDataStep;

Assert.NotNull(output.Data);

@TomFinleyTomFinleyMay 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.

Assert.NotNull(output.Data); [](start = 16, length = 28)

If you really meant the as above, you should first Assert.NonNull on output. If you didn't mean the as above, then you should do a direct () style cast to ILearningPipelineDataStep. The only reason to use an as style cast is if you are entertaining the possibility that it might not implement that interface, in which case, given that this is a test, you should test that. (And if it wasn't a test, you would Contracts.Check* it.) #Closed

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
private Data.DataViewReference _dataViewEntryPoint;
private IDataView _dataView;

public MemoryCollection(IList<TInput> collection)

@Ivanidzo4kaIvanidzo4kaMay 9, 2018

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

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

public constructor required comments. #Resolved

internal static class DataViewConstructionUtils
public static class DataViewConstructionUtils
{
public static IDataView CreateFromList<TRow>(IHostEnvironment env, IList<TRow> data,

@Ivanidzo4kaIvanidzo4kaMay 9, 2018

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

IList [](start = 75, length = 5)

Since we in this file, @tfinley@gmail.com do you have any opinion about IList?
I would personally convert it to List. #Resolved

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 there a reason why you would prefer List here?

So the reason I would prefer a specific implementer of an interface rather than the interface itself is to avoid having to go through the virtual function table. (Which is why it's often better to write Foo<TBar>(TBar biz) where TBar : IBar vs. Foo(IBar biz).) In this specific case though, I don't think it's worth it. You're ultimately going to be dealing with an IEnumerator<TRow>anyway for most operations on this structure, and there it's unfortunately unavoidable, so I care a bit less. But perhaps there's something to this I'm not appreciating.


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

@Ivanidzo4kaIvanidzo4kaMay 10, 2018

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I guess its just personal. I just don't like IList. In same time, IList allow you to pass Arrays, so this solve problem with Array support.


In reply to: 187207615 [](ancestors = 187207615,187205023)

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated

public MemoryCollection(IEnumerable<TInput> collection)
{
Contracts.CheckParamValue(collection != null, collection, nameof(collection), "Must be non-null");

@TomFinleyTomFinleyMay 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.

CheckParamValue(collection != null, collection [](start = 22, length = 46)

I'm sorry, I'm silly... I didn't mean CheckParamValue, I meant CheckValue. That'll simplify this a bit. #Closed

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
public MemoryCollectionPipelineStep(Var<IDataView> data)
{
Data = data;
Model = null;

@TomFinleyTomFinleyMay 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.

Unnecessary, the default value is null.

That's fine, but I'd go one step further... What I'd do is change the public Var<ITransformModel> Model { get; } below to public Var<ITransformModel> Model => null;, that way you avoid having any backing field whatsoever. (Plus you save three characters, which totally makes it worth it. :D ) #Closed

[Fact]
public void CanSuccessfullyApplyATransform()
{
var collection = new MemoryCollection<Input>(new List<Input>() { new Input { Number1 = 1, String1 = "1" } });

@TomFinleyTomFinleyMay 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.

MemoryCollection [](start = 33, length = 23)

Just an observation... if we had instead structured this as a static utility method somewhere, then we could avoid having the double-specification of the Input class, as it would have been inferred by the compiler.

So: if we had a input type MyAwesomeInputType, then instead of MemoryCollection<MyAwesomeInputType>(new MyAwesomeInputType[] {...}), we would have MemoryCollection.Create(new MyAwesomeInputType[] {...}) since the compiler could have done the work of inferring the type and whatnot. #Closed

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
public class MemoryCollection
{
/// <summary>
/// Creates memory collection loader.

@glebukglebukMay 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
ContributorAuthor

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)

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
}

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

@glebukglebukMay 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

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
using Microsoft.ML.Runtime.EntryPoints;
using Microsoft.ML.Runtime.Internal.Utilities;

namespace Microsoft.ML

@glebukglebukMay 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
ContributorAuthor

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)

@codemzscodemzsMay 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

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

@glebukglebukMay 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
ContributorAuthor

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)

@glebukglebukMay 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 commented May 11, 2018

Copy link
Copy Markdown
Contributor

Sorry, indeed I meant to add a different Eric!


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


namespace Microsoft.ML.Data
{
public class CollectionLoader

@TomFinleyTomFinleyMay 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.

public class [](start = 4, length = 12)

Static class #Closed

@Ivanidzo4kaIvanidzo4ka changed the title In memory loader (train on top of memory collection instead of loading data from file)CollectionDataSource (train on top of memory collection instead of loading data from file)May 11, 2018
@Ivanidzo4ka

Ivanidzo4ka commented May 11, 2018

Copy link
Copy Markdown
ContributorAuthor

@dotnet-bot test Windows_NT Release please

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

@TomFinleyTomFinleyMay 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

@TomFinleyTomFinley left a comment

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.

:shipit:

new IrisData { SepalLength = 1f, SepalWidth = 1f ,PetalLength=0.3f, PetalWidth=5.1f, Label=1},
new IrisData { SepalLength = 1.2f, SepalWidth = 0.5f ,PetalLength=0.3f, PetalWidth=5.1f, Label=0}
};
var collection = CollectionDataSource.Create(data);

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.

Would we address the inconsistency in naming/usage between CollectionDataSource and TextLoader in a separate PR? We want it to be clearer these are the two (current) approaches to bringing data into a LearningPipeline.

@shauheenshauheen removed this from the 0518 milestone May 14, 2018
@Ivanidzo4ka

Ivanidzo4ka commented May 14, 2018

Copy link
Copy Markdown
ContributorAuthor

@glebuk is this review still in blocking state? If yes, what should be process of API review? #Closed

@glebuk

Copy link
Copy Markdown
Contributor

let me review it. Just give me 20 minutes.


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


namespace Microsoft.ML.Data
{
public static class CollectionDataSource

@glebukglebukMay 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.

CollectionDataSource [](start = 24, length = 20)

Please add a top level XML help - what is this class, where does it use, what's the purpose for its existance? #Closed

@glebuk

Copy link
Copy Markdown
Contributor

done. please look at 2 new comments


In reply to: 388992391 [](ancestors = 388992391,388913155)

@glebukglebuk left a comment

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.

:shipit:

@Ivanidzo4ka

Copy link
Copy Markdown
ContributorAuthor

@dotnet-bot test OSX10.13 Debug please

@glebukglebuk left a comment

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.

:shipit:

@Ivanidzo4ka
Ivanidzo4ka merged commit 6d5a41d into dotnet:masterMay 15, 2018
@Ivanidzo4ka
Ivanidzo4ka deleted the ivanidze/in_memory_loader branch May 15, 2018 00:26
@ntaherkhani

Copy link
Copy Markdown

"CollectionDataSource" is not recognized in my project.
"The name 'CollectionDataSource' does not exist in the current context" .
may somebody help me please.
Also, May please put some samples for other types of data loading except using "TextLoader". I need some samples to add data to pipeline from "DataTable".
Thanks.

@Ivanidzo4ka

Ivanidzo4ka commented May 23, 2018

Copy link
Copy Markdown
ContributorAuthor

@ntaherkhani Changes in this PR would be part of 0.2 release. Currently on nuget.org you can find only 0.1 release. You can consume nuget with current master branch from myget: https://dotnet.myget.org/F/dotnet-core/api/v3/index.json
Check "Include prerelease" in VS and search for Microsoft.ML package.

eerhardt pushed a commit to eerhardt/machinelearning that referenced this pull request Jul 27, 2018
…ading data from file) (dotnet#106)
* in memory loader
* add test file for memory collection
* even in afterlife EntryPointCatalog will chase me down.
* Address some comments.
* update tests
* address more comments.
* remove empty param description
* hide collectionloader
* refactor classes a little.
* pesky new lines!
* slightly better comments. but only slighty
* rename it
* make class static
* not a loader
* remove alias in entrypoint
* address comments
@ghostghost locked as resolved and limited conversation to collaborators Mar 31, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancementNew feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

@Ivanidzo4ka@glebuk@erier@ntaherkhani@codemzs@GalOshri@eerhardt@TomFinley@shauheen
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

CollectionDataSource (train on top of memory collection instead of loading data from file) - #106

Merged
Ivanidzo4ka merged 16 commits into
dotnet:masterfrom
Ivanidzo4ka:ivanidze/in_memory_loader
May 15, 2018
Merged

CollectionDataSource (train on top of memory collection instead of loading data from file)#106
Ivanidzo4ka merged 16 commits into
dotnet:masterfrom
Ivanidzo4ka:ivanidze/in_memory_loader

Conversation

@Ivanidzo4ka

@Ivanidzo4kaIvanidzo4ka commented May 9, 2018

Copy link
Copy Markdown
Contributor

First iteration which allows user to create IDataview on top of IList or Enumerable and infrastructure to add it in pipeline.
address #10 issue

@Ivanidzo4ka

Ivanidzo4ka commented May 9, 2018

Copy link
Copy Markdown
ContributorAuthor

@GalOshri@glebuk I would appreciate your contribution regarding class names. #Resolved

@Ivanidzo4kaIvanidzo4ka self-assigned this May 9, 2018
@Ivanidzo4kaIvanidzo4ka added the enhancement New feature or request label May 9, 2018
Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
public void SetInput(IHostEnvironment env, Experiment experiment)
{
if (_listCollection!=null)
{

@TomFinleyTomFinleyMay 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

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated

public MemoryCollection(IList<TInput> collection)
{
//need validation at some point

@TomFinleyTomFinleyMay 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.

//need validation at some point [](start = 12, length = 31)

How about we at least validate to ensure that these aren't null, with a Contracts.CheckParamValue? Here and in the other constructor. #Closed

@shauheenshauheen added this to the 0518 milestone May 9, 2018
/// A helper class to create data views based on the user-provided types.
/// </summary>
internal static class DataViewConstructionUtils
public static class DataViewConstructionUtils

@TomFinleyTomFinleyMay 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.

public static class DataViewConstructionUtils [](start = 4, length = 45)

This makes me nervous... If you make this public rather than internal, then it is no longer appropriate to have what are currently Asserts on the public methods. They'll have to be Checks, with suitably verbose error messages, properly called in the context of env, and so on, and so on. This is more work than I think you want to have right now.

Do you need all of the functions in this class? This was originally a supporting utility class for the pre-ML.NET API. You don't need all of it... in fact I think you only need a couple of them. I might choose to either (1) introduce another public class with the methods you need being accessible through that or (2) change this class so that it remains public but everything in it has its access member changed to internal, except the one or two facilities you actually need. #Closed

@Ivanidzo4kaIvanidzo4kaMay 9, 2018

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Oh, I miss these blobs of text so much. (I'm serious right now) #Closed

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Someone already did that for me. All I had to do is to look for method reference :)


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

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.

Thanks Ivan, it's nice to be appreciated. :D :D


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

@TomFinley
TomFinley requested a review from eerhardtMay 9, 2018 23:24
/// An internal class that holds the (already validated) mapping between a custom type and an IDataView schema.
/// </summary>
internal sealed class InternalSchemaDefinition
public sealed class InternalSchemaDefinition

@TomFinleyTomFinleyMay 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.

public sealed class InternalSchemaDefinition [](start = 4, length = 44)

I have similar concerns about this class being public. If we can avoid it, possibly by moving some of the logic current in MemoryCollection.cs to this assembly, then calling that from the Microsoft.ML project, I'd be delighted. #Closed

@Ivanidzo4ka

Ivanidzo4ka commented May 9, 2018

Copy link
Copy Markdown
ContributorAuthor

using Microsoft.ML.Data;

need header #Resolved


Refers to: src/Microsoft.ML/Runtime/EntryPoints/DataViewReference.cs:1 in b166f05. [](commit_id = b166f05, deletion_comment = False)

@Ivanidzo4ka

Ivanidzo4ka commented May 9, 2018

Copy link
Copy Markdown
ContributorAuthor

using System;

need header #Resolved


Refers to: src/Microsoft.ML/MemoryCollection.cs:1 in b166f05. [](commit_id = b166f05, deletion_comment = False)

Experiment experiment = environment.CreateExperiment();
ILearningPipelineDataStep output = collection.ApplyStep(null, experiment) as ILearningPipelineDataStep;

Assert.NotNull(output.Data);

@TomFinleyTomFinleyMay 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.

Assert.NotNull(output.Data); [](start = 16, length = 28)

If you really meant the as above, you should first Assert.NonNull on output. If you didn't mean the as above, then you should do a direct () style cast to ILearningPipelineDataStep. The only reason to use an as style cast is if you are entertaining the possibility that it might not implement that interface, in which case, given that this is a test, you should test that. (And if it wasn't a test, you would Contracts.Check* it.) #Closed

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
private Data.DataViewReference _dataViewEntryPoint;
private IDataView _dataView;

public MemoryCollection(IList<TInput> collection)

@Ivanidzo4kaIvanidzo4kaMay 9, 2018

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

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

public constructor required comments. #Resolved

internal static class DataViewConstructionUtils
public static class DataViewConstructionUtils
{
public static IDataView CreateFromList<TRow>(IHostEnvironment env, IList<TRow> data,

@Ivanidzo4kaIvanidzo4kaMay 9, 2018

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

IList [](start = 75, length = 5)

Since we in this file, @tfinley@gmail.com do you have any opinion about IList?
I would personally convert it to List. #Resolved

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 there a reason why you would prefer List here?

So the reason I would prefer a specific implementer of an interface rather than the interface itself is to avoid having to go through the virtual function table. (Which is why it's often better to write Foo<TBar>(TBar biz) where TBar : IBar vs. Foo(IBar biz).) In this specific case though, I don't think it's worth it. You're ultimately going to be dealing with an IEnumerator<TRow>anyway for most operations on this structure, and there it's unfortunately unavoidable, so I care a bit less. But perhaps there's something to this I'm not appreciating.


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

@Ivanidzo4kaIvanidzo4kaMay 10, 2018

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I guess its just personal. I just don't like IList. In same time, IList allow you to pass Arrays, so this solve problem with Array support.


In reply to: 187207615 [](ancestors = 187207615,187205023)

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated

public MemoryCollection(IEnumerable<TInput> collection)
{
Contracts.CheckParamValue(collection != null, collection, nameof(collection), "Must be non-null");

@TomFinleyTomFinleyMay 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.

CheckParamValue(collection != null, collection [](start = 22, length = 46)

I'm sorry, I'm silly... I didn't mean CheckParamValue, I meant CheckValue. That'll simplify this a bit. #Closed

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
public MemoryCollectionPipelineStep(Var<IDataView> data)
{
Data = data;
Model = null;

@TomFinleyTomFinleyMay 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.

Unnecessary, the default value is null.

That's fine, but I'd go one step further... What I'd do is change the public Var<ITransformModel> Model { get; } below to public Var<ITransformModel> Model => null;, that way you avoid having any backing field whatsoever. (Plus you save three characters, which totally makes it worth it. :D ) #Closed

[Fact]
public void CanSuccessfullyApplyATransform()
{
var collection = new MemoryCollection<Input>(new List<Input>() { new Input { Number1 = 1, String1 = "1" } });

@TomFinleyTomFinleyMay 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.

MemoryCollection [](start = 33, length = 23)

Just an observation... if we had instead structured this as a static utility method somewhere, then we could avoid having the double-specification of the Input class, as it would have been inferred by the compiler.

So: if we had a input type MyAwesomeInputType, then instead of MemoryCollection<MyAwesomeInputType>(new MyAwesomeInputType[] {...}), we would have MemoryCollection.Create(new MyAwesomeInputType[] {...}) since the compiler could have done the work of inferring the type and whatnot. #Closed

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
public class MemoryCollection
{
/// <summary>
/// Creates memory collection loader.

@glebukglebukMay 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
ContributorAuthor

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)

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
}

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

@glebukglebukMay 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

Comment threadsrc/Microsoft.ML/MemoryCollection.cs Outdated
using Microsoft.ML.Runtime.EntryPoints;
using Microsoft.ML.Runtime.Internal.Utilities;

namespace Microsoft.ML

@glebukglebukMay 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
ContributorAuthor

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)

@codemzscodemzsMay 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

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

@glebukglebukMay 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
ContributorAuthor

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)

@glebukglebukMay 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 commented May 11, 2018

Copy link
Copy Markdown
Contributor

Sorry, indeed I meant to add a different Eric!


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


namespace Microsoft.ML.Data
{
public class CollectionLoader

@TomFinleyTomFinleyMay 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.

public class [](start = 4, length = 12)

Static class #Closed

@Ivanidzo4kaIvanidzo4ka changed the title In memory loader (train on top of memory collection instead of loading data from file)CollectionDataSource (train on top of memory collection instead of loading data from file)May 11, 2018
@Ivanidzo4ka

Ivanidzo4ka commented May 11, 2018

Copy link
Copy Markdown
ContributorAuthor

@dotnet-bot test Windows_NT Release please

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

@TomFinleyTomFinleyMay 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

@TomFinleyTomFinley left a comment

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.

:shipit:

new IrisData { SepalLength = 1f, SepalWidth = 1f ,PetalLength=0.3f, PetalWidth=5.1f, Label=1},
new IrisData { SepalLength = 1.2f, SepalWidth = 0.5f ,PetalLength=0.3f, PetalWidth=5.1f, Label=0}
};
var collection = CollectionDataSource.Create(data);

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.

Would we address the inconsistency in naming/usage between CollectionDataSource and TextLoader in a separate PR? We want it to be clearer these are the two (current) approaches to bringing data into a LearningPipeline.

@shauheenshauheen removed this from the 0518 milestone May 14, 2018
@Ivanidzo4ka

Ivanidzo4ka commented May 14, 2018

Copy link
Copy Markdown
ContributorAuthor

@glebuk is this review still in blocking state? If yes, what should be process of API review? #Closed

@glebuk

Copy link
Copy Markdown
Contributor

let me review it. Just give me 20 minutes.


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


namespace Microsoft.ML.Data
{
public static class CollectionDataSource

@glebukglebukMay 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.

CollectionDataSource [](start = 24, length = 20)

Please add a top level XML help - what is this class, where does it use, what's the purpose for its existance? #Closed

@glebuk

Copy link
Copy Markdown
Contributor

done. please look at 2 new comments


In reply to: 388992391 [](ancestors = 388992391,388913155)

@glebukglebuk left a comment

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.

:shipit:

@Ivanidzo4ka

Copy link
Copy Markdown
ContributorAuthor

@dotnet-bot test OSX10.13 Debug please

@glebukglebuk left a comment

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.

:shipit:

@Ivanidzo4ka
Ivanidzo4ka merged commit 6d5a41d into dotnet:masterMay 15, 2018
@Ivanidzo4ka
Ivanidzo4ka deleted the ivanidze/in_memory_loader branch May 15, 2018 00:26
@ntaherkhani

Copy link
Copy Markdown

"CollectionDataSource" is not recognized in my project.
"The name 'CollectionDataSource' does not exist in the current context" .
may somebody help me please.
Also, May please put some samples for other types of data loading except using "TextLoader". I need some samples to add data to pipeline from "DataTable".
Thanks.

@Ivanidzo4ka

Ivanidzo4ka commented May 23, 2018

Copy link
Copy Markdown
ContributorAuthor

@ntaherkhani Changes in this PR would be part of 0.2 release. Currently on nuget.org you can find only 0.1 release. You can consume nuget with current master branch from myget: https://dotnet.myget.org/F/dotnet-core/api/v3/index.json
Check "Include prerelease" in VS and search for Microsoft.ML package.

eerhardt pushed a commit to eerhardt/machinelearning that referenced this pull request Jul 27, 2018
…ading data from file) (dotnet#106)
* in memory loader
* add test file for memory collection
* even in afterlife EntryPointCatalog will chase me down.
* Address some comments.
* update tests
* address more comments.
* remove empty param description
* hide collectionloader
* refactor classes a little.
* pesky new lines!
* slightly better comments. but only slighty
* rename it
* make class static
* not a loader
* remove alias in entrypoint
* address comments
@ghostghost locked as resolved and limited conversation to collaborators Mar 31, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancementNew feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

@Ivanidzo4ka@glebuk@erier@ntaherkhani@codemzs@GalOshri@eerhardt@TomFinley@shauheen