Skip to content

Commit 4944be7

Browse files
authored
Check for null Label, Feature, and GroupId columns (#4265)
1 parent f790a69 commit 4944be7

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/Microsoft.ML.EntryPoints/PermutationFeatureImportance.cs

+3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ internal static IDataView GetMetrics(
6262
RoleMappedData roleMappedData,
6363
PermutationFeatureImportanceArguments input)
6464
{
65+
Contracts.Check(roleMappedData.Schema.Feature != null, "Feature column not found.");
66+
Contracts.Check(roleMappedData.Schema.Label != null, "Label column not found.");
6567
IDataView result;
6668
if (predictor.PredictionKind == PredictionKind.BinaryClassification)
6769
result = GetBinaryMetrics(env, predictor, roleMappedData, input);
@@ -252,6 +254,7 @@ private static IDataView GetRankingMetrics(
252254
RoleMappedData roleMappedData,
253255
PermutationFeatureImportanceArguments input)
254256
{
257+
Contracts.Check(roleMappedData.Schema.Group != null, "Group ID column not found.");
255258
var roles = roleMappedData.Schema.GetColumnRoleNames();
256259
var featureColumnName = roles.Where(x => x.Key.Value == RoleMappedSchema.ColumnRole.Feature.Value).First().Value;
257260
var labelColumnName = roles.Where(x => x.Key.Value == RoleMappedSchema.ColumnRole.Label.Value).First().Value;

0 commit comments

Comments
 (0)