Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No ONNX model export support for {FixedPlatt, Isotonic, Naive}CalibratorEstimator(s) #5277

Open
mstfbl opened this issue Jul 2, 2020 · 2 comments
Assignees
Labels
enhancement New feature or request onnx Exporting ONNX models or loading ONNX models P2 Priority of the issue for triage purpose: Needs to be fixed at some point. test related to tests

Comments

@mstfbl
Copy link
Contributor

mstfbl commented Jul 2, 2020

For tracking purposes. The following CalibratorEstimators do not have ONNX model conversion support:

  • FixedPlattCalibratorEstimator
  • IsotonicCalibratorEstimator
  • NaiveCalibratorEstimator

PlattCalibratorEstimator does have ONNX export support. This issue will be closed when the remaining calibrator estimators have ONNX export support, and are being tested for ONNX conversion in the manner below as PlattCalibratorEstimator is being tested:

public void PlattCalibratorOnnxConversionTest()
{
var mlContext = new MLContext(seed: 1);
string dataPath = GetDataPath("breast-cancer.txt");
// Now read the file (remember though, readers are lazy, so the actual reading will happen when the data is accessed).
var dataView = mlContext.Data.LoadFromTextFile<BreastCancerBinaryClassification>(dataPath, separatorChar: '\t', hasHeader: true);
List<IEstimator<ITransformer>> estimators = new List<IEstimator<ITransformer>>()
{
mlContext.BinaryClassification.Trainers.AveragedPerceptron(),
mlContext.BinaryClassification.Trainers.FastForest(),
mlContext.BinaryClassification.Trainers.FastTree(),
mlContext.BinaryClassification.Trainers.LbfgsLogisticRegression(),
mlContext.BinaryClassification.Trainers.LinearSvm(),
mlContext.BinaryClassification.Trainers.Prior(),
mlContext.BinaryClassification.Trainers.SdcaLogisticRegression(),
mlContext.BinaryClassification.Trainers.SdcaNonCalibrated(),
mlContext.BinaryClassification.Trainers.SgdCalibrated(),
mlContext.BinaryClassification.Trainers.SgdNonCalibrated(),
mlContext.BinaryClassification.Trainers.SymbolicSgdLogisticRegression(),
};
if (Environment.Is64BitProcess)
{
estimators.Add(mlContext.BinaryClassification.Trainers.LightGbm());
}
var initialPipeline = mlContext.Transforms.ReplaceMissingValues("Features").
Append(mlContext.Transforms.NormalizeMinMax("Features"));
foreach (var estimator in estimators)
{
var pipeline = initialPipeline.Append(estimator).Append(mlContext.BinaryClassification.Calibrators.Platt());
var onnxFileName = $"{estimator}-WithPlattCalibrator.onnx";
TestPipeline(pipeline, dataView, onnxFileName, new ColumnComparison[] { new ColumnComparison("Score", 3), new ColumnComparison("PredictedLabel"), new ColumnComparison("Probability", 3) });
}
Done();
}

@mstfbl mstfbl added enhancement New feature or request test related to tests P2 Priority of the issue for triage purpose: Needs to be fixed at some point. onnx Exporting ONNX models or loading ONNX models labels Jul 2, 2020
@mstfbl mstfbl self-assigned this Jul 2, 2020
@antoniovs1029
Copy link
Member

For the record, support for onnx export of PlattCalibrator was added on the PR:
#4699

EDIT: After a quick look, it seems that doing this for PlattCalibrator was straightforward because it already had its own implementation of how to export it to Onnx. But for the other calibrators, I think it would also be necessary to make that implementation. (Note: I'm not sure about Naive or Isotonic, but at least FixedPlatt might be able to share the same logic to save as Onnx as the one used for Platt).

@mstfbl
Copy link
Contributor Author

mstfbl commented Jul 21, 2020

Update: Merged PR #5289 has added and verified ONNX export support for the Naive and FixedPlatt calibrator estimators. PR #5298 is set to add ONNX export support for the Isotonic calibrator estimator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request onnx Exporting ONNX models or loading ONNX models P2 Priority of the issue for triage purpose: Needs to be fixed at some point. test related to tests
Projects
None yet
Development

No branches or pull requests

2 participants