diff --git a/src/Microsoft.ML.Data/Prediction/CalibratorCatalog.cs b/src/Microsoft.ML.Data/Prediction/CalibratorCatalog.cs index 00de4ee9c12..a1de8d2e5d2 100644 --- a/src/Microsoft.ML.Data/Prediction/CalibratorCatalog.cs +++ b/src/Microsoft.ML.Data/Prediction/CalibratorCatalog.cs @@ -204,7 +204,6 @@ private protected CalibratorTransformer(IHostEnvironment env, ModelLoadContext c string ISingleFeaturePredictionTransformer.FeatureColumnName => ((ISingleFeaturePredictionTransformer)this).FeatureColumnName; DataViewType ISingleFeaturePredictionTransformer.FeatureColumnType => NumberDataViewType.Single; - DataViewType ISingleFeaturePredictionTransformer.FeatureColumnType => ((ISingleFeaturePredictionTransformer)this).FeatureColumnType; TICalibrator IPredictionTransformer.Model => _calibrator; diff --git a/src/Microsoft.ML.Data/Prediction/IPredictionTransformer.cs b/src/Microsoft.ML.Data/Prediction/IPredictionTransformer.cs index e189ee69d82..fceb68ae07d 100644 --- a/src/Microsoft.ML.Data/Prediction/IPredictionTransformer.cs +++ b/src/Microsoft.ML.Data/Prediction/IPredictionTransformer.cs @@ -45,8 +45,5 @@ internal interface ISingleFeaturePredictionTransformer : ITransformer { /// The name of the feature column. string FeatureColumnName { get; } - - /// Holds information about the type of the feature column. - DataViewType FeatureColumnType { get; } } } \ No newline at end of file diff --git a/src/Microsoft.ML.Transforms/PermutationFeatureImportanceExtensions.cs b/src/Microsoft.ML.Transforms/PermutationFeatureImportanceExtensions.cs index 858de28d489..f3a0f4fa002 100644 --- a/src/Microsoft.ML.Transforms/PermutationFeatureImportanceExtensions.cs +++ b/src/Microsoft.ML.Transforms/PermutationFeatureImportanceExtensions.cs @@ -681,7 +681,7 @@ private static double[] ComputeSequenceDeltas(IReadOnlyList a, IReadOnly env.CheckValue(lastTransformer, nameof(lastTransformer), "The model provided does not have a compatible predictor"); string featureColumnName = lastTransformer.FeatureColumnName; - TryGetImplementedIPredictionTransformer(lastTransformer.GetType(), out var predictionTransformerGenericType); + var predictionTransformerGenericType = GetImplementedIPredictionTransformer(lastTransformer.GetType()); Type[] types = { predictionTransformerGenericType.GenericTypeArguments[0], typeof(TMetric), typeof(TResult) }; Type pfiGenericType = typeof(PermutationFeatureImportance<,,>).MakeGenericType(types); @@ -721,19 +721,17 @@ private static double[] ComputeSequenceDeltas(IReadOnlyList a, IReadOnly return output.ToImmutableDictionary(); } - private static bool TryGetImplementedIPredictionTransformer(Type type, out Type interfaceType) + private static Type GetImplementedIPredictionTransformer(Type type) { foreach (Type iType in type.GetInterfaces()) { if (iType.IsGenericType && iType.GetGenericTypeDefinition() == typeof(IPredictionTransformer<>)) { - interfaceType = iType; - return true; + return iType; } } - interfaceType = null; - return false; + throw new ArgumentException($"Type IPredictionTransformer not implemented by provided type", nameof(type)); } #endregion