Skip to content

Commit 37f92d6

Browse files
daholsteDmitry-A
authored andcommitted
add estimator extension tests (dotnet#24)
1 parent a7f072e commit 37f92d6

File tree

2 files changed

+49
-4
lines changed

2 files changed

+49
-4
lines changed

src/AutoML/EstimatorExtensions/EstimatorExtensions.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using Microsoft.ML.Core.Data;
1+
using Microsoft.ML.Core.Data;
42
using Microsoft.ML.Data;
5-
using Microsoft.ML.Transforms;
63
using Microsoft.ML.Transforms.Categorical;
74
using Microsoft.ML.Transforms.Conversions;
85

src/Test/EstimatorExtensionTests.cs

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using System;
2+
using System.Linq;
3+
using Microsoft.VisualStudio.TestTools.UnitTesting;
4+
5+
namespace Microsoft.ML.Auto.Test
6+
{
7+
[TestClass]
8+
public class EstimatorExtensionTests
9+
{
10+
[TestMethod]
11+
public void EstimatorExtensionInstanceTests()
12+
{
13+
var context = new MLContext();
14+
var pipelineNode = new PipelineNode()
15+
{
16+
InColumns = new string[] { "Input" },
17+
OutColumns = new string[] { "Output" }
18+
};
19+
20+
var estimatorNames = Enum.GetValues(typeof(EstimatorName)).Cast<EstimatorName>();
21+
foreach (var estimatorName in estimatorNames)
22+
{
23+
var extension = EstimatorExtensionCatalog.GetExtension(estimatorName);
24+
var instance = extension.CreateInstance(context, pipelineNode);
25+
Assert.IsNotNull(instance);
26+
}
27+
}
28+
29+
[TestMethod]
30+
public void EstimatorExtensionStaticTests()
31+
{
32+
var context = new MLContext();
33+
var inCol = "Input";
34+
var outCol = "Output";
35+
var inCols = new string[] { inCol };
36+
var outCols = new string[] { outCol };
37+
Assert.IsNotNull(ColumnConcatenatingExtension.CreateSuggestedTransform(context, inCols, outCol));
38+
Assert.IsNotNull(ColumnCopyingExtension.CreateSuggestedTransform(context, inCol, outCol));
39+
Assert.IsNotNull(MissingValueIndicatorExtension.CreateSuggestedTransform(context, inCols, outCols));
40+
Assert.IsNotNull(NormalizingExtension.CreateSuggestedTransform(context, inCol, outCol));
41+
Assert.IsNotNull(OneHotEncodingExtension.CreateSuggestedTransform(context, inCols, outCols));
42+
Assert.IsNotNull(OneHotHashEncodingExtension.CreateSuggestedTransform(context, inCols, outCols));
43+
Assert.IsNotNull(TextFeaturizingExtension.CreateSuggestedTransform(context, inCol, outCol));
44+
Assert.IsNotNull(TypeConvertingExtension.CreateSuggestedTransform(context, inCols, outCols));
45+
Assert.IsNotNull(ValueToKeyMappingExtension.CreateSuggestedTransform(context, inCol, outCol));
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)