-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Reformatted Recommendation samples to width 85 #3941
Conversation
dataMatrix.Add(new MatrixElement() { MatrixColumnIndex = i, MatrixRowIndex = j, Value = (i + j) % 5 }); | ||
dataMatrix.Add(new MatrixElement() { MatrixColumnIndex = i, | ||
MatrixRowIndex = j, Value = (i + j) % 5 }); | ||
|
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.
Empty line. Is it produced by an auto-formatting tool?
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.
Actually, Zeeshan asked us to do that, so that's what we've been doing as a norm.
Console.WriteLine($"Root Mean Squared Error: {metrics.RootMeanSquaredError:F2}"); | ||
Console.WriteLine($"RSquared: {metrics.RSquared:F2}"); | ||
Console.WriteLine("Mean Absolute Error: " + metrics.MeanAbsoluteError + | ||
":F2"); |
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.
Is this correct? I thought F2
tells the prcision.
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 either. I tried reformatting it like another example Zeeshan helped us with that used a similar format. Do you know what the right notation is?
":F2"); | ||
|
||
Console.WriteLine("Mean Squared Error: " + metrics.MeanSquaredError + | ||
":F2"); |
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.
Maybe merging the two lines to
Console.WriteLine("Mean Squared Error: " + metrics.MeanSquaredError);
could be a reasonable setting.
...mples/Microsoft.ML.Samples/Dynamic/Trainers/Recommendation/MatrixFactorizationWithOptions.cs
Show resolved
Hide resolved
...mples/Microsoft.ML.Samples/Dynamic/Trainers/Recommendation/MatrixFactorizationWithOptions.tt
Show resolved
Hide resolved
// its desired value would be set 0.15. In other words, this parameter determines | ||
// the value of all missing matrix elements. | ||
MatrixColumnIndexColumnName = nameof( | ||
MatrixElement.MatrixColumnIndex), |
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.
Line 46 and Lines 47-53 should be at the same indent level.
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.
Zeeshan asked us to indent after the first break, so we've been doing that for all the files. Maybe we can discuss this along with Zeeshan in the scrum tomorrow?
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.
var predictions = mlContext.Data.CreateEnumerable<MatrixElement>(transformedData, reuseRowObject: false).Take(5).ToList(); | ||
var predictions = mlContext.Data | ||
.CreateEnumerable<MatrixElement>(transformedData, | ||
reuseRowObject: false).Take(5).ToList(); |
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 layout is very difficult to read. The following would be preferable:
var predictions = mlContext.Data
.CreateEnumerable<MatrixElement>(
transformedData,
reuseRowObject: false)
.Take(5)
.ToList();
nameof(MatrixElement.MatrixRowIndex), 10, 0.2, 1); | ||
var pipeline = mlContext.Recommendation().Trainers. | ||
MatrixFactorization(nameof(MatrixElement.Value), | ||
nameof(MatrixElement.MatrixColumnIndex), |
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 incorrectly indented
@@ -74,32 +92,40 @@ private static List<MatrixElement> GenerateMatrix() | |||
var dataMatrix = new List<MatrixElement>(); | |||
for (uint i = 0; i < MatrixColumnCount; ++i) | |||
for (uint j = 0; j < MatrixRowCount; ++j) | |||
dataMatrix.Add(new MatrixElement() { MatrixColumnIndex = i, MatrixRowIndex = j, Value = (i + j) % 5 }); | |||
dataMatrix.Add(new MatrixElement() { MatrixColumnIndex = i, | |||
MatrixRowIndex = j, Value = (i + j) % 5 }); |
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.
📝 Incorrect line wrapping and indentation
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.
Requesting changes. The wrapping applied in this pull request produces worse readability than whatever tool was automatically wrapping past the 85 character limit.
// the value of all missing matrix elements. | ||
MatrixColumnIndexColumnName = nameof( | ||
MatrixElement.MatrixColumnIndex), | ||
MatrixRowIndexColumnName = nameof(MatrixElement.MatrixRowIndex), |
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 incorrectly indented
// Apply the trained model to the test set. Notice that training is a | ||
// partial | ||
var prediction = model.Transform(mlContext.Data.LoadFromEnumerable( | ||
testData)); |
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.
📝 Incorrect wrapping (prefer to wrap the outer argument when it will fit on the same number of lines)
// Specify IDataView colum which stores matrix row indexes. | ||
// Specify IDataView colum which stores matrix column indexes. | ||
MatrixColumnIndexColumnName = nameof(MatrixElement.MatrixColumnIndex | ||
), |
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.
📝 Incorrect wrapping (should be wrapped before nameof
)
* Reformatted Recommendation samples * Fix for tab spacing errors * Removed precision for reformatting in Console.WriteLine and fixed KeyType error
Guidelines followed:
Fix for Issue Samples width: they need to be formatted at 85 characters or less. #3478