Skip to content

Changed default NGram length from 1 to 2. #5248

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 3 commits into from
Jun 26, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -79,7 +79,7 @@ public class Options

public Options()
{
NgramLength = 1;
NgramLength = 2;
SkipLength = NgramExtractingEstimator.Defaults.SkipLength;
UseAllLengths = NgramExtractingEstimator.Defaults.UseAllLengths;
MaximumNgramsCount = new int[] { NgramExtractingEstimator.Defaults.MaximumNgramsCount };
Expand Down
1 change: 1 addition & 0 deletions test/BaselineOutput/Common/EntryPoints/core_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -23696,6 +23696,7 @@
"Default": {
"Name": "NGram",
"Settings": {
"NgramLength": 2,
"MaxNumTerms": [
10000000
]
Expand Down
14 changes: 7 additions & 7 deletions test/BaselineOutput/Common/Text/featurized.tsv

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions test/Microsoft.ML.Tests/TrainerEstimators/LbfgsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ public void TestLRWithStats()

Assert.NotNull(biasStats);

CompareNumbersWithTolerance(biasStats.StandardError, 0.25, digitsOfPrecision: 2);
CompareNumbersWithTolerance(biasStats.ZScore, 7.97, digitsOfPrecision: 2);
CompareNumbersWithTolerance(biasStats.StandardError, 0.24, digitsOfPrecision: 2);
CompareNumbersWithTolerance(biasStats.ZScore, 8.32, digitsOfPrecision: 2);

var scoredData = transformer.Transform(dataView);

var coefficients = stats.GetWeightsCoefficientStatistics(100);

Assert.Equal(18, coefficients.Length);
Assert.Equal(17, coefficients.Length);

foreach (var coefficient in coefficients)
Assert.True(coefficient.StandardError < 1.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ public void FastTreeBinaryClassificationTestSummary()
[Fact]
public void FastForestBinaryClassificationTestSummary()
{
var (pipeline, dataView) = GetOneHotBinaryClassificationPipeline();
var (pipeline, dataView) = GetBinaryClassificationPipeline();
var estimator = pipeline.Append(ML.BinaryClassification.Trainers.FastForest(
new FastForestBinaryTrainer.Options { NumberOfTrees = 2, NumberOfThreads = 1, NumberOfLeaves = 4, CategoricalSplit = true }));

Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be changed too?

Expand Down
6 changes: 3 additions & 3 deletions test/Microsoft.ML.Tests/Transformers/TextFeaturizerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,14 @@ public void TextFeaturizerWithL2NormTest()
var prediction = engine.Predict(data[0]);
Assert.Equal(data[0].A, string.Join(" ", prediction.OutputTokens));
var exp1 = 0.333333343f;
var exp2 = 0.707106769f;
var expected = new float[] { exp1, exp1, exp1, exp1, exp1, exp1, exp1, exp1, exp1, exp2, exp2 };
var exp2 = 0.577350259f;
var expected = new float[] { exp1, exp1, exp1, exp1, exp1, exp1, exp1, exp1, exp1, exp2, exp2, exp2 };
Assert.Equal(expected, prediction.Features);

prediction = engine.Predict(data[1]);
exp1 = 0.4472136f;
Assert.Equal(data[1].A, string.Join(" ", prediction.OutputTokens));
expected = new float[] { exp1, 0.0f, 0.0f, 0.0f, 0.0f, exp1, exp1, exp1, exp1, 0.0f, 1.0f };
expected = new float[] { exp1, 0.0f, 0.0f, 0.0f, 0.0f, exp1, exp1, exp1, exp1, 0.0f, 0.0f, 1.0f };
Assert.Equal(expected, prediction.Features);
}

Expand Down