diff --git a/src/Microsoft.ML.Core/Data/InPredicate.cs b/src/Microsoft.ML.Core/Data/InPredicate.cs index 3c35bf600a..86d716356a 100644 --- a/src/Microsoft.ML.Core/Data/InPredicate.cs +++ b/src/Microsoft.ML.Core/Data/InPredicate.cs @@ -4,5 +4,6 @@ namespace Microsoft.ML.Data { - public delegate bool InPredicate(in T value); + [BestFriend] + internal delegate bool InPredicate(in T value); } diff --git a/src/Microsoft.ML.Data/DataLoadSave/TransformWrapper.cs b/src/Microsoft.ML.Data/DataLoadSave/TransformWrapper.cs index 0014ae638e..c822568cf1 100644 --- a/src/Microsoft.ML.Data/DataLoadSave/TransformWrapper.cs +++ b/src/Microsoft.ML.Data/DataLoadSave/TransformWrapper.cs @@ -168,26 +168,4 @@ public SchemaShape GetOutputSchema(SchemaShape inputSchema) return SchemaShape.Create(transformer.GetOutputSchema(fakeSchema)); } } - - /// - /// Estimator for untrained wrapped transformers. - /// - public abstract class TrivialWrapperEstimator : TrivialEstimator - { - protected TrivialWrapperEstimator(IHost host, TransformWrapper transformer) - : base(host, transformer) - { - } - - /// - /// Returns the of the schema which will be produced by the transformer. - /// Used for schema propagation and verification in a pipeline. - /// - public override SchemaShape GetOutputSchema(SchemaShape inputSchema) - { - Host.CheckValue(inputSchema, nameof(inputSchema)); - var fakeSchema = FakeSchemaFactory.Create(inputSchema); - return SchemaShape.Create(Transformer.GetOutputSchema(fakeSchema)); - } - } } diff --git a/src/Microsoft.ML.Data/Dirty/ILoss.cs b/src/Microsoft.ML.Data/Dirty/ILoss.cs index 1bb1350e0b..6e35c17bea 100644 --- a/src/Microsoft.ML.Data/Dirty/ILoss.cs +++ b/src/Microsoft.ML.Data/Dirty/ILoss.cs @@ -4,7 +4,6 @@ using System; using Microsoft.ML.EntryPoints; -using Float = System.Single; namespace Microsoft.ML { @@ -17,12 +16,12 @@ public interface ILossFunction Double Loss(TOutput output, TLabel label); } - public interface IScalarOutputLoss : ILossFunction + public interface IScalarOutputLoss : ILossFunction { /// /// Derivative of the loss function with respect to output /// - Float Derivative(Float output, Float label); + float Derivative(float output, float label); } [TlcModule.ComponentKind("RegressionLossFunction")] @@ -46,10 +45,10 @@ public interface IClassificationLoss : IScalarOutputLoss /// /// Delegate signature for standardized classification loss functions. /// - public delegate void SignatureClassificationLoss(); + internal delegate void SignatureClassificationLoss(); /// /// Delegate signature for standardized regression loss functions. /// - public delegate void SignatureRegressionLoss(); + internal delegate void SignatureRegressionLoss(); } diff --git a/src/Microsoft.ML.Data/Transforms/ValueToKeyMappingEstimator.cs b/src/Microsoft.ML.Data/Transforms/ValueToKeyMappingEstimator.cs index 1b2106ccaa..9521da3766 100644 --- a/src/Microsoft.ML.Data/Transforms/ValueToKeyMappingEstimator.cs +++ b/src/Microsoft.ML.Data/Transforms/ValueToKeyMappingEstimator.cs @@ -159,25 +159,4 @@ public enum KeyValueOrder : byte /// Value = ValueToKeyMappingEstimator.SortOrder.Value } - - /// - /// Information on the result of fitting a to-key transform. - /// - /// The type of the values. - public sealed class ToKeyFitResult - { - /// - /// For user defined delegates that accept instances of the containing type. - /// - /// - public delegate void OnFit(ToKeyFitResult result); - - // At the moment this is empty. Once PR #863 clears, we can change this class to hold the output - // key-values metadata. - - [BestFriend] - internal ToKeyFitResult(ValueToKeyMappingTransformer.TermMap map) - { - } - } } diff --git a/src/Microsoft.ML.FastTree/GamClassification.cs b/src/Microsoft.ML.FastTree/GamClassification.cs index fb7262ece8..92c65471c9 100644 --- a/src/Microsoft.ML.FastTree/GamClassification.cs +++ b/src/Microsoft.ML.FastTree/GamClassification.cs @@ -180,7 +180,7 @@ public sealed class BinaryClassificationGamModelParameters : GamModelParametersB /// A map from the feature shape functions (as described by the binUpperBounds and BinEffects) /// to the input feature. Used when the number of input features is different than the number of shape functions. Use default if all features have /// a shape function. - public BinaryClassificationGamModelParameters(IHostEnvironment env, + internal BinaryClassificationGamModelParameters(IHostEnvironment env, double[][] binUpperBounds, double[][] binEffects, double intercept, int inputLength, int[] featureToInputMap) : base(env, LoaderSignature, binUpperBounds, binEffects, intercept, inputLength, featureToInputMap) { } diff --git a/src/Microsoft.ML.FastTree/GamRegression.cs b/src/Microsoft.ML.FastTree/GamRegression.cs index c3defd7990..cc8a57532f 100644 --- a/src/Microsoft.ML.FastTree/GamRegression.cs +++ b/src/Microsoft.ML.FastTree/GamRegression.cs @@ -126,7 +126,7 @@ public sealed class RegressionGamModelParameters : GamModelParametersBase /// A map from the feature shape functions (as described by the binUpperBounds and BinEffects) /// to the input feature. Used when the number of input features is different than the number of shape functions. Use default if all features have /// a shape function. - public RegressionGamModelParameters(IHostEnvironment env, + internal RegressionGamModelParameters(IHostEnvironment env, double[][] binUpperBounds, double[][] binEffects, double intercept, int inputLength = -1, int[] featureToInputMap = null) : base(env, LoaderSignature, binUpperBounds, binEffects, intercept, inputLength, featureToInputMap) { } diff --git a/src/Microsoft.ML.PCA/PcaTrainer.cs b/src/Microsoft.ML.PCA/PcaTrainer.cs index abf2c8dbae..654cac0bdb 100644 --- a/src/Microsoft.ML.PCA/PcaTrainer.cs +++ b/src/Microsoft.ML.PCA/PcaTrainer.cs @@ -411,7 +411,7 @@ private static VersionInfo GetVersionInfo() /// The rank of the PCA approximation of the covariance matrix. This is the number of eigenvectors in the model. /// Array of eigenvectors. /// The mean vector of the training data. - public PcaModelParameters(IHostEnvironment env, int rank, float[][] eigenVectors, in VBuffer mean) + internal PcaModelParameters(IHostEnvironment env, int rank, float[][] eigenVectors, in VBuffer mean) : base(env, RegistrationName) { _dimension = eigenVectors[0].Length; diff --git a/src/Microsoft.ML.StandardLearners/FactorizationMachine/FieldAwareFactorizationMachineModelParameters.cs b/src/Microsoft.ML.StandardLearners/FactorizationMachine/FieldAwareFactorizationMachineModelParameters.cs index 80b7e10d35..78000c948d 100644 --- a/src/Microsoft.ML.StandardLearners/FactorizationMachine/FieldAwareFactorizationMachineModelParameters.cs +++ b/src/Microsoft.ML.StandardLearners/FactorizationMachine/FieldAwareFactorizationMachineModelParameters.cs @@ -57,7 +57,7 @@ private static VersionInfo GetVersionInfo() /// and each latent vector contains values. In the f-th field, the j-th feature's latent vector, `v_{j, f}` in the doc /// https://github.com/wschin/fast-ffm/blob/master/fast-ffm.pdf, starts at latentWeights[j * fieldCount * latentDim + f * latentDim]. /// The k-th element in v_{j, f} is latentWeights[j * fieldCount * latentDim + f * latentDim + k]. The size of the array must be featureCount x fieldCount x latentDim. - public FieldAwareFactorizationMachineModelParameters(IHostEnvironment env, bool norm, int fieldCount, int featureCount, int latentDim, + internal FieldAwareFactorizationMachineModelParameters(IHostEnvironment env, bool norm, int fieldCount, int featureCount, int latentDim, float[] linearWeights, float[] latentWeights) : base(env, LoaderSignature) { Host.Assert(fieldCount > 0); diff --git a/src/Microsoft.ML.StandardLearners/Standard/LinearModelParameters.cs b/src/Microsoft.ML.StandardLearners/Standard/LinearModelParameters.cs index 33d9823e65..e72c6c5615 100644 --- a/src/Microsoft.ML.StandardLearners/Standard/LinearModelParameters.cs +++ b/src/Microsoft.ML.StandardLearners/Standard/LinearModelParameters.cs @@ -115,7 +115,7 @@ public IEnumerator GetEnumerator() /// The weights for the linear model. The i-th element of weights is the coefficient /// of the i-th feature. Note that this will take ownership of the . /// The bias added to every output score. - public LinearModelParameters(IHostEnvironment env, string name, in VBuffer weights, float bias) + internal LinearModelParameters(IHostEnvironment env, string name, in VBuffer weights, float bias) : base(env, name) { Host.CheckParam(FloatUtils.IsFinite(weights.GetValues()), nameof(weights), "Cannot initialize linear predictor with non-finite weights"); @@ -436,7 +436,7 @@ private static VersionInfo GetVersionInfo() /// of the i-th feature. Note that this will take ownership of the . /// The bias added to every output score. /// - public LinearBinaryModelParameters(IHostEnvironment env, in VBuffer weights, float bias, LinearModelStatistics stats = null) + internal LinearBinaryModelParameters(IHostEnvironment env, in VBuffer weights, float bias, LinearModelStatistics stats = null) : base(env, RegistrationName, in weights, bias) { Contracts.AssertValueOrNull(stats); @@ -604,7 +604,7 @@ private static VersionInfo GetVersionInfo() /// The weights for the linear model. The i-th element of weights is the coefficient /// of the i-th feature. Note that this will take ownership of the . /// The bias added to every output score. - public LinearRegressionModelParameters(IHostEnvironment env, in VBuffer weights, float bias) + internal LinearRegressionModelParameters(IHostEnvironment env, in VBuffer weights, float bias) : base(env, RegistrationName, in weights, bias) { } @@ -687,7 +687,7 @@ private static VersionInfo GetVersionInfo() /// The weights for the linear model. The i-th element of weights is the coefficient /// of the i-th feature. Note that this will take ownership of the . /// The bias added to every output score. - public PoissonRegressionModelParameters(IHostEnvironment env, in VBuffer weights, float bias) + internal PoissonRegressionModelParameters(IHostEnvironment env, in VBuffer weights, float bias) : base(env, RegistrationName, in weights, bias) { } diff --git a/src/Microsoft.ML.StandardLearners/Standard/LogisticRegression/MulticlassLogisticRegression.cs b/src/Microsoft.ML.StandardLearners/Standard/LogisticRegression/MulticlassLogisticRegression.cs index 815b7b30ba..224921adc8 100644 --- a/src/Microsoft.ML.StandardLearners/Standard/LogisticRegression/MulticlassLogisticRegression.cs +++ b/src/Microsoft.ML.StandardLearners/Standard/LogisticRegression/MulticlassLogisticRegression.cs @@ -434,7 +434,7 @@ internal MulticlassLogisticRegressionModelParameters(IHostEnvironment env, in VB /// The length of the feature vector. /// The optional label names. If specified not null, it should have the same length as . /// The model statistics. - public MulticlassLogisticRegressionModelParameters(IHostEnvironment env, VBuffer[] weights, float[] bias, int numClasses, int numFeatures, string[] labelNames, LinearModelStatistics stats = null) + internal MulticlassLogisticRegressionModelParameters(IHostEnvironment env, VBuffer[] weights, float[] bias, int numClasses, int numFeatures, string[] labelNames, LinearModelStatistics stats = null) : base(env, RegistrationName) { Contracts.CheckValue(weights, nameof(weights)); diff --git a/src/Microsoft.ML.StandardLearners/Standard/MultiClass/MultiClassNaiveBayesTrainer.cs b/src/Microsoft.ML.StandardLearners/Standard/MultiClass/MultiClassNaiveBayesTrainer.cs index e3db654b18..9549e8d95f 100644 --- a/src/Microsoft.ML.StandardLearners/Standard/MultiClass/MultiClassNaiveBayesTrainer.cs +++ b/src/Microsoft.ML.StandardLearners/Standard/MultiClass/MultiClassNaiveBayesTrainer.cs @@ -254,7 +254,7 @@ public void GetFeatureHistogram(ref int[][] featureHistogram, out int labelCount /// The histogram of labels. /// The feature histogram. /// The number of features. - public MultiClassNaiveBayesModelParameters(IHostEnvironment env, int[] labelHistogram, int[][] featureHistogram, int featureCount) + internal MultiClassNaiveBayesModelParameters(IHostEnvironment env, int[] labelHistogram, int[][] featureHistogram, int featureCount) : base(env, LoaderSignature) { Host.AssertValue(labelHistogram); diff --git a/src/Microsoft.ML.StaticPipe/CategoricalStaticExtensions.cs b/src/Microsoft.ML.StaticPipe/CategoricalStaticExtensions.cs index af2e47fe66..11ccbbb6a5 100644 --- a/src/Microsoft.ML.StaticPipe/CategoricalStaticExtensions.cs +++ b/src/Microsoft.ML.StaticPipe/CategoricalStaticExtensions.cs @@ -7,6 +7,7 @@ using Microsoft.ML.StaticPipe.Runtime; using Microsoft.ML.Transforms.Categorical; using Microsoft.ML.Transforms.Conversions; +using static Microsoft.ML.StaticPipe.TermStaticExtensions; namespace Microsoft.ML.StaticPipe { diff --git a/src/Microsoft.ML.StaticPipe/TermStaticExtensions.cs b/src/Microsoft.ML.StaticPipe/TermStaticExtensions.cs index a879757239..c18d47f45a 100644 --- a/src/Microsoft.ML.StaticPipe/TermStaticExtensions.cs +++ b/src/Microsoft.ML.StaticPipe/TermStaticExtensions.cs @@ -3,8 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using Microsoft.ML; -using Microsoft.ML.StaticPipe; using Microsoft.ML.Transforms.Conversions; namespace Microsoft.ML.StaticPipe @@ -12,6 +10,26 @@ namespace Microsoft.ML.StaticPipe public static partial class TermStaticExtensions { // Do not edit this file directly. Rather, it is generated out of TermStaticExtensions.tt. + /// + /// Information on the result of fitting a to-key transform. + /// + /// The type of the values. + public sealed class ToKeyFitResult + { + /// + /// For user defined delegates that accept instances of the containing type. + /// + /// + public delegate void OnFit(ToKeyFitResult result); + + // At the moment this is empty. Once PR #863 clears, we can change this class to hold the output + // key-values metadata. + + [BestFriend] + internal ToKeyFitResult(ValueToKeyMappingTransformer.TermMap map) + { + } + } #region For string inputs. /// diff --git a/src/Microsoft.ML.StaticPipe/TermStaticExtensions.tt b/src/Microsoft.ML.StaticPipe/TermStaticExtensions.tt index fef9abf45a..a4c0409ec2 100644 --- a/src/Microsoft.ML.StaticPipe/TermStaticExtensions.tt +++ b/src/Microsoft.ML.StaticPipe/TermStaticExtensions.tt @@ -9,8 +9,6 @@ // See the LICENSE file in the project root for more information. using System; -using Microsoft.ML; -using Microsoft.ML.StaticPipe; using Microsoft.ML.Transforms.Conversions; namespace Microsoft.ML.StaticPipe @@ -18,6 +16,26 @@ namespace Microsoft.ML.StaticPipe public static partial class TermStaticExtensions { // Do not edit this file directly. Rather, it is generated out of TermStaticExtensions.tt. + /// + /// Information on the result of fitting a to-key transform. + /// + /// The type of the values. + public sealed class ToKeyFitResult + { + /// + /// For user defined delegates that accept instances of the containing type. + /// + /// + public delegate void OnFit(ToKeyFitResult result); + + // At the moment this is empty. Once PR #863 clears, we can change this class to hold the output + // key-values metadata. + + [BestFriend] + internal ToKeyFitResult(ValueToKeyMappingTransformer.TermMap map) + { + } + } <# // Let's skip the time-based types for now. foreach (string typeName in new string[] { "string", "float", "double", "sbyte", "short", "int", "long", "byte", "ushort", "uint", "ulong", "bool" }) {