Skip to content

Commit

Permalink
New PFI API (#5934)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelgsharp authored Oct 1, 2021
1 parent d4c9dd4 commit 2da3488
Show file tree
Hide file tree
Showing 5 changed files with 591 additions and 15 deletions.
3 changes: 2 additions & 1 deletion src/Microsoft.ML.Data/Prediction/CalibratorCatalog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public CalibratorTransformer<TICalibrator> Fit(IDataView input)
/// where score can be viewed as a feature while probability is treated as the label.
/// </summary>
/// <typeparam name="TICalibrator">The <see cref="ICalibrator"/> used to transform the data.</typeparam>
public abstract class CalibratorTransformer<TICalibrator> : RowToRowTransformerBase, ISingleFeaturePredictionTransformer<TICalibrator>
public abstract class CalibratorTransformer<TICalibrator> : RowToRowTransformerBase, ISingleFeaturePredictionTransformer<TICalibrator>, ISingleFeaturePredictionTransformer
where TICalibrator : class, ICalibrator
{
private readonly TICalibrator _calibrator;
Expand Down Expand Up @@ -201,6 +201,7 @@ private protected CalibratorTransformer(IHostEnvironment env, ModelLoadContext c
}

string ISingleFeaturePredictionTransformer<TICalibrator>.FeatureColumnName => DefaultColumnNames.Score;
string ISingleFeaturePredictionTransformer.FeatureColumnName => ((ISingleFeaturePredictionTransformer<TICalibrator>)this).FeatureColumnName;

DataViewType ISingleFeaturePredictionTransformer<TICalibrator>.FeatureColumnType => NumberDataViewType.Single;

Expand Down
12 changes: 12 additions & 0 deletions src/Microsoft.ML.Data/Prediction/IPredictionTransformer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,16 @@ public interface ISingleFeaturePredictionTransformer<out TModel> : IPredictionTr
/// <summary>Holds information about the type of the feature column.</summary>
DataViewType FeatureColumnType { get; }
}

/// <summary>
/// An ISingleFeaturePredictionTransformer contains the name of the <see cref="FeatureColumnName"/>
/// and its type, <see cref="FeatureColumnType"/>. Implementations of this interface, have the ability
/// to score the data of an input <see cref="IDataView"/> through the <see cref="ITransformer.Transform(IDataView)"/>
/// </summary>
[BestFriend]
internal interface ISingleFeaturePredictionTransformer : ITransformer
{
/// <summary>The name of the feature column.</summary>
string FeatureColumnName { get; }
}
}
2 changes: 1 addition & 1 deletion src/Microsoft.ML.Data/Scorers/PredictionTransformer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public void Dispose()
/// Those are all the transformers that work with one feature column.
/// </summary>
/// <typeparam name="TModel">The model used to transform the data.</typeparam>
public abstract class SingleFeaturePredictionTransformerBase<TModel> : PredictionTransformerBase<TModel>, ISingleFeaturePredictionTransformer<TModel>
public abstract class SingleFeaturePredictionTransformerBase<TModel> : PredictionTransformerBase<TModel>, ISingleFeaturePredictionTransformer<TModel>, ISingleFeaturePredictionTransformer
where TModel : class
{
/// <summary>
Expand Down
Loading

0 comments on commit 2da3488

Please sign in to comment.