Skip to content

Commit

Permalink
Multiclass nondefault label test (dotnet#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
daholste authored Feb 23, 2019
1 parent 796ae8a commit abf6f0d
Show file tree
Hide file tree
Showing 4 changed files with 190 additions and 8 deletions.
7 changes: 3 additions & 4 deletions src/Test/AutoFitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,14 @@ public void AutoFitBinaryTest()
public void AutoFitMultiTest()
{
var context = new MLContext();
var dataPath = DatasetUtil.DownloadTrivialDataset();
var columnInference = context.AutoInference().InferColumns(dataPath, DatasetUtil.TrivialDatasetLabel);
var columnInference = context.AutoInference().InferColumns(DatasetUtil.TrivialMulticlassDatasetPath, DatasetUtil.TrivialMulticlassDatasetLabel);
var textLoader = context.Data.CreateTextLoader(columnInference.TextLoaderArgs);
var trainData = textLoader.Read(dataPath);
var trainData = textLoader.Read(DatasetUtil.TrivialMulticlassDatasetPath);
var validationData = context.Data.TakeRows(trainData, 20);
trainData = context.Data.SkipRows(trainData, 20);
var result = context.AutoInference()
.CreateMulticlassClassificationExperiment(0)
.Execute(trainData, validationData, new ColumnInformation() { LabelColumn = DatasetUtil.TrivialDatasetLabel });
.Execute(trainData, validationData, new ColumnInformation() { LabelColumn = DatasetUtil.TrivialMulticlassDatasetLabel });

Assert.IsTrue(result.Max(i => i.Metrics.AccuracyMacro) > 0.80);
}
Expand Down
7 changes: 3 additions & 4 deletions src/Test/DatasetUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ namespace Microsoft.ML.Auto.Test
internal static class DatasetUtil
{
public const string UciAdultLabel = DefaultColumnNames.Label;
public const string TrivialDatasetLabel = DefaultColumnNames.Label;
public const string TrivialMulticlassDatasetLabel = "Target";
public const string MlNetGeneratedRegressionLabel = "target";
public const int IrisDatasetLabelColIndex = 0;

public const string TrivialMulticlassDatasetPath = @"TestData\TrivialMulticlassDataset.txt";

private static IDataView _uciAdultDataView;

public static IDataView GetUciAdultDataView()
Expand All @@ -36,9 +38,6 @@ public static IDataView GetUciAdultDataView()
public static string DownloadUciAdultDataset() =>
DownloadIfNotExists("https://raw.githubusercontent.com/dotnet/machinelearning/f0e639af5ffdc839aae8e65d19b5a9a1f0db634a/test/data/adult.tiny.with-schema.txt", "uciadult.dataset");

public static string DownloadTrivialDataset() =>
DownloadIfNotExists("https://raw.githubusercontent.com/dotnet/machinelearning/eae76959e6714af44caa212e102a5f06f0110e72/test/data/trivial-train.tsv", "trivial.dataset");

public static string DownloadMlNetGeneratedRegressionDataset() =>
DownloadIfNotExists("https://raw.githubusercontent.com/dotnet/machinelearning/e78971ea6fd736038b4c355b840e5cbabae8cb55/test/data/generated_regression_dataset.csv", "mlnet_generated_regression.dataset");

Expand Down
3 changes: 3 additions & 0 deletions src/Test/Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
<None Update="TestData\DatasetWithEmptyColumn.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestData\TrivialMulticlassDataset.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
181 changes: 181 additions & 0 deletions src/Test/TestData/TrivialMulticlassDataset.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
Target Row Column
1 14 20
1 19 26
3 17 4
1 10 20
1 3 5
1 7 5
1 18 36
2 1 36
2 1 38
3 17 1
2 6 26
2 9 30
3 13 8
2 7 33
2 8 30
3 10 1
1 18 25
1 13 12
1 3 2
2 8 28
1 11 24
2 3 28
2 1 16
1 9 7
1 15 16
3 19 4
1 1 8
1 8 0
1 10 34
1 18 37
2 1 17
2 8 39
1 17 30
2 1 27
2 0 38
1 11 16
3 19 3
1 7 8
1 13 13
1 19 31
3 16 1
1 5 1
2 6 11
1 9 5
3 10 6
1 1 2
2 6 30
2 7 15
1 17 21
1 18 23
3 10 7
2 5 39
2 2 27
3 12 6
3 11 4
1 9 3
1 12 22
2 8 19
2 1 14
1 11 11
1 10 36
3 12 4
1 15 21
1 17 37
1 6 3
2 3 18
1 10 10
1 11 33
1 18 19
2 7 35
3 10 2
1 12 30
1 12 26
2 1 31
2 5 21
2 1 11
1 7 3
2 8 36
3 10 4
1 18 26
2 8 10
1 10 22
1 15 14
3 16 0
2 0 30
2 3 34
3 13 9
1 0 2
1 15 36
1 15 23
1 10 30
2 6 20
2 9 24
2 9 35
1 7 6
2 7 39
2 5 20
3 12 8
2 9 12
1 17 25
1 12 33
2 6 19
1 17 10
2 4 35
1 15 31
3 12 7
1 17 16
2 1 19
2 3 25
1 16 30
1 19 30
1 5 4
2 6 10
1 18 20
1 13 26
2 3 39
2 2 20
1 4 7
2 3 33
1 16 20
2 1 21
3 15 2
3 19 2
1 12 10
2 5 37
2 1 32
3 18 6
1 2 1
1 16 21
2 1 23
1 17 33
2 5 11
2 3 14
1 11 12
1 13 20
1 19 38
1 15 10
2 8 11
3 11 0
1 18 10
1 19 24
1 13 11
2 4 23
1 16 26
1 7 7
1 17 29
1 18 30
1 13 10
2 6 21
1 19 32
2 7 12
1 12 28
2 2 11
1 12 15
2 8 32
3 15 9
3 16 5
1 9 1
1 19 28
3 16 3
1 15 17
2 7 38
1 16 38
1 14 26
1 10 26
1 10 37
3 18 5
2 5 27
2 2 22
1 11 39
1 16 36
1 0 9
2 5 19
1 18 28
1 12 13
1 17 17
1 8 1
2 6 15
3 14 4
1 1 4

0 comments on commit abf6f0d

Please sign in to comment.