Skip to content

Add needed param to warning for L2 in SDCA #597

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
merged 6 commits into from
Jul 30, 2018

Conversation

justinormont
Copy link
Contributor

Closes #596

@@ -209,7 +209,7 @@ internal virtual void Check(IHostEnvironment env)
{
ch.Warning("The specified l2Const = {0} is too small. SDCA optimizes the dual objective function. " +
"The dual formulation is only valid with a positive L2 regularization. Also, an l2Const less than {1} " +
"could drastically slow down the convergence. So using l2Const = {1} instead.", L2Const);
"could drastically slow down the convergence. So using l2Const = {1} instead.", L2Const, L2LowerBound);
Copy link
Contributor

@TomFinley TomFinley Jul 29, 2018

Choose a reason for hiding this comment

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

l2Const [](start = 83, length = 7)

Hi @justinormont thanks for looking at this. Another problem with this message, replace these with nameof(L2Const), here, and everywhere in this message that it is used, in the format args. It might go easier if you used the $ string interpolation. #resolved

@justinormont
Copy link
Contributor Author

@dotnet-bot test OSX10.13 Debug

@justinormont
Copy link
Contributor Author

@TomFinley : Perhaps there's a StyleCop (ref: #553) rule we can enable, which can catch future issues like this mismatched (param count) vs. (count of items in the String.Format-style).

@justinormont justinormont requested a review from abgoswam July 30, 2018 18:08
@TomFinley
Copy link
Contributor

Such a code analysis rule would have to be aware of ch.Warning, ch.Except, and all such other places -- certainly StyleCop is unaware of this. One possible remediation would be to drop all usage of such things, and insist that if people want formatted args, we simply do $ style string interpolation, which just simply works.


In reply to: 408797756 [](ancestors = 408797756)

@TomFinley
Copy link
Contributor

            env.CheckUserArg(L2Const == null || L2Const >= 0, nameof(L2Const), "L2 constant must be non-negative.");

If you wanted to improve these messages while you're at it so they don't contain this redundant information that would be nice. E.g., "``L2 constant must be non-negative"should just be "Must be non-negative."`, similar for other messages here that needlessly re-identify what paramater they're talking about, despite the fact that the name of the parameter is already part of the error message.


Refers to: src/Microsoft.ML.StandardLearners/Standard/LinearClassificationTrainer.cs:201 in dc42fee. [](commit_id = dc42fee, deletion_comment = False)

Copy link
Contributor

@TomFinley TomFinley left a comment

Choose a reason for hiding this comment

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

Thanks @justinormont . If you wanted to improve those other badly structured messages preceding your changes that would also help improve our overall quality.

Copy link
Member

@abgoswam abgoswam left a comment

Choose a reason for hiding this comment

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

:shipit:

@justinormont
Copy link
Contributor Author

@TomFinley : I did a pass of word-smithing.

The warning now reads as:
Warning: The L2 regularization constant must be at least 1E-09. In SDCA, the dual formulation is only valid with a positive constant, and values below 1E-09 cause very slow convergence. The original L2Const = 0, was replaced with L2Const = 1E-09.

@justinormont justinormont merged commit 98318b6 into dotnet:master Jul 30, 2018
@justinormont justinormont deleted the sdca-l2-fix branch July 31, 2018 17:11
codemzs pushed a commit to codemzs/machinelearning that referenced this pull request Aug 1, 2018
* Fix warning for L2 in SDCA

* String interpolation

* Word-smithing the warning message
@ghost ghost locked as resolved and limited conversation to collaborators Mar 29, 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.

3 participants