Skip to content
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

Merged
merged 3 commits into from
Jul 2, 2019

Conversation

sayanshaw24
Copy link
Contributor

Guidelines followed:

  • 85 characters per line
  • Use 4 spaces for indentation
  • Dot, open parentheses, and function/variable name on same line
  • Math operations on same line
  • Don't indent comments
  • Don't break links
  • Don't break a comment if it represents a print output
  • Add an extra line after a break if it does not already exist
  • Break before "$"
    Fix for Issue Samples width: they need to be formatted at 85 characters or less. #3478

dataMatrix.Add(new MatrixElement() { MatrixColumnIndex = i, MatrixRowIndex = j, Value = (i + j) % 5 });
dataMatrix.Add(new MatrixElement() { MatrixColumnIndex = i,
MatrixRowIndex = j, Value = (i + j) % 5 });

Copy link
Member

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?

Copy link
Contributor Author

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");
Copy link
Member

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.

Copy link
Contributor Author

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");
Copy link
Member

@wschin wschin Jul 1, 2019

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.

// 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),
Copy link
Member

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.

Copy link
Contributor Author

@sayanshaw24 sayanshaw24 Jul 2, 2019

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?

Copy link
Member

@codemzs codemzs left a comment

Choose a reason for hiding this comment

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

:shipit:

@sayanshaw24 sayanshaw24 merged commit 01b3ec7 into dotnet:master Jul 2, 2019
var predictions = mlContext.Data.CreateEnumerable<MatrixElement>(transformedData, reuseRowObject: false).Take(5).ToList();
var predictions = mlContext.Data
.CreateEnumerable<MatrixElement>(transformedData,
reuseRowObject: false).Take(5).ToList();
Copy link
Member

@sharwell sharwell Jul 2, 2019

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),
Copy link
Member

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 });
Copy link
Member

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

Copy link
Member

@sharwell sharwell left a 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),
Copy link
Member

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));
Copy link
Member

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
),
Copy link
Member

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)

Dmitry-A pushed a commit to Dmitry-A/machinelearning that referenced this pull request Jul 24, 2019
* Reformatted Recommendation samples

* Fix for tab spacing errors

* Removed precision for reformatting in Console.WriteLine and fixed KeyType error
@ghost ghost locked as resolved and limited conversation to collaborators Mar 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants