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

Public API for KMeansPredictor #1739

Merged
merged 12 commits into from
Dec 5, 2018
Merged

Conversation

najeeb-kazmi
Copy link
Member

Fixes #1699

@@ -169,7 +172,7 @@ private void Map(in VBuffer<Float> src, Span<Float> distances)
}
}

public void SaveAsText(TextWriter writer, RoleMappedSchema schema)
void ICanSaveInTextFormat.SaveAsText(TextWriter writer, RoleMappedSchema schema)
Copy link
Member

Choose a reason for hiding this comment

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

Is it private?

{
/// <include file='./doc.xml' path='doc/members/member[@name="KMeans++"]/*' />
public class KMeansPlusPlusTrainer : TrainerEstimatorBase<ClusteringPredictionTransformer<KMeansPredictor>, KMeansPredictor>
public class KMeansPlusPlusTrainer : TrainerEstimatorBase<ClusteringPredictionTransformer<KMeansModelParameters>, KMeansModelParameters>
Copy link
Member

Choose a reason for hiding this comment

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

Can Visual Studio retrieve the doc in xml? If not, we need to add enough information here.

@najeeb-kazmi najeeb-kazmi changed the title WIP: Public API for KMeansPredictor Public API for KMeansPredictor Nov 28, 2018
@@ -185,7 +185,8 @@ protected LinearPredictor(IHostEnvironment env, string name, ModelLoadContext ct
_weightsDenseLock = new object();
}

protected override void SaveCore(ModelSaveContext ctx)
[BestFriend]
private protected override void SaveCore(ModelSaveContext ctx)
Copy link
Member

Choose a reason for hiding this comment

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

private [](start = 8, length = 7)

This is already a protected function on an internal class -- isn't that already hidden?

Copy link
Member

Choose a reason for hiding this comment

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

Sorry I misread - it is a public class and you are overriding SaveCore from PredictorBase which is protected. However, I dont quite follow how protected isnt hidden to begin with -- is this covering cases where classes derive from LinearPredictor? Also could LinearPredictor be internal?


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

Copy link
Contributor

@TomFinley TomFinley Dec 4, 2018

Choose a reason for hiding this comment

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

Hi @singlis , sorry just saw this now -- protected is absolutely not hidden. It won't show up in usage of instances, but will show up in docs and other contexts.

@singlis
Copy link
Member

singlis commented Nov 28, 2018

using Microsoft.ML.Trainers.Recommender;

can you sort the headers here...


Refers to: test/Microsoft.ML.StaticPipelineTesting/Training.cs:22 in 58aa330. [](commit_id = 58aa330, deletion_comment = False)

@TomFinley
Copy link
Contributor

    public void SaveAsText(TextWriter writer, RoleMappedSchema schema)

Hi @najeeb-kazmi, thanks for doing this! The corresponding interface has been made internal, should we make these explicit implementations here and everywhere? It requires a little bit of work, but no more than you've already done for the SaveCore stuff.


Refers to: src/Microsoft.ML.FastTree/FastTree.cs:2968 in 073ff03. [](commit_id = 073ff03, deletion_comment = False)

@@ -296,7 +296,7 @@ private OlsLinearRegressionPredictor TrainCore(IChannel ch, FloatLabelCursor.Fac
Double tss = 0; // total sum of squares
using (var cursor = cursorFactory.Create())
{
var lrPredictor = new LinearRegressionPredictor(Host, in weights, bias);
IValueMapper lrPredictor = new LinearRegressionPredictor(Host, in weights, bias);
Copy link
Contributor

Choose a reason for hiding this comment

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

IValueMapper lrPredictor [](start = 16, length = 24)

Good stuff

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.

Thank you for dogin this @najeeb-kazmi !! This will lay the groundwork for lots more hiding in future.


namespace Microsoft.ML.Trainers.KMeans
namespace Microsoft.ML.KMeansClustering
Copy link
Member

Choose a reason for hiding this comment

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

Microsoft.ML.KMeansClustering [](start = 10, length = 29)

i wonder if we want to put all predictors in something:

Microsoft.ML.ModelParameters.KMeansClustering

Copy link
Contributor

Choose a reason for hiding this comment

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

If the argument is that the namespace is "Trainers" and therefore only ITrainer implementors should live in that namespace, then I'd argue that we should not have "Trainers" in the namespace name, if you think it could cause confusion.

It would be very inconvenient to have predictors in a different namespace from their associated trainers (except in generalizable cases like linear predictors that can be produced by many things).


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

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe Microsoft.ML.KMeans would be a better namespace, but let's not have one namespace every time we devise a new type that isn't a trainer, a predictor, or whatever. 😛

Copy link
Member Author

Choose a reason for hiding this comment

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

So both the trainer and predictor would be in Microsoft.ML.KMeansClustering. That is what I gather from @Zruty0 's description in #1699 .

Copy link
Member

Choose a reason for hiding this comment

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

On #1318 there was an explicit ask to put all the trainers inside Microsoft.ML.Trainers or appropriate namaspaces.

So if i read both those issues, the ModelParameters also go in the same namespace as the respective trainer; for this case Microsoft.ML.Trainers.Kmeans @TomFinley that sounds good?

Copy link
Member Author

Choose a reason for hiding this comment

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

That makes sense. I'll stick to the conventions in #1318 and revert the namespace to Microsoft.ML.Trainers.KMeans.

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:

@najeeb-kazmi najeeb-kazmi merged commit a087ec5 into dotnet:master Dec 5, 2018
@najeeb-kazmi najeeb-kazmi deleted the 1699 branch January 30, 2020 01:12
@ghost ghost locked as resolved and limited conversation to collaborators Mar 26, 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