-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fix NullReferenceException when it comes to Recommendation in AutoML and CodeGenerator #4774
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
Merged
LittleLittleCloud
merged 1 commit into
dotnet:master
from
LittleLittleCloud:u/xiaoyun/fixRecommendationBug
Feb 4, 2020
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
using Microsoft.ML; | ||
using Microsoft.ML.AutoML; | ||
using Microsoft.ML.CodeGenerator.CSharp; | ||
using Microsoft.ML.Trainers; | ||
using Xunit; | ||
|
||
namespace mlnet.Tests | ||
|
@@ -295,14 +296,21 @@ public void MatrixFactorizationAdvancedTest() | |
{"MatrixColumnIndexColumnName","userId" }, | ||
{"MatrixRowIndexColumnName","movieId" }, | ||
{"LabelColumnName","rating" }, | ||
{nameof(MatrixFactorizationTrainer.Options.NumberOfIterations), 10 }, | ||
{nameof(MatrixFactorizationTrainer.Options.LearningRate), 0.01f }, | ||
{nameof(MatrixFactorizationTrainer.Options.ApproximationRank), 8 }, | ||
{nameof(MatrixFactorizationTrainer.Options.Lambda), 0.01f }, | ||
{nameof(MatrixFactorizationTrainer.Options.LossFunction), MatrixFactorizationTrainer.LossFunctionType.SquareLossRegression }, | ||
{nameof(MatrixFactorizationTrainer.Options.Alpha), 1f }, | ||
{nameof(MatrixFactorizationTrainer.Options.C), 0.00001f }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for adding the MF options to a test. |
||
}; | ||
PipelineNode node = new PipelineNode("MatrixFactorization", PipelineNodeType.Trainer, default(string[]), default(string), elementProperties); | ||
Pipeline pipeline = new Pipeline(new PipelineNode[] { node }); | ||
CodeGenerator codeGenerator = new CodeGenerator(pipeline, null, null); | ||
var actual = codeGenerator.GenerateTrainerAndUsings(); | ||
string expectedTrainerString = "MatrixFactorization(matrixColumnIndexColumnName:\"userId\",matrixRowIndexColumnName:\"movieId\",labelColumnName:\"rating\")"; | ||
string expectedTrainerString = "MatrixFactorization(new MatrixFactorizationTrainer.Options(){MatrixColumnIndexColumnName=\"userId\",MatrixRowIndexColumnName=\"movieId\",LabelColumnName=\"rating\",NumberOfIterations=10,LearningRate=0.01f,ApproximationRank=8,Lambda=0.01f,LossFunction=MatrixFactorizationTrainer.LossFunctionType.SquareLossRegression,Alpha=1f,C=1E-05f})"; | ||
Assert.Equal(expectedTrainerString, actual.Item1); | ||
Assert.Null(actual.Item2); | ||
Assert.Equal(new string[] { "using Microsoft.ML.Trainers;\r\n" },actual.Item2); | ||
} | ||
|
||
[Fact] | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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'm not sure why the try/catch was needed. If no one else knows, we may want drill down in the code, or run a variety of datasets thru the CLI to show that nothing is expected to throw.
The old catch seem to eat the error without a hint of what went wrong.
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.
Yeah, that's why I removed that part of code