-
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 Regression samples to width 85 #3948
Conversation
// Create testing data. Use different random seed to make it different from training data. | ||
var testData = mlContext.Data.LoadFromEnumerable(GenerateRandomDataPoints(5, seed: 123)); | ||
// Create testing data. Use different random seed to make it different | ||
// from training data. |
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.
[](start = 0, length = 3)
please use four spaces instead of tabs. https://blogs.msdn.microsoft.com/zainnab/2010/03/14/how-to-convert-tabs-to-spaces-and-vice-versa/
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 sorry, I think I missed a few lines while untabifying the tt files. Will fix that and commit.
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.
@@ -8,37 +8,47 @@ namespace Samples.Dynamic.Trainers.Regression | |||
{ | |||
public static class FastForestRegression | |||
{ | |||
// This example requires installation of additional NuGet package | |||
// <a href="https://www.nuget.org/packages/Microsoft.ML.FastTree/">Microsoft.ML.FastTree</a>. | |||
|
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.
There's an extra line here that I don't think you need.
@@ -9,19 +9,23 @@ namespace Samples.Dynamic.Trainers.Regression | |||
{ | |||
public static class FastForestWithOptionsRegression | |||
{ | |||
// This example requires installation of additional NuGet package | |||
// <a href="https://www.nuget.org/packages/Microsoft.ML.FastTree/">Microsoft.ML.FastTree</a>. | |||
|
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.
extra line here too?
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.
Yep @RadicalRayan explained why below. I think he's asking Zeeshan about the feasibility of removing the line from all of the tt files with the NuGet package installation comment.
// Create testing data. Use different random seed to make it different from training data. | ||
var testData = mlContext.Data.LoadFromEnumerable(GenerateRandomDataPoints(5, seed: 123)); | ||
// Create testing data. Use different random seed to make it different | ||
// from training data. |
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.
tab issue here
string ClassHeader = @"// This example requires installation of additional NuGet package | ||
// <a href=""https://www.nuget.org/packages/Microsoft.ML.FastTree/"">Microsoft.ML.FastTree</a>. "; | ||
string ClassHeader = @" | ||
// This example requires installation of additional NuGet package for |
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.
Since you put this on a new line, it added an extra empty line for all the .cs files that use this .tt file. If you fix this and run custom tool, it'll fix the other cases too (I commented about one)
// Create testing data. Use different random seed to make it different from training data. | ||
var testData = mlContext.Data.LoadFromEnumerable(GenerateRandomDataPoints(5, seed: 123)); | ||
// Create testing data. Use different random seed to make it different | ||
// from training data. |
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 think this tabbing issue may be linked to a .tt or .ttinclude file
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 they're all fixed in the new commit.
string ClassHeader = @"// This example requires installation of additional NuGet package | ||
// <a href=""https://www.nuget.org/packages/Microsoft.ML.FastTree/"">Microsoft.ML.FastTree</a>. "; | ||
string ClassHeader = @" | ||
// This example requires installation of additional NuGet package for |
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 think this will cause the same problem too.
@@ -12,7 +14,9 @@ string TrainerOptions = @"FastTreeTweedieTrainer.Options | |||
LabelColumnName = nameof(DataPoint.Label), | |||
FeatureColumnName = nameof(DataPoint.Features), | |||
// Use L2Norm for early stopping. | |||
EarlyStoppingMetric = Microsoft.ML.Trainers.FastTree.EarlyStoppingMetric.L2Norm, | |||
EarlyStoppingMetric = | |||
Microsoft.ML.Trainers.FastTree.EarlyStoppingMetric.L2Norm, |
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.
tabbing issue
// Use L2-norm for early stopping. If the gradient's L2-norm is | ||
// smaller than an auto-computed value, training process will stop. | ||
EarlyStoppingMetric = | ||
Microsoft.ML.Trainers.FastTree.EarlyStoppingMetric.L2Norm, |
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 the root of the tab issue seen in other .cs files too
string Trainer = @"Gam(labelColumnName: nameof(DataPoint.Label), featureColumnName: nameof(DataPoint.Features))"; | ||
string Trainer = @"Gam( | ||
labelColumnName: nameof(DataPoint.Label), | ||
featureColumnName: nameof(DataPoint.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.
Is this correct? It seems like there are a lot of spaces before it
labelColumnName: labelName, | ||
numberOfLeaves: 4, | ||
minimumExampleCountPerLeaf: 6, | ||
learningRate: 0.001)); |
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.
there are a lot of spaces in front of this
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 pipeline = mlContext.Transforms.Concatenate("Features",
featureNames)
.Append(mlContext.Regression.Trainers.LightGbm(
labelColumnName: labelName,
numberOfLeaves: 4,
minimumExampleCountPerLeaf: 6,
learningRate: 0.001));
foreach (var p in predictions) | ||
Console.WriteLine($"Label: {p.Label:F3}, Prediction: {p.Score:F3}"); | ||
|
||
// This trainer is not numerically stable. Please see issue #2425. | ||
|
||
// This trainer is not numerically stable. Please see issue #2425. |
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.
extra line before. Needs another four spaces to align with the other comments
var metrics = mlContext.Regression.Evaluate(dataWithPredictions, labelColumnName: labelName); | ||
var metrics = mlContext.Regression.Evaluate( | ||
dataWithPredictions, | ||
labelColumnName: labelName); |
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.
needs an empty line after
labelColumnName: labelName, | ||
numberOfLeaves: 4, | ||
minimumExampleCountPerLeaf: 6, | ||
learningRate: 0.001)); |
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.
again a lot of spaces
foreach (var p in predictions) | ||
Console.WriteLine($"Label: {p.Label:F3}, Prediction: {p.Score:F3}"); | ||
|
||
// This trainer is not numerically stable. Please see issue #2425. | ||
|
||
// This trainer is not numerically stable. Please see issue #2425. |
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 need for empty line on 66. Needs spaces to align with the other comments.
|
||
// Evaluate the overall metrics | ||
var metrics = mlContext.Regression.Evaluate(transformedTestData); | ||
PrintMetrics(metrics); | ||
|
||
// This trainer is not numerically stable. Please see issue #2425. | ||
|
||
// This trainer is not numerically stable. Please see issue #2425. |
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 need for empty line on 73. needs spaces to align with the other comments
|
||
.OrderByDescending(feature => Math.Abs( | ||
feature.RootMeanSquaredError.Mean)) | ||
|
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.
lines 54 and 57 are empty lines. the tabbing looks good but you don't need the extra lines.
* Reformatted Regression samples * Untabified comments in tt files. * Removed extra lines * Removed extra lines and added necessary indents
Guidelines followed:
Fix for Issue Samples width: they need to be formatted at 85 characters or less. #3478