Skip to content

Public API for Tree predictors #1837

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
Dec 11, 2018
Merged

Conversation

najeeb-kazmi
Copy link
Member

@najeeb-kazmi najeeb-kazmi commented Dec 6, 2018

Fix #1701

Internalized and explicitly implemented the following interfaces implemented by FastTreePredictionWrapper:

  • ICanSaveInIniFormat
  • ICanSaveInSourceCode
  • ICanSaveSummary
  • ICanSaveSummaryInKeyValuePairs
  • ICanGetSummaryAsIRow
  • IFeatureContributionMapper
  • IQuantileValueMapper
  • IQuantileRegressionPredictor
  • IValueMapperDist

Renamed FastTreePredictionWrapper to TreeEnsembleModelParameters and descendants to XYZModelParameters. Reduced public surface of TreeEnsembleModelParameters and descendants.

Added public constructors for TreeEnsembleModelParameters and descendants.

Added a sample showing FastTreeRegressionModelParameters operations.

…ourceCode, ICanSaveSummary, ICanSaveSummaryInKeyValuePairs, and ICanGetSummaryAsIRow
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.

🕐

…ntileValueMapper, IQuantileRegressionPredictor. Rename FastTreePredictionWrapper to TreeEnsembleModelParameters and all descendants to XyzModelParameters
@najeeb-kazmi najeeb-kazmi changed the title [WIP] Public API for Tree predictors Public API for Tree predictors Dec 11, 2018
@@ -467,12 +467,12 @@ private static VersionInfo GetVersionInfo()

protected override uint VerCategoricalSplitSerialized => 0x00010005;

internal FastTreeRegressionPredictor(IHostEnvironment env, TreeEnsemble trainedEnsemble, int featureCount, string innerArgs)
Copy link
Member

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)

i still think those should be internal. There is nothing else that can create the predictor/model params besides training..
Only the class needs to be public IMO.. but I won't block on it.. you can take it with Tom/Pete and potentially change on a later PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense. I'll keep these constructors public for now.

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:

@wschin
Copy link
Member

wschin commented Dec 11, 2018

    public const string LoadNameValue = "FastTreeBinaryClassification";

Can this be internal or even more conservative? #Resolved


Refers to: src/Microsoft.ML.FastTree/FastTreeClassification.cs:111 in a5aa3b9. [](commit_id = a5aa3b9, deletion_comment = False)

@wschin
Copy link
Member

wschin commented Dec 11, 2018

    public const string LoaderSignature = "RandomPredictor";

internal? #Resolved


Refers to: src/Microsoft.ML.StandardLearners/Standard/Simple/SimpleTrainers.cs:114 in a5aa3b9. [](commit_id = a5aa3b9, deletion_comment = False)

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.

LGTM. Just some minor comments but please still address them before merging.

// Get the leaf and the leaf value for a row of data with Parity = 1, Induced = 1 in the first tree.
var testRow = new VBuffer<float>(2, new[] { 1.0f, 1.0f });
List<int> path = default;
var leaf = modelParams.GetLeaf(0, in testRow, ref path);
Copy link
Contributor

Choose a reason for hiding this comment

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

var leaf = modelParams.GetLeaf(0, in testRow, ref path); [](start = 12, length = 56)

How many leaves you have in this tree?
If it's only few, can we actually read all leaf values, and also their relationship and drew small tree in comments?

like

(node 0, value: 1.1)
|(left)
|---->(leaf 0, value: 2.4)
|
|(right)
|---> (leaf 1,value: 3.5)

@najeeb-kazmi najeeb-kazmi merged commit 25abf91 into dotnet:master Dec 11, 2018
@najeeb-kazmi najeeb-kazmi deleted the 1701 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.

4 participants