-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Adding CodeGen piece for MatrixFactorization trainer #4391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding CodeGen piece for MatrixFactorization trainer #4391
Conversation
0fc8a38
to
acdf78a
Compare
@@ -47,7 +48,10 @@ private void Initialize(PipelineNode node) | |||
{ | |||
node.Properties.Add("LabelColumnName", "Label"); | |||
} | |||
node.Properties.Add("FeatureColumnName", "Features"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FeatureColumnName gets added for all existing trainer generators. I added IncludeFeatureColumnName which is false for MatrixFactorization trainer generator only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO:
- Look more closely at the implementation to see why it was expected for all Trainer Generators to have a FeatureColumn. if it is expected then it should also be added for MatrixFactorization trainer generator
src/Microsoft.ML.CodeGenerator/CodeGenerator/CSharp/TrainerGenerators.cs
Show resolved
Hide resolved
{ | ||
get | ||
{ | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit of an anti-pattern: to return a new object every time a property is invoked. I see this is already being used in existing code, so you don't need to fix it in this PR. But in general, calling a property is supposed to be fast.
https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/property
Although properties are technically very similar to methods, they are quite different in terms of their usage scenarios. They should be seen as smart fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't find changes in For example here we need to add something like |
@LittleLittleCloud brings up a great point. We need to include the Recommender package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks initially good to me. I'll have further feedback when testing it with the NuGet packages and when available from the CLI.
a8bbbd8
to
523e808
Compare
523e808
to
d586c62
Compare
src/Microsoft.ML.CodeGenerator/Templates/Console/PackageVersion.ttinclude
Outdated
Show resolved
Hide resolved
src/Microsoft.ML.CodeGenerator/Templates/Console/ModelProject.tt
Outdated
Show resolved
Hide resolved
...atorTests.Recommendation_GenerateConsoleAppProjectContents_VerifyPredictProject.approved.txt
Outdated
Show resolved
Hide resolved
...eratorTests.Recommendation_GenerateConsoleAppProjectContents_VerifyModelBuilder.approved.txt
Outdated
Show resolved
Hide resolved
…ation Conflicts: src/Microsoft.ML.CodeGenerator/CodeGenerator/CSharp/CodeGenerator.cs src/Microsoft.ML.CodeGenerator/CodeGenerator/CSharp/TrainerGeneratorFactory.cs src/Microsoft.ML.CodeGenerator/CodeGenerator/CSharp/TrainerGenerators.cs src/Microsoft.ML.CodeGenerator/Templates/Console/ModelProject.cs src/Microsoft.ML.CodeGenerator/Templates/Console/ModelProject.tt src/Microsoft.ML.CodeGenerator/Templates/Console/PredictProject.cs src/Microsoft.ML.CodeGenerator/Templates/Console/PredictProject.tt test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.ConsoleAppProjectFileContentTest.approved.txt test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.ModelProjectFileContentTestOnlyStableProjects.approved.txt test/Microsoft.ML.CodeGenerator.Tests/ApprovalTests/ConsoleCodeGeneratorTests.cs
I resolved the conflicts resulted from the image classification code gen submission.
|
src/Microsoft.ML.CodeGenerator/CodeGenerator/CSharp/CodeGeneratorSettings.cs
Outdated
Show resolved
Hide resolved
@@ -27,6 +27,10 @@ public CodeGeneratorSettings() | |||
|
|||
public GenerateTarget Target { get; set; } | |||
|
|||
public string StablePackageVersion { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JakeRadMSFT @LittleLittleCloud - what do you think of this approach? It at least removes hard-coded versions from the CodeGenerator assembly, and allows the "app" (CLI and Model Builder) to pick the version they require.
src/Microsoft.ML.CodeGenerator/Templates/Console/ModelProject.tt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
No, please don't make that change. Leave it as is. |
…ation Conflicts: src/Microsoft.ML.CodeGenerator/Templates/Console/ModelProject.cs src/Microsoft.ML.CodeGenerator/Templates/Console/ModelProject.tt src/Microsoft.ML.CodeGenerator/Templates/Console/PredictProject.cs src/Microsoft.ML.CodeGenerator/Templates/Console/PredictProject.tt
Merged since the CI code coverage failures are unrelated to this PR: https://github.com/dotnet/machinelearning/pull/4391/checks?check_run_id=282184827
|
* Add CodeGen piece for Recommendation Task using MatrixFactorization
* Add CodeGen piece for Recommendation Task using MatrixFactorization
This PR adds CodeGen piece for MatrixFactorization trainer (For the recommendation task)
cc: @eerhardt @LittleLittleCloud
TODO: