Skip to content

Lockdown Microsoft.ML.FastTree public surface #2511

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
Feb 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions src/Microsoft.ML.Data/Dirty/PredictorInterfaces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,6 @@ internal interface IQuantileValueMapper
ValueMapper<VBuffer<float>, VBuffer<float>> GetMapper(float[] quantiles);
}

/// <summary>
/// Interface for quantile distribution
/// </summary>
/// <typeparam name="TResult">Type of statistics result</typeparam>
[BestFriend]
internal interface IQuantileDistribution<TResult> : IDistribution<TResult>, ISampleableDistribution<TResult>
{
TResult Median { get; }

/// <summary>
/// Returns an estimate of the p-th quantile, the data value where proportionately p of the data has value
/// less than or equal to the returned value.
/// </summary>
TResult GetQuantile(float p);
}

[BestFriend]
internal interface ISampleableDistribution<TResult> : IDistribution<TResult>
{
Expand Down
16 changes: 8 additions & 8 deletions src/Microsoft.ML.FastTree/BoostingFastTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ public abstract class BoostingFastTreeTrainerBase<TArgs, TTransformer, TModel> :
where TArgs : BoostedTreeArgs, new()
where TModel : class
{
protected BoostingFastTreeTrainerBase(IHostEnvironment env, TArgs args, SchemaShape.Column label) : base(env, args, label)
private protected BoostingFastTreeTrainerBase(IHostEnvironment env, TArgs args, SchemaShape.Column label) : base(env, args, label)
{
}

protected BoostingFastTreeTrainerBase(IHostEnvironment env,
private protected BoostingFastTreeTrainerBase(IHostEnvironment env,
SchemaShape.Column label,
string featureColumn,
string weightColumn,
Expand All @@ -32,7 +32,7 @@ protected BoostingFastTreeTrainerBase(IHostEnvironment env,
FastTreeTrainerOptions.LearningRates = learningRate;
}

protected override void CheckArgs(IChannel ch)
private protected override void CheckArgs(IChannel ch)
{
if (FastTreeTrainerOptions.OptimizationAlgorithm == BoostedTreeArgs.OptimizationAlgorithmType.AcceleratedGradientDescent)
FastTreeTrainerOptions.UseLineSearch = true;
Expand Down Expand Up @@ -102,7 +102,7 @@ private protected override OptimizationAlgorithm ConstructOptimizationAlgorithm(
return optimizationAlgorithm;
}

protected override IGradientAdjuster MakeGradientWrapper(IChannel ch)
private protected override IGradientAdjuster MakeGradientWrapper(IChannel ch)
{
if (!FastTreeTrainerOptions.BestStepRankingRegressionTrees)
return base.MakeGradientWrapper(ch);
Expand All @@ -115,7 +115,7 @@ protected override IGradientAdjuster MakeGradientWrapper(IChannel ch)
return new BestStepRegressionGradientWrapper();
}

protected override bool ShouldStop(IChannel ch, ref IEarlyStoppingCriterion earlyStoppingRule, ref int bestIteration)
private protected override bool ShouldStop(IChannel ch, ref IEarlyStoppingCriterion earlyStoppingRule, ref int bestIteration)
{
if (FastTreeTrainerOptions.EarlyStoppingRule == null)
return false;
Expand Down Expand Up @@ -147,7 +147,7 @@ protected override bool ShouldStop(IChannel ch, ref IEarlyStoppingCriterion earl
return shouldStop;
}

protected override int GetBestIteration(IChannel ch)
private protected override int GetBestIteration(IChannel ch)
{
int bestIteration = Ensemble.NumTrees;
if (!FastTreeTrainerOptions.WriteLastEnsemble && PruningTest != null)
Expand All @@ -161,15 +161,15 @@ protected override int GetBestIteration(IChannel ch)
/// <summary>
/// Retrieves max tree output if best regression step option is active or returns negative value otherwise.
/// </summary>
protected double BsrMaxTreeOutput()
private protected double BsrMaxTreeOutput()
{
if (FastTreeTrainerOptions.BestStepRankingRegressionTrees)
return FastTreeTrainerOptions.MaxTreeOutput;
else
return -1;
}

protected override bool ShouldRandomStartOptimizer()
private protected override bool ShouldRandomStartOptimizer()
{
return FastTreeTrainerOptions.RandomStart;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.ML.FastTree/Dataset/Dataset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Microsoft.ML.Trainers.FastTree
/// <summary>
/// A dataset of features.
/// </summary>
public sealed class Dataset
internal sealed class Dataset
{
private readonly DatasetSkeleton _datasetSkeleton;
private readonly FeatureFlockBase[] _flocks;
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.ML.FastTree/Dataset/DatasetUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Microsoft.ML.Trainers.FastTree
/// <summary>
/// Loads training/validation/test sets from file
/// </summary>
public static class DatasetUtils
internal static class DatasetUtils
{
private const string DefaultTransformFormat = "Name={0}\nTransform=Linear\nSlope=1\nIntercept=0";

Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.ML.FastTree/Dataset/Feature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Microsoft.ML.Trainers.FastTree
/// <summary>
/// Represents a binned feature
/// </summary>
public abstract class Feature
internal abstract class Feature
{
private IntArray _bins;

Expand Down Expand Up @@ -190,7 +190,7 @@ public IntArray Bins
}
}

public sealed class TsvFeature : Feature
internal sealed class TsvFeature : Feature
{
private readonly uint[] _valueMap;
private string _name;
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.ML.FastTree/Dataset/FeatureFlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace Microsoft.ML.Trainers.FastTree
/// are then used in <see cref="LeastSquaresRegressionTreeLearner"/> to find splitting on which bin will yield the
/// best least squares solution
/// </summary>
public readonly struct PerBinStats
internal readonly struct PerBinStats
{
/// <summary>Sum of all target values in a partition for the bin.</summary>
public readonly Double SumTargets;
Expand Down Expand Up @@ -967,7 +967,7 @@ protected sealed override void SubtractCore(SufficientStatsBase other)
/// <see cref="Dataset.MapFeatureToFlockAndSubFeature"/> to see some details of this
/// dataset-wide versus flock-wide feature index.
/// </summary>
public abstract class FeatureFlockBase
internal abstract class FeatureFlockBase
{
/// <summary>
/// The number of features contained within this flock.
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.ML.FastTree/Dataset/FeatureHistogram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Microsoft.ML.Trainers.FastTree
/// <summary>
/// Class to represent statistics of the feature used by LeastSquaresRegressionTreeLearner
/// </summary>
public sealed class FeatureHistogram
internal sealed class FeatureHistogram
{
public readonly FloatType[] SumTargetsByBin;
public readonly double[] SumWeightsByBin;
Expand Down Expand Up @@ -138,7 +138,7 @@ public void SumupWeighted(int numDocsInLeaf, double sumTargets, double sumWeight
}
}

public sealed class SumupInputData
internal sealed class SumupInputData
{
public int TotalCount;
public double SumTargets;
Expand Down
8 changes: 4 additions & 4 deletions src/Microsoft.ML.FastTree/Dataset/IntArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ namespace Microsoft.ML.Trainers.FastTree
#else
#endif

public enum IntArrayType { Dense, Sparse, Repeat, Segmented, Current };
public enum IntArrayBits { Bits32 = 32, Bits16 = 16, Bits10 = 10, Bits8 = 8, Bits4 = 4, Bits1 = 1, Bits0 = 0 };
internal enum IntArrayType { Dense, Sparse, Repeat, Segmented, Current };
internal enum IntArrayBits { Bits32 = 32, Bits16 = 16, Bits10 = 10, Bits8 = 8, Bits4 = 4, Bits1 = 1, Bits0 = 0 };

/// <summary>
/// An object representing an array of integers
/// </summary>
public abstract class IntArray : IEnumerable<int>
internal abstract class IntArray : IEnumerable<int>
{
// The level of compression to use with features.
// 0x1 - Use 10 bit.
Expand Down Expand Up @@ -360,7 +360,7 @@ public IntArray Compress(uint[] workarray = null)
/// <summary>
/// Interface for objects that can index into an <see cref="IntArray"/>, but only with a non-decreasing sequence of indices.
/// </summary>
public interface IIntArrayForwardIndexer
internal interface IIntArrayForwardIndexer
{
/// <summary>
/// Gets the element at the given index.
Expand Down
Loading