Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static void Example()
// Make the convergence tolerance tighter.
ConvergenceTolerance = 0.05f,
// Increase the maximum number of passes over training data.
NumberOfIterations = 30,
MaximumNumberOfIterations = 30,
// Give the instances of the positive class slightly more weight.
PositiveInstanceWeight = 1.2f,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static void Example()
// A pipeline for concatenating the age, parity and induced columns together in the Features column and training a KMeans model on them.
string outputColumnName = "Features";
var pipeline = ml.Transforms.Concatenate(outputColumnName, new[] { "Age", "Parity", "Induced" })
.Append(ml.Clustering.Trainers.KMeans(outputColumnName, clustersCount: 2));
.Append(ml.Clustering.Trainers.KMeans(outputColumnName, numberOfClusters: 2));

var model = pipeline.Fit(trainData);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static void Example()
{
FeatureColumnName = outputColumnName,
NumberOfClusters = 2,
NumberOfIterations = 100,
MaximumNumberOfIterations = 100,
OptimizationTolerance = 1e-6f,
NumberOfThreads = 1
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static void Example()
// Make the convergence tolerance tighter.
ConvergenceTolerance = 0.05f,
// Increase the maximum number of passes over training data.
NumberOfIterations = 30,
MaximumNumberOfIterations = 30,
};

// Create a pipeline.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static void Example()
// Make the convergence tolerance tighter.
ConvergenceTolerance = 0.02f,
// Increase the maximum number of passes over training data.
NumberOfIterations = 30,
MaximumNumberOfIterations = 30,
// Increase learning rate for bias
BiasLearningRate = 0.1f
};
Expand Down
6 changes: 3 additions & 3 deletions src/Microsoft.ML.KMeansClustering/KMeansCatalog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static class KMeansClusteringExtensions
/// <param name="catalog">The clustering catalog trainer object.</param>
/// <param name="featureColumnName">The name of the feature column.</param>
/// <param name="exampleWeightColumnName">The name of the example weight column (optional).</param>
/// <param name="clustersCount">The number of clusters to use for KMeans.</param>
/// <param name="numberOfClusters">The number of clusters to use for KMeans.</param>
/// <example>
/// <format type="text/markdown">
/// <![CDATA[
Expand All @@ -30,7 +30,7 @@ public static class KMeansClusteringExtensions
public static KMeansPlusPlusTrainer KMeans(this ClusteringCatalog.ClusteringTrainers catalog,
string featureColumnName = DefaultColumnNames.Features,
string exampleWeightColumnName = null,
int clustersCount = KMeansPlusPlusTrainer.Defaults.NumberOfClusters)
int numberOfClusters = KMeansPlusPlusTrainer.Defaults.NumberOfClusters)
{
Contracts.CheckValue(catalog, nameof(catalog));
var env = CatalogUtils.GetEnvironment(catalog);
Expand All @@ -39,7 +39,7 @@ public static KMeansPlusPlusTrainer KMeans(this ClusteringCatalog.ClusteringTrai
{
FeatureColumnName = featureColumnName,
ExampleWeightColumnName = exampleWeightColumnName,
NumberOfClusters = clustersCount
NumberOfClusters = numberOfClusters
};
return new KMeansPlusPlusTrainer(env, options);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Microsoft.ML.KMeansClustering/KMeansPlusPlusTrainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public sealed class Options : UnsupervisedTrainerInputBaseWithWeight
/// </summary>
[Argument(ArgumentType.AtMostOnce, HelpText = "Maximum number of iterations.", ShortName = "maxiter")]
[TGUI(Label = "Max Number of Iterations")]
public int NumberOfIterations = 1000;
public int MaximumNumberOfIterations = 1000;

/// <summary>
/// Memory budget (in MBs) to use for KMeans acceleration.
Expand Down Expand Up @@ -125,8 +125,8 @@ internal KMeansPlusPlusTrainer(IHostEnvironment env, Options options)

_k = options.NumberOfClusters;

Host.CheckUserArg(options.NumberOfIterations > 0, nameof(options.NumberOfIterations), "Must be positive");
_maxIterations = options.NumberOfIterations;
Host.CheckUserArg(options.MaximumNumberOfIterations > 0, nameof(options.MaximumNumberOfIterations), "Must be positive");
_maxIterations = options.MaximumNumberOfIterations;

Host.CheckUserArg(options.OptimizationTolerance > 0, nameof(options.OptimizationTolerance), "Tolerance must be positive");
_convergenceThreshold = options.OptimizationTolerance;
Expand Down
18 changes: 9 additions & 9 deletions src/Microsoft.ML.StandardLearners/Standard/SdcaBinary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public abstract class OptionsBase : TrainerInputBaseWithLabel
[Argument(ArgumentType.AtMostOnce, HelpText = "Maximum number of iterations; set to 1 to simulate online learning. Defaults to automatic.", NullName = "<Auto>", ShortName = "iter, MaxIterations")]
[TGUI(Label = "Max number of iterations", SuggestedSweeps = "<Auto>,10,20,100")]
[TlcModule.SweepableDiscreteParam("MaxIterations", new object[] { "<Auto>", 10, 20, 100 })]
public int? NumberOfIterations;
public int? MaximumNumberOfIterations;

/// <summary>
/// Determines whether to shuffle data for each training iteration.
Expand Down Expand Up @@ -235,7 +235,7 @@ internal virtual void Check(IHostEnvironment env)
Contracts.AssertValue(env);
env.CheckUserArg(L2Regularization == null || L2Regularization >= 0, nameof(L2Regularization), "L2 constant must be non-negative.");
env.CheckUserArg(L1Threshold == null || L1Threshold >= 0, nameof(L1Threshold), "L1 threshold must be non-negative.");
env.CheckUserArg(NumberOfIterations == null || NumberOfIterations > 0, nameof(NumberOfIterations), "Max number of iterations must be positive.");
env.CheckUserArg(MaximumNumberOfIterations == null || MaximumNumberOfIterations > 0, nameof(MaximumNumberOfIterations), "Max number of iterations must be positive.");
env.CheckUserArg(ConvergenceTolerance > 0 && ConvergenceTolerance <= 1, nameof(ConvergenceTolerance), "Convergence tolerance must be positive and no larger than 1.");

if (L2Regularization < L2LowerBound)
Expand Down Expand Up @@ -303,7 +303,7 @@ internal SdcaTrainerBase(IHostEnvironment env, TOptions options, SchemaShape.Col
SdcaTrainerOptions = options;
SdcaTrainerOptions.L2Regularization = l2Const ?? options.L2Regularization;
SdcaTrainerOptions.L1Threshold = l1Threshold ?? options.L1Threshold;
SdcaTrainerOptions.NumberOfIterations = maxIterations ?? options.NumberOfIterations;
SdcaTrainerOptions.MaximumNumberOfIterations = maxIterations ?? options.MaximumNumberOfIterations;
SdcaTrainerOptions.Check(env);
}

Expand Down Expand Up @@ -442,12 +442,12 @@ private protected sealed override TModel TrainCore(IChannel ch, RoleMappedData d

ch.Check(count > 0, "Training set has 0 instances, aborting training.");
// Tune the default hyperparameters based on dataset size.
if (SdcaTrainerOptions.NumberOfIterations == null)
SdcaTrainerOptions.NumberOfIterations = TuneDefaultMaxIterations(ch, count, numThreads);
if (SdcaTrainerOptions.MaximumNumberOfIterations == null)
SdcaTrainerOptions.MaximumNumberOfIterations = TuneDefaultMaxIterations(ch, count, numThreads);

Contracts.Assert(SdcaTrainerOptions.NumberOfIterations.HasValue);
Contracts.Assert(SdcaTrainerOptions.MaximumNumberOfIterations.HasValue);
if (SdcaTrainerOptions.L2Regularization == null)
SdcaTrainerOptions.L2Regularization = TuneDefaultL2(ch, SdcaTrainerOptions.NumberOfIterations.Value, count, numThreads);
SdcaTrainerOptions.L2Regularization = TuneDefaultL2(ch, SdcaTrainerOptions.MaximumNumberOfIterations.Value, count, numThreads);

Contracts.Assert(SdcaTrainerOptions.L2Regularization.HasValue);
if (SdcaTrainerOptions.L1Threshold == null)
Expand Down Expand Up @@ -547,8 +547,8 @@ private protected sealed override TModel TrainCore(IChannel ch, RoleMappedData d
ch.AssertValue(metricNames);
ch.AssertValue(metrics);
ch.Assert(metricNames.Length == metrics.Length);
ch.Assert(SdcaTrainerOptions.NumberOfIterations.HasValue);
var maxIterations = SdcaTrainerOptions.NumberOfIterations.Value;
ch.Assert(SdcaTrainerOptions.MaximumNumberOfIterations.HasValue);
var maxIterations = SdcaTrainerOptions.MaximumNumberOfIterations.Value;

var rands = new Random[maxIterations];
for (int i = 0; i < maxIterations; i++)
Expand Down
24 changes: 12 additions & 12 deletions src/Microsoft.ML.StandardLearners/StandardLearnersCatalog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public static SgdNonCalibratedBinaryTrainer StochasticGradientDescentNonCalibrat
/// <param name="exampleWeightColumnName">The name of the example weight column (optional).</param>
/// <param name="l2Regularization">The L2 <a href='tmpurl_regularization'>regularization</a> hyperparameter.</param>
/// <param name="l1Threshold">The L1 <a href='tmpurl_regularization'>regularization</a> hyperparameter. Higher values will tend to lead to more sparse model.</param>
/// <param name="numberOfIterations">The maximum number of passes to perform over the data.</param>
/// <param name="maximumNumberOfIterations">The maximum number of passes to perform over the data.</param>
/// <param name="loss">The custom <a href="tmpurl_loss">loss</a>, if unspecified will be <see cref="SquaredLoss"/>.</param>
/// <example>
/// <format type="text/markdown">
Expand All @@ -147,11 +147,11 @@ public static SdcaRegressionTrainer StochasticDualCoordinateAscent(this Regressi
ISupportSdcaRegressionLoss loss = null,
float? l2Regularization = null,
float? l1Threshold = null,
int? numberOfIterations = null)
int? maximumNumberOfIterations = null)
{
Contracts.CheckValue(catalog, nameof(catalog));
var env = CatalogUtils.GetEnvironment(catalog);
return new SdcaRegressionTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, loss, l2Regularization, l1Threshold, numberOfIterations);
return new SdcaRegressionTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, loss, l2Regularization, l1Threshold, maximumNumberOfIterations);
}

/// <summary>
Expand Down Expand Up @@ -184,7 +184,7 @@ public static SdcaRegressionTrainer StochasticDualCoordinateAscent(this Regressi
/// <param name="exampleWeightColumnName">The name of the example weight column (optional).</param>
/// <param name="l2Regularization">The L2 <a href='tmpurl_regularization'>regularization</a> hyperparameter.</param>
/// <param name="l1Threshold">The L1 <a href='tmpurl_regularization'>regularization</a> hyperparameter. Higher values will tend to lead to more sparse model.</param>
/// <param name="numberOfIterations">The maximum number of passes to perform over the data.</param>
/// <param name="maximumNumberOfIterations">The maximum number of passes to perform over the data.</param>
/// <example>
/// <format type="text/markdown">
/// <![CDATA[
Expand All @@ -198,11 +198,11 @@ public static SdcaBinaryTrainer StochasticDualCoordinateAscent(
string exampleWeightColumnName = null,
float? l2Regularization = null,
float? l1Threshold = null,
int? numberOfIterations = null)
int? maximumNumberOfIterations = null)
{
Contracts.CheckValue(catalog, nameof(catalog));
var env = CatalogUtils.GetEnvironment(catalog);
return new SdcaBinaryTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, l2Regularization, l1Threshold, numberOfIterations);
return new SdcaBinaryTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, l2Regularization, l1Threshold, maximumNumberOfIterations);
}

/// <summary>
Expand Down Expand Up @@ -237,7 +237,7 @@ public static SdcaBinaryTrainer StochasticDualCoordinateAscent(
/// <param name="loss">The custom <a href="tmpurl_loss">loss</a>. Defaults to <see cref="LogLoss"/> if not specified.</param>
/// <param name="l2Regularization">The L2 <a href='tmpurl_regularization'>regularization</a> hyperparameter.</param>
/// <param name="l1Threshold">The L1 <a href='tmpurl_regularization'>regularization</a> hyperparameter. Higher values will tend to lead to more sparse model.</param>
/// <param name="numberOfIterations">The maximum number of passes to perform over the data.</param>
/// <param name="maximumNumberOfIterations">The maximum number of passes to perform over the data.</param>
/// <example>
/// <format type="text/markdown">
/// <![CDATA[
Expand All @@ -252,11 +252,11 @@ public static SdcaNonCalibratedBinaryTrainer StochasticDualCoordinateAscentNonCa
ISupportSdcaClassificationLoss loss = null,
float? l2Regularization = null,
float? l1Threshold = null,
int? numberOfIterations = null)
int? maximumNumberOfIterations = null)
{
Contracts.CheckValue(catalog, nameof(catalog));
var env = CatalogUtils.GetEnvironment(catalog);
return new SdcaNonCalibratedBinaryTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, loss, l2Regularization, l1Threshold, numberOfIterations);
return new SdcaNonCalibratedBinaryTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, loss, l2Regularization, l1Threshold, maximumNumberOfIterations);
}

/// <summary>
Expand Down Expand Up @@ -285,7 +285,7 @@ public static SdcaNonCalibratedBinaryTrainer StochasticDualCoordinateAscentNonCa
/// <param name="loss">The custom <a href="tmpurl_loss">loss</a>. Defaults to <see cref="LogLoss"/> if not specified.</param>
/// <param name="l2Regularization">The L2 <a href='tmpurl_regularization'>regularization</a> hyperparameter.</param>
/// <param name="l1Threshold">The L1 <a href='tmpurl_regularization'>regularization</a> hyperparameter. Higher values will tend to lead to more sparse model.</param>
/// <param name="numberOfIterations">The maximum number of passes to perform over the data.</param>
/// <param name="maximumNumberOfIterations">The maximum number of passes to perform over the data.</param>
/// <example>
/// <format type="text/markdown">
/// <![CDATA[
Expand All @@ -299,11 +299,11 @@ public static SdcaMultiClassTrainer StochasticDualCoordinateAscent(this Multicla
ISupportSdcaClassificationLoss loss = null,
float? l2Regularization = null,
float? l1Threshold = null,
int? numberOfIterations = null)
int? maximumNumberOfIterations = null)
{
Contracts.CheckValue(catalog, nameof(catalog));
var env = CatalogUtils.GetEnvironment(catalog);
return new SdcaMultiClassTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, loss, l2Regularization, l1Threshold, numberOfIterations);
return new SdcaMultiClassTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, loss, l2Regularization, l1Threshold, maximumNumberOfIterations);
}

/// <summary>
Expand Down
8 changes: 4 additions & 4 deletions test/BaselineOutput/Common/EntryPoints/core_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -11019,7 +11019,7 @@
"Default": 1E-07
},
{
"Name": "NumberOfIterations",
"Name": "MaximumNumberOfIterations",
"Type": "Int",
"Desc": "Maximum number of iterations.",
"Aliases": [
Expand Down Expand Up @@ -15221,7 +15221,7 @@
}
},
{
"Name": "NumberOfIterations",
"Name": "MaximumNumberOfIterations",
"Type": "Int",
"Desc": "Maximum number of iterations; set to 1 to simulate online learning. Defaults to automatic.",
"Aliases": [
Expand Down Expand Up @@ -15494,7 +15494,7 @@
}
},
{
"Name": "NumberOfIterations",
"Name": "MaximumNumberOfIterations",
"Type": "Int",
"Desc": "Maximum number of iterations; set to 1 to simulate online learning. Defaults to automatic.",
"Aliases": [
Expand Down Expand Up @@ -15767,7 +15767,7 @@
}
},
{
"Name": "NumberOfIterations",
"Name": "MaximumNumberOfIterations",
"Type": "Int",
"Desc": "Maximum number of iterations; set to 1 to simulate online learning. Defaults to automatic.",
"Aliases": [
Expand Down
4 changes: 2 additions & 2 deletions test/Microsoft.ML.Functional.Tests/IntrospectiveTraining.cs
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ private IEstimator<TransformerChain<ClusteringPredictionTransformer<KMeansModelP
{
InitializationAlgorithm = KMeansPlusPlusTrainer.InitializationAlgorithm.Random,
NumberOfClusters = 4,
NumberOfIterations = 10,
MaximumNumberOfIterations = 10,
NumberOfThreads = 1
}));
}
Expand All @@ -435,7 +435,7 @@ private IEstimator<TransformerChain<MulticlassPredictionTransformer<MulticlassLo
return mlContext.Transforms.Conversion.MapValueToKey("Label")
.Append(mlContext.MulticlassClassification.Trainers.StochasticDualCoordinateAscent(
new SdcaMultiClassTrainer.Options {
NumberOfIterations = 10,
MaximumNumberOfIterations = 10,
NumberOfThreads = 1 }));
}
}
Expand Down
Loading