Skip to content

Commit

Permalink
Changes from PR comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelgsharp committed Sep 30, 2021
1 parent 9c7556a commit 86d301f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/Microsoft.ML.Data/Prediction/CalibratorCatalog.cs
Expand Up @@ -204,7 +204,6 @@ private protected CalibratorTransformer(IHostEnvironment env, ModelLoadContext c
string ISingleFeaturePredictionTransformer.FeatureColumnName => ((ISingleFeaturePredictionTransformer<TICalibrator>)this).FeatureColumnName;

DataViewType ISingleFeaturePredictionTransformer<TICalibrator>.FeatureColumnType => NumberDataViewType.Single;
DataViewType ISingleFeaturePredictionTransformer.FeatureColumnType => ((ISingleFeaturePredictionTransformer<TICalibrator>)this).FeatureColumnType;

TICalibrator IPredictionTransformer<TICalibrator>.Model => _calibrator;

Expand Down
3 changes: 0 additions & 3 deletions src/Microsoft.ML.Data/Prediction/IPredictionTransformer.cs
Expand Up @@ -45,8 +45,5 @@ internal interface ISingleFeaturePredictionTransformer : ITransformer
{
/// <summary>The name of the feature column.</summary>
string FeatureColumnName { get; }

/// <summary>Holds information about the type of the feature column.</summary>
DataViewType FeatureColumnType { get; }
}
}
Expand Up @@ -681,7 +681,7 @@ private static double[] ComputeSequenceDeltas(IReadOnlyList<double> 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);
Expand Down Expand Up @@ -721,19 +721,17 @@ private static double[] ComputeSequenceDeltas(IReadOnlyList<double> 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
Expand Down

0 comments on commit 86d301f

Please sign in to comment.