Skip to content

Commit 267c387

Browse files
committed
Address Ivan's comments (hopefully)
1 parent 3dabf17 commit 267c387

File tree

62 files changed

+3229
-3389
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+3229
-3389
lines changed

docs/samples/Microsoft.ML.Samples/Dynamic/Calibrator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static void Calibration()
4949
// Then append the StochasticDualCoordinateAscentBinary binary classifier, setting the "Label" column as the label of the dataset, and
5050
// the "Features" column produced by FeaturizeText as the features column.
5151
var pipeline = mlContext.Transforms.Text.FeaturizeText("SentimentText", "Features")
52-
.Append(mlContext.BinaryClassification.Trainers.StochasticDualCoordinateAscent(
52+
.Append(mlContext.BinaryClassification.Trainers.StochasticDualCoordinateAscentNonCalibrated(
5353
labelColumn: "Sentiment",
5454
featureColumn: "Features",
5555
l2Const: 0.001f,

docs/samples/Microsoft.ML.Samples/Dynamic/SDCACalibrated.cs renamed to docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/SDCA.cs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,9 @@
55

66
namespace Microsoft.ML.Samples.Dynamic
77
{
8-
public class SDCACalibrated_BinaryClassificationExample
8+
public class SDCALogisticRegressionExample
99
{
10-
/// <summary>
11-
/// Call <see cref="SdcaCalibratedBinaryTrainer"/> to train a logistic regression model.
12-
/// Training examples are generated by calling <see cref="Samples.Utils.DatasetUtils.GenerateBinaryLabelFloatFeatureVectorSamples"/>.
13-
/// The type of those examples is <see cref="SamplesUtils.DatasetUtils.FloatLabelFloatFeatureVectorSample"/>,
14-
/// which contains one bool label and a float feature vector.
15-
/// </summary>
16-
public static void SDCACalibrated_BinaryClassification()
10+
public static void SDCALogisticRegression()
1711
{
1812
// Generate C# objects as training examples.
1913
var rawData = SamplesUtils.DatasetUtils.GenerateBinaryLabelFloatFeatureVectorSamples(100);
@@ -41,13 +35,13 @@ public static void SDCACalibrated_BinaryClassification()
4135
// Step 1: Read the data as an IDataView.
4236
var data = mlContext.Data.ReadFromEnumerable(rawData);
4337

44-
// ML.NET doesn't cache data set by default. Caching is very helpful when working with iterative
45-
// algorithms which needs many data passes. Since SDCA is the case, we cache.
38+
// ML.NET doesn't cache data set by default. Caching is always recommended when using the
39+
// StochasticDualCoordinateAscent algorithm because it may incur multiple data passes.
4640
data = mlContext.Data.Cache(data);
4741

48-
// Step 2: Create a binary classifier.
42+
// Step 2: Create a binary classifier. This trainer may produce a logistic regression model.
4943
// We set the "Label" column as the label of the dataset, and the "Features" column as the features column.
50-
var pipeline = mlContext.BinaryClassification.Trainers.StochasticDualCoordinateAscentCalibrated(labelColumn: "Label", featureColumn: "Features", l2Const: 0.001f);
44+
var pipeline = mlContext.BinaryClassification.Trainers.StochasticDualCoordinateAscent(labelColumn: "Label", featureColumn: "Features", l2Const: 0.001f);
5145

5246
// Step 3: Train the pipeline created.
5347
var model = pipeline.Fit(data);
@@ -62,7 +56,7 @@ public static void SDCACalibrated_BinaryClassification()
6256

6357
Console.WriteLine("The first example actual label is {0}." +
6458
" The trained model assigns it a score {1} and a probability of being positive class {2}.",
65-
first.Label /*true*/, first.Score /*around 3.2*/, first.Probability /*around around 0.95*/);
59+
first.Label /*true*/, first.Score /*around 3.2*/, first.Probability /*around 0.95*/);
6660
}
6761
}
6862
}

docs/samples/Microsoft.ML.Samples/Dynamic/SDCA.cs renamed to docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/SDCANonCalibrated.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
namespace Microsoft.ML.Samples.Dynamic
77
{
8-
public class SDCA_BinaryClassificationExample
8+
public class SDCABinaryClassificationExample
99
{
10-
public static void SDCA_BinaryClassification()
10+
public static void SDCABinaryClassification()
1111
{
1212
// Downloading the dataset from github.com/dotnet/machinelearning.
1313
// This will create a sentiment.tsv file in the filesystem.
@@ -49,7 +49,7 @@ public static void SDCA_BinaryClassification()
4949
// the "Features" column produced by FeaturizeText as the features column.
5050
var pipeline = mlContext.Transforms.Text.FeaturizeText("SentimentText", "Features")
5151
.AppendCacheCheckpoint(mlContext) // Add a data-cache step within a pipeline.
52-
.Append(mlContext.BinaryClassification.Trainers.StochasticDualCoordinateAscent(labelColumn: "Sentiment", featureColumn: "Features", l2Const: 0.001f));
52+
.Append(mlContext.BinaryClassification.Trainers.StochasticDualCoordinateAscentNonCalibrated(labelColumn: "Sentiment", featureColumn: "Features", l2Const: 0.001f));
5353

5454
// Step 3: Run Cross-Validation on this pipeline.
5555
var cvResults = mlContext.BinaryClassification.CrossValidate(data, pipeline, labelColumn: "Sentiment");
@@ -60,8 +60,8 @@ public static void SDCA_BinaryClassification()
6060
// If we wanted to specify more advanced parameters for the algorithm,
6161
// we could do so by tweaking the 'advancedSetting'.
6262
var advancedPipeline = mlContext.Transforms.Text.FeaturizeText("SentimentText", "Features")
63-
.Append(mlContext.BinaryClassification.Trainers.StochasticDualCoordinateAscent(
64-
new SdcaBinaryTrainer.Options {
63+
.Append(mlContext.BinaryClassification.Trainers.StochasticDualCoordinateAscentNonCalibrated(
64+
new SdcaNonCalibratedBinaryTrainer.Options {
6565
LabelColumn = "Sentiment",
6666
FeatureColumn = "Features",
6767
ConvergenceTolerance = 0.01f, // The learning rate for adjusting bias from being regularized

docs/samples/Microsoft.ML.Samples/Static/SDCABinaryClassification.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public static void SdcaBinaryClassification()
7373
.Append(row => (
7474
Features: row.Features.Normalize(),
7575
Label: row.Label,
76-
Score: mlContext.BinaryClassification.Trainers.SdcaCalibrated(
76+
Score: mlContext.BinaryClassification.Trainers.Sdca(
7777
row.Label,
7878
row.Features,
7979
l1Threshold: 0.25f,

0 commit comments

Comments
 (0)