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

Modify API for advanced settings (MatrixFactorizationTrainer) #2204

Merged
merged 6 commits into from Jan 26, 2019

Conversation

abgoswam
Copy link
Member

@abgoswam abgoswam commented Jan 22, 2019

Towards #1798 .

This PR addresses the following algos

  • MatrixFactorizationTrainer

The following changes have been made:

  1. Two public extension methods, one for simple arguments and the other for advanced options
  2. Make constructors internal . Also a few other fields have been made internal
  3. Pass Options objects as arguments instead of Action delegate. Also, added 3 fields to Options for API consistency.
  4. Rename Arguments to Options
  5. Rename Options objects as options (instead of args or advancedSettings used so far)

/// <remarks>
/// <para>The basic idea of matrix factorization is finding two low-rank factor marcies to apporimate the training matrix.</para>
/// <para>In this module, the expected training data is a list of tuples. Every tuple consists of a column index, a row index,
/// and the value at the location specified by the two indexes.
Copy link
Member

@wschin wschin Jan 23, 2019

Choose a reason for hiding this comment

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

Could you add a reference to Options in the doc string?

Suggested change
/// and the value at the location specified by the two indexes.
/// and the value at the location specified by the two indexes. The training configuration is encoded in <see cref="Options>.
``` #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

added


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

.Append(r => (r.label, score: mlContext.Regression.Trainers.MatrixFactorization(r.label, r.matrixRowIndex, r.matrixColumnIndex, onFit: p => pred = p,
advancedSettings: args => { args.NumThreads = 1; })));
.Append(r => (r.label, score: mlContext.Regression.Trainers.MatrixFactorization(
r.label, r.matrixRowIndex, r.matrixColumnIndex,
Copy link
Member

@wschin wschin Jan 23, 2019

Choose a reason for hiding this comment

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

This and the following 2 lines got too many indents? #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

i found this slightly easier to read. did a control+k+d on this file


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

MatrixRowIndexColumnName = itemColumnName,
LabelColumnName = labelColumnName,
NumIterations = 3,
NumThreads = 1,
Copy link
Member

@wschin wschin Jan 23, 2019

Choose a reason for hiding this comment

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

Please copy my old comment. Thanks. #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

added back


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

MatrixRowIndexColumnName = nameof(MatrixElement.MatrixRowIndex),
LabelColumnName = nameof(MatrixElement.Value),
NumIterations = 10,
NumThreads = 1,
Copy link
Member

@wschin wschin Jan 23, 2019

Choose a reason for hiding this comment

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

Same here. Please copy my comment on NumThread. #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed


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

MatrixRowIndexColumnName = nameof(MatrixElement.MatrixRowIndex),
LabelColumnName = nameof(MatrixElement.Value),
NumIterations = 100,
NumThreads = 1,
Copy link
Member

@wschin wschin Jan 23, 2019

Choose a reason for hiding this comment

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

May we have my old comment back? :) #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed


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

LabelColumnName = nameof(MatrixElement.Value),
LossFunction = MatrixFactorizationTrainer.LossFunctionType.SquareLossOneClass,
NumIterations = 100,
NumThreads = 1,
Copy link
Member

@wschin wschin Jan 23, 2019

Choose a reason for hiding this comment

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

Missing my old comment. #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed


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

Copy link
Member

@wschin wschin left a comment

Choose a reason for hiding this comment

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

Just some minor comments. Overall LGTM.

@codemzs codemzs closed this Jan 24, 2019
@codemzs codemzs reopened this Jan 24, 2019
@codecov
Copy link

codecov bot commented Jan 24, 2019

Codecov Report

Merging #2204 into master will not change coverage.
The diff coverage is 95.6%.

@@           Coverage Diff           @@
##           master    #2204   +/-   ##
=======================================
  Coverage   69.78%   69.78%           
=======================================
  Files         786      786           
  Lines      143945   143945           
  Branches    16648    16642    -6     
=======================================
  Hits       100451   100451           
+ Misses      38951    38949    -2     
- Partials     4543     4545    +2
Flag Coverage Δ
#Debug 69.78% <95.6%> (ø) ⬆️
#production 66.13% <87.09%> (-0.01%) ⬇️
#test 84.92% <100%> (ø) ⬆️


/// <summary>
/// The <see cref="TrainerInfo"/> contains general parameters for this trainer.
/// </summary>
public override TrainerInfo Info { get; }

/// <summary>
/// Legacy constructor initializing a new instance of <see cref="MatrixFactorizationTrainer"/> through the legacy
/// <see cref="Arguments"/> class.
/// Constructor initializing a new instance of <see cref="MatrixFactorizationTrainer"/> through the <see cref="Options"/> class.
Copy link
Member

@sfilipi sfilipi Jan 25, 2019

Choose a reason for hiding this comment

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

Constructor initializing [](start = 12, length = 24)

replace with "Initializes".

That seems to be standard for .net docs for ctors. #Resolved

/// <param name="args">An instance of the legacy <see cref="Arguments"/> to apply advanced parameters to the algorithm.</param>
private MatrixFactorizationTrainer(IHostEnvironment env, Arguments args) : base(env, LoadNameValue)
/// <param name="options">An instance of <see cref="Options"/> to apply advanced parameters to the algorithm.</param>
internal MatrixFactorizationTrainer(IHostEnvironment env, Options options) : base(env, LoadNameValue)
Copy link
Member

@sfilipi sfilipi Jan 25, 2019

Choose a reason for hiding this comment

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

internal [](start = 8, length = 8)

think @Ivanidzo4ka asked for those marked with [BestFriend] #Resolved

/// </para>
/// </remarks>
/// <param name="options">Advanced arguments to the algorithm.</param>
public MatrixFactorizationTrainer MatrixFactorization(
Copy link
Member

Choose a reason for hiding this comment

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

public MatrixFactorizationTrainer MatrixFactorization [](start = 9, length = 56)

please link to the Matrix factorization sample.

Copy link
Member

@sfilipi sfilipi left a comment

Choose a reason for hiding this comment

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

:shipit:

@abgoswam abgoswam merged commit 2497833 into dotnet:master Jan 26, 2019
@abgoswam abgoswam deleted the abgoswam/action_arguments_mf branch February 20, 2019 16:59
@dotnet dotnet locked as resolved and limited conversation to collaborators Mar 25, 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.

None yet

4 participants